On Wed, Nov 01 2023, Theo Buehler <tb@theobuehler.org> wrote:
> I ran a bulk with the full diff removing syscall from libc and kernel
> applied. Here's what broke or threw a warning. Running nm on .o files
> in WRKDIR didn't find any unexpected 'syscall U'.
>
> Non-Go ports with warnings or build failures. Some details at the end:
>
> net/torsocks probably BROKEN
> print/luametatex easy fix
> x11/qt{5,6}/qtwebengine easy fix
>
> Go ports that didn't build due to the linker erroring on missing syscall:
>
> databases/influx-cli
> databases/influxdb
> databases/mongo-tools
> devel/hub
> devel/reposurgeon
> games/clidle
> mail/aerc
> net/dendrite
> net/gomuks
> net/headscale
> net/minio/client
> net/minio/server
> net/termshark
> security/cfssl
> security/step-ca
> sysutils/beats/metricbeat
> sysutils/beats/packetbeat
> sysutils/chezmoi
> sysutils/docker-cli
> sysutils/node_exporter
> sysutils/nomad
> sysutils/rclone
> sysutils/snmp_exporter
> sysutils/telegraf
> www/gitea
>
> net/torsocks
>
> checking for syscall... (cached) no
> configure: error: "Required function not found"
>
> This port intercepts syscall from libc via an LD_PRELOAD wrapper and
> inspects arguments to decide how to act on them, i.e., wether to call
> libc's version or do its won thing. It is not obvious how to fix the
> approach taken in src/lib/syscall.c. This needs some serious thought.
> Probably the port needs to be marked BROKEN.
The approach taken in src/lib/syscall.c is to intercept syscall(2) uses
from applications, but we plan to prevent that, so there's nothing to
intercept any more. So we can just ifdef that code out. With this,
torsocks seems to do the right thing (lightly tested with ftp(1)).
Porting concerns:
- no idea if it makes sense for libtorsocks.so to be handled as a shared
lib, but since the diff removes public symbols, it comes with a shared
lib major bump.
- running autoreconf in pre-patch instead of post-patch doesn't fly
since we want to patch configure.ac ; instead I switched to
CONFIGURE_STYLE=autoreconf.
While here, make plist shows a ChangeLog file.
I already have an ok from tb@. ok?
Index: Makefile
===================================================================
RCS file: /cvs/ports/net/torsocks/Makefile,v
retrieving revision 1.17
diff -u -p -r1.17 Makefile
--- Makefile 27 Sep 2023 14:18:37 -0000 1.17
+++ Makefile 4 Nov 2023 14:16:12 -0000
@@ -1,8 +1,9 @@
COMMENT = socks proxy for use with tor
DISTNAME = torsocks-2.3.0
+REVISION = 0
-SHARED_LIBS = torsocks 1.0 # 0.0
+SHARED_LIBS = torsocks 2.0 # 0.0
CATEGORIES = net
@@ -20,21 +21,14 @@ SITES= https://gitweb.torproject.org/t
AUTOCONF_VERSION= 2.69
AUTOMAKE_VERSION= 1.15
-BUILD_DEPENDS= ${MODGNU_AUTOCONF_DEPENDS} \
- ${MODGNU_AUTOMAKE_DEPENDS}
-
USE_LIBTOOL = gnu
RUN_DEPENDS = net/tor
FAKE_FLAGS = CONFDIR=${PREFIX}/share/examples/torsocks
-CONFIGURE_STYLE = gnu
-
-pre-patch:
- cd ${WRKSRC} && \
- AUTOCONF_VERSION=${AUTOCONF_VERSION} \
- AUTOMAKE_VERSION=${AUTOMAKE_VERSION} ./autogen.sh
+CONFIGURE_STYLE = autoreconf
+AUTORECONF = ${WRKSRC}/autogen.sh
pre-configure:
${SUBST_CMD} ${WRKSRC}/src/bin/torsocks.in
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_ac 4 Nov 2023 14:16:12 -0000
@@ -0,0 +1,21 @@
+Don't require syscall and __syscall functions.
+
+For upstream: needs an autoheader call to update include/config.h.in
+
+Index: configure.ac
+--- configure.ac.orig
++++ configure.ac
+@@ -53,10 +53,12 @@ AC_CHECK_HEADERS(dlfcn.h sys/syscall.h sys/socket.h ar
+
+ dnl Checks for required library functions.
+ AC_CHECK_FUNCS(strcspn strdup strerror strcasecmp strncasecmp mmap munmap \
+- socket connect close syscall recv send memset memcpy strlen \
++ socket connect close recv send memset memcpy strlen \
+ strncpy strcmp malloc calloc strstr strtoul free,,
+ [AC_MSG_ERROR("Required function not found")]
+ )
++dnl Checks for optional library functions
++AC_CHECK_FUNCS(syscall __syscall,,)
+
+ ##############################################################################
+ # 3. Determine libraries we need to include when linking libtorsocks.
Index: patches/patch-src_lib_syscall_c
===================================================================
RCS file: /cvs/ports/net/torsocks/patches/patch-src_lib_syscall_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_lib_syscall_c
--- patches/patch-src_lib_syscall_c 1 Jun 2022 12:35:11 -0000 1.3
+++ patches/patch-src_lib_syscall_c 4 Nov 2023 14:16:12 -0000
@@ -1,37 +1,28 @@
+Don't attempt to intercept syscall(2) if not available.
+
Index: src/lib/syscall.c
--- src/lib/syscall.c.orig
+++ src/lib/syscall.c
-@@ -457,7 +457,8 @@ LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number,
- ret = handle_close(args);
- break;
- case TSOCKS_NR_MMAP:
--#if (defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(__x86_64)
-+#if (defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
-+ defined(__OpenBSD__) && defined(__x86_64))
- /*
- * On an 64 bit *BSD system, __syscall(2) should be used for mmap().
- * This is NOT suppose to happen but for protection we deny that call.
-@@ -486,7 +487,7 @@ LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number,
- * own memory using mmap() called by syscall(). Same for munmap().
- */
- ret = handle_mmap(args);
--
No comments:
Post a Comment