[tor-dev] torsocks-v2.0.0-rc3 NetBSD improvements

Thomas Klausner wiz at NetBSD.org
Tue Nov 5 15:14:33 UTC 2013


Hi!

I've patched torsocks-v2.0.0-rc3 to compile on NetBSD.

There is one warning left:
syscall.c: In function 'handle_mmap':
syscall.c:88:9: warning: cast from pointer to integer of different size

and I haven't done any functional tests yet. What is the easiest way
to do that?

Attached are the patches I've used to get this far.

Some additional comments: The package installs a few files where it
shouldn't:

share/DEBUG
share/SOCKS5
share/socks-extensions.txt

These belong in share/doc/torsocks instead, I guess.

And what is the point of src.old inside the tarball?

Cheers,
 Thomas

-------------- next part --------------
$NetBSD$

Handle NetBSD like FreeBSD.

--- src/common/compat.c.orig	2013-11-03 18:24:51.000000000 +0000
+++ src/common/compat.c
@@ -19,7 +19,7 @@
 
 #include "compat.h"
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Initialize a pthread mutex. This never fails.
@@ -71,4 +71,4 @@ void tsocks_mutex_unlock(tsocks_mutex_t 
 	assert(!ret);
 }
 
-#endif /* __GLIBC__, __darwin__, __FreeBSD__ */
+#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
-------------- next part --------------
$NetBSD$

Handle NetBSD like FreeBSD.

--- src/common/compat.h.orig	2013-11-03 18:24:51.000000000 +0000
+++ src/common/compat.h
@@ -22,7 +22,7 @@
 #define __darwin__	1
 #endif
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 #define RTLD_NEXT	((void *) -1)
 
@@ -43,7 +43,7 @@ void tsocks_mutex_unlock(tsocks_mutex_t 
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__, __darwin__, __FreeBSD__ */
+#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
 
 #if defined(__linux__)
 
@@ -84,17 +84,21 @@ void tsocks_mutex_unlock(tsocks_mutex_t 
 
 #endif /* __linux__ */
 
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__darwin__))
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__darwin__) || defined(__NetBSD__))
 
 #include <sys/syscall.h>
 #include <unistd.h>
 
+#if defined(__NetBSD__)
+#define SYS_socket          SYS___socket30
+#endif
+
 #define TSOCKS_NR_SOCKET    SYS_socket
 #define TSOCKS_NR_CONNECT   SYS_connect
 #define TSOCKS_NR_CLOSE     SYS_close
 #define TSOCKS_NR_MMAP      SYS_mmap
 #define TSOCKS_NR_MUNMAP    SYS_munmap
 
-#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__ */
+#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__, __NetBSD__ */
 
 #endif /* TORSOCKS_COMPAT_H */
-------------- next part --------------
$NetBSD$

Handle NetBSD like FreeBSD.

--- src/common/ref.h.orig	2013-11-03 18:24:51.000000000 +0000
+++ src/common/ref.h
@@ -26,7 +26,7 @@ struct ref {
 	long count;
 };
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Get a reference by incrementing the refcount.
-------------- next part --------------
$NetBSD$

Handle NetBSD like FreeBSD.

--- src/lib/torsocks.h.orig	2013-11-03 18:24:51.000000000 +0000
+++ src/lib/torsocks.h
@@ -33,7 +33,7 @@
 #define TSOCKS_DECL(name, type, sig) \
 	extern type tsocks_##name(sig);
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /* connect(2) */
 #include <sys/types.h>
@@ -171,7 +171,7 @@ struct hostent **__result, int *__h_errn
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__ , __FreeBSD__, __darwin__ */
+#endif /* __GLIBC__ , __FreeBSD__, __darwin__, __NetBSD__ */
 
 #if (defined(__linux__))
 
@@ -186,7 +186,7 @@ struct hostent **__result, int *__h_errn
 
 #endif /* __linux__ */
 
-#if (defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /* syscall(2) */
 #define LIBC_SYSCALL_NAME syscall
@@ -195,7 +195,7 @@ struct hostent **__result, int *__h_errn
 #define LIBC_SYSCALL_SIG int __number, ...
 #define LIBC_SYSCALL_ARGS __number
 
-#endif /* __FreeBSD__, __darwin__ */
+#endif /* __FreeBSD__, __darwin__, __NetBSD__ */
 
 #if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
 
-------------- next part --------------
$NetBSD$

isdigit() only accepts unsigned chars and -1.
NetBSD's version is quite picky about this.

--- tests/utils/tap/tap.c.orig	2013-11-03 18:24:51.000000000 +0000
+++ tests/utils/tap/tap.c
@@ -94,7 +94,7 @@ _gen_result(int ok, const char *func, ch
 		if(local_test_name) {
 			name_is_digits = 1;
 			for(c = local_test_name; *c != '\0'; c++) {
-				if(!isdigit(*c) && !isspace(*c)) {
+				if(!isdigit((unsigned char)*c) && !isspace((unsigned char)*c)) {
 					name_is_digits = 0;
 					break;
 				}


More information about the tor-dev mailing list