commit 75b9f9880737197b8c00c897e04c1c4116ee3de0 Author: Robert Hogan robert@roberthogan.net Date: Mon Feb 14 22:51:40 2011 +0000
Compile and (apparently) work on OpenBSD
Need more testing to be sure, but it looks like it works OK. --- configure.in | 12 ++++++++++++ src/Makefile.am | 1 - src/dead_pool.c | 5 +++++ src/torsocks.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in index ca5af2a..cdb99e7 100644 --- a/configure.in +++ b/configure.in @@ -518,6 +518,9 @@ SPECIALLIBS=${LIBS} AC_SUBST(SPECIALLIBS) LIBS=${SIMPLELIBS}
+AC_SEARCH_LIBS(dlopen, [dl]) +AC_SEARCH_LIBS(inet_aton, [resolv]) + dnl Linker checks for Mac OSX, which uses DYLD_INSERT_LIBRARIES dnl instead of LD_PRELOAD case "$host_os" in @@ -562,6 +565,15 @@ darwin*) ;; esac
+dnl OpenBSD needs -lpthread. It also doesn't support AI_V4MAPPED. +case $host in +*-*-openbsd*) + AC_DEFINE(OPENBSD, 1, "Define to handle OpenBSD") + AC_SEARCH_LIBS(pthread_create, [pthread]) + AC_SEARCH_LIBS(pthread_detach, [pthread]) + ;; +esac + AC_SUBST(SHLIB_EXT) AC_SUBST(LD_PRELOAD)
diff --git a/src/Makefile.am b/src/Makefile.am index 134dc42..cce43f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,5 @@ # Makefile used by configure to create real Makefile
-LIBS = -ldl -lc -lresolv libdir = @libdir@/torsocks
# Install configuration file diff --git a/src/dead_pool.c b/src/dead_pool.c index bba90d3..6f4043a 100644 --- a/src/dead_pool.c +++ b/src/dead_pool.c @@ -752,6 +752,10 @@ our_getipnodebyname(dead_pool *pool, const char *name, int af, int flags, /* Caller has requested an AF_INET6 address, and is not prepared to accept IPv4-mapped IPV6 addresses. There's nothing we can do to service their request. */ +#ifdef OPENBSD + /* OpenBSD doesn't support the AI_V4MAPPED flag, so just return. */ + return NULL; +#else if((flags & AI_V4MAPPED) == 0) { show_msg(MSGWARN, "getipnodebyname: asked for V6 addresses only, " "but torsocks can't handle that\n"); @@ -760,6 +764,7 @@ our_getipnodebyname(dead_pool *pool, const char *name, int af, int flags, } else { want_4in6 = 1; } +#endif }
pos = store_pool_entry(pool, (char *)name, &pool_addr); diff --git a/src/torsocks.c b/src/torsocks.c index 579751e..4239ced 100644 --- a/src/torsocks.c +++ b/src/torsocks.c @@ -147,7 +147,7 @@ static pthread_mutex_t torsocks_init_mutex = PTHREAD_MUTEX_INITIALIZER; void torsocks_init(void) { #define LOAD_ERROR(s,l) { \ - char *error; \ + const char *error; \ error = dlerror(); \ show_msg(l, "The symbol %s() was not found in any shared " \ "library. The error reported was: %s!\n", s, \