Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD patches #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void));
#define TSOCKS_NR_GETPEERNAME SYS_getpeername
#define TSOCKS_NR_LISTEN SYS_listen
#define TSOCKS_NR_RECVMSG SYS_recvmsg
#if defined(__FreeBSD__)
#define TSOCKS_NR_GETPID SYS_getpid
#define TSOCKS_NR_FORK SYS_fork
#endif

#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__, __NetBSD__ */

Expand Down
8 changes: 8 additions & 0 deletions src/lib/torsocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,17 @@ static void init_libc_symbols(void)
tsocks_libc_socket = dlsym(libc_ptr, LIBC_SOCKET_NAME_STR);
tsocks_libc_syscall = dlsym(libc_ptr, LIBC_SYSCALL_NAME_STR);
tsocks_libc_execve = dlsym(libc_ptr, LIBC_EXECVE_NAME_STR);
#if defined(__FreeBSD__)
tsocks_libc_accept = dlsym(libc_ptr, LIBC_ACCEPT_NAME_STR);
#else
tsocks_libc_accept4 = dlsym(libc_ptr, LIBC_ACCEPT4_NAME_STR);
#endif
if (!tsocks_libc_connect || !tsocks_libc_close || !tsocks_libc_socket ||
#if defined(__FreeBSD__)
!tsocks_libc_syscall || !tsocks_libc_execve || ! tsocks_libc_accept) {
#else
!tsocks_libc_syscall || !tsocks_libc_execve || ! tsocks_libc_accept4) {
#endif
ERR("Unable to lookup symbols in " LIBC_NAME "(%s)", dlerror());
goto error;
}
Expand Down