izzy Meyer wrote:
On Wed, 29 Jul 2026 11:30:34 +0100
Stuart Henderson <[email protected]> wrote:

On 2026/07/28 20:38, Kolton wrote:
Hi torsocks is over 2 years old in the ports does anyone know how
to update it? Idk much about coding and am like an old granny using
OpenBSD thx so much

I don't use torsocks so runtime is not tested, but at least the newer
version builds with this.

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/torsocks/Makefile,v
diff -u -p -r1.19 Makefile
--- Makefile    31 Jan 2024 22:46:19 -0000      1.19
+++ Makefile    29 Jul 2026 10:28:53 -0000
@@ -1,6 +1,6 @@
  COMMENT =             SOCKS proxy for use with Tor
-V = 2.4.0
+V =                    2.5.0
  DISTNAME =            torsocks-v${V}
  PKGNAME =             ${DISTNAME:S/v//}
@@ -27,6 +27,7 @@ USE_LIBTOOL = gnu
  RUN_DEPENDS =         net/tor
FAKE_FLAGS = CONFDIR=${PREFIX}/share/examples/torsocks
+CFLAGS +=              -DAI_V4MAPPED=0
CONFIGURE_STYLE = autoreconf autoheader Index: distinfo
===================================================================
RCS file: /cvs/ports/net/torsocks/distinfo,v
diff -u -p -r1.5 distinfo
--- distinfo    31 Jan 2024 22:46:19 -0000      1.5
+++ distinfo    29 Jul 2026 10:28:53 -0000
@@ -1,2 +1,2 @@
-SHA256 (torsocks-v2.4.0.tar.gz) =
wBtHHYntqfPI3LhaRI6AZmktBwf5/4sqx+ZlpgIpG4c= -SIZE
(torsocks-v2.4.0.tar.gz) = 118991 +SHA256 (torsocks-v2.5.0.tar.gz) =
D8jhjy3C4S8RKQVPbVrMfsw/A0W7V+1lP8jGZ05uzH4= +SIZE
(torsocks-v2.5.0.tar.gz) = 122020 Index: patches/patch-configure_ac
===================================================================
RCS file: /cvs/ports/net/torsocks/patches/patch-configure_ac,v
diff -u -p -r1.1 patch-configure_ac
--- patches/patch-configure_ac  11 Nov 2023 11:51:22
-0000   1.1 +++ patches/patch-configure_ac      29 Jul 2026
10:28:53 -0000 @@ -5,16 +5,18 @@ For upstream: needs an autoheader
call t Index: configure.ac
  --- configure.ac.orig
  +++ configure.ac
-@@ -53,10 +53,12 @@ AC_CHECK_HEADERS(dlfcn.h sys/syscall.h
sys/socket.h ar +@@ -53,13 +53,14 @@ 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,,
+                strcmp malloc calloc strstr strtoul free,,
        [AC_MSG_ERROR("Required function not found")]
   )
-+dnl Checks for optional library functions
+
+ dnl Checks for optional library functions.
+ AC_CHECK_FUNCS(strlcpy strlcat)
  +AC_CHECK_FUNCS(syscall __syscall,,)
##############################################################################
Index: patches/patch-src_common_compat_c
===================================================================
RCS file: /cvs/ports/net/torsocks/patches/patch-src_common_compat_c,v
diff -u -p -r1.2 patch-src_common_compat_c
--- patches/patch-src_common_compat_c   11 Mar 2022 19:47:53
-0000   1.2 +++ patches/patch-src_common_compat_c       29 Jul
2026 10:28:53 -0000 @@ -9,9 +9,9 @@ Index: src/common/compat.c
  +             defined(__darwin__) || defined(__NetBSD__) || \
  +             defined(__OpenBSD__))
- /*
-  * Initialize a pthread mutex. This never fails.
-@@ -97,4 +98,4 @@ void tsocks_once(tsocks_once_t *o, void
(*init_routine
+ /* Inline the strl functions if the platform doesn't have them. */
+ #ifndef HAVE_STRLCPY
+@@ -105,4 +106,4 @@ void tsocks_once(tsocks_once_t *o, void
(*init_routine tsocks_mutex_unlock(&o->mutex);
   }
Index: patches/patch-src_common_compat_h
===================================================================
RCS file: /cvs/ports/net/torsocks/patches/patch-src_common_compat_h,v
diff -u -p -r1.4 patch-src_common_compat_h
--- patches/patch-src_common_compat_h   31 Jan 2024 22:46:19
-0000   1.4 +++ patches/patch-src_common_compat_h       29 Jul
2026 10:28:53 -0000 @@ -11,7 +11,7 @@ Index: src/common/compat.h
#ifndef RTLD_NEXT
   #define RTLD_NEXT    ((void *) -1)
-@@ -58,7 +59,7 @@ void tsocks_once(tsocks_once_t *o, void
(*init_routine +@@ -65,7 +66,7 @@ void tsocks_once(tsocks_once_t *o,
void (*init_routine
   #else
   #error "OS not supported."
@@ -20,7 +20,7 @@ Index: src/common/compat.h
#if defined(__linux__)
   #include <unistd.h>
-@@ -204,7 +205,8 @@ void tsocks_once(tsocks_once_t *o, void
(*init_routine +@@ -211,7 +212,8 @@ void tsocks_once(tsocks_once_t
*o, void (*init_routine
   #endif /* __linux__ */
@@ -30,7 +30,7 @@ Index: src/common/compat.h #include <sys/syscall.h>
   #include <unistd.h>
-@@ -223,7 +225,7 @@ void tsocks_once(tsocks_once_t *o, void
(*init_routine +@@ -230,7 +232,7 @@ void tsocks_once(tsocks_once_t
*o, void (*init_routine #define TSOCKS_NR_LISTEN    SYS_listen
   #define TSOCKS_NR_RECVMSG   SYS_recvmsg

This diff seems to work at runtime too. curl-ing ifconfig.me via
torsocks results in a different IP than without. I have a personal tor
bridge on my lan that torsocks is configured to point to. Seems to work
well. Thanks for the diff!

It is a shame that OpenBSD does not have Linux-style namespaces, because Oniux depends on network, mount, PID, and user namespaces to isolate an application and give it access only to a virtual interface connected to Tor. That is why it cannot be ported directly: it would have to be almost completely redesigned.

A more realistic alternative would be to create an OpenBSD-specific fork of torsocks. It could still use LD_PRELOAD to intercept socket(), connect(), getaddrinfo(), and other networking functions, but enforce a stricter policy: block connections that cannot be redirected through SOCKS, disable UDP and raw sockets, force DNS resolution through Tor, and terminate the process if it attempts any direct connection.

It could also include a privileged launcher that places the process inside an rdomain with no direct Internet route, applies PF rules, and then drops privileges. Combining torsocks, rdomain, PF, a dedicated user, pledge(), and unveil() would not provide the same isolation as Oniux, especially against statically linked binaries or direct system calls, but it could be much more robust than the current torsocks implementation.

Reply via email to