2011-09-11 14:45:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
prefix=/usr/local
|
2016-10-16 11:28:05 +00:00
|
|
|
OUR_CPPFLAGS=
|
2011-09-11 14:45:40 +00:00
|
|
|
|
2016-10-08 19:59:37 +00:00
|
|
|
# Get a temporary filename
|
2020-10-29 12:05:58 +00:00
|
|
|
fail() { printf "%s\n" "$1" >&2 ; exit 1 ; }
|
2016-10-08 19:59:37 +00:00
|
|
|
i=0
|
|
|
|
set -C
|
|
|
|
while : ; do i=$(($i+1))
|
|
|
|
tmpc="./conf$$-$PPID-$i.c"
|
|
|
|
2>|/dev/null > "$tmpc" && break
|
|
|
|
test "$i" -gt 50 && fail "$0: cannot create temporary file $tmpc"
|
|
|
|
done
|
|
|
|
set +C
|
|
|
|
trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
|
|
|
|
|
2015-10-01 13:06:14 +00:00
|
|
|
check_compile() {
|
|
|
|
printf "checking %s ... " "$1"
|
2016-10-08 19:59:37 +00:00
|
|
|
printf "$3" > "$tmpc"
|
2015-10-01 13:06:14 +00:00
|
|
|
local res=0
|
2018-12-25 17:58:54 +00:00
|
|
|
$CC $OUR_CPPFLAGS $CPPFLAGS $2 $CFLAGS "$tmpc" -o /dev/null >/dev/null 2>&1 \
|
2015-10-01 13:06:14 +00:00
|
|
|
|| res=1
|
|
|
|
test x$res = x0 && \
|
2016-10-16 11:28:05 +00:00
|
|
|
{ printf "yes\n" ; test x"$2" = x || OUR_CPPFLAGS="$OUR_CPPFLAGS $2" ; } \
|
2015-10-01 13:06:14 +00:00
|
|
|
|| printf "no\n"
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2016-02-04 12:49:43 +00:00
|
|
|
check_define() {
|
|
|
|
printf "checking whether \$CC defines %s ... " "$1"
|
|
|
|
local res=1
|
2016-10-16 11:28:05 +00:00
|
|
|
$CC $OUR_CPPFLAGS $CPPFLAGS $CFLAGS -dM -E - </dev/null | grep "$1" >/dev/null && res=0
|
2016-02-04 12:49:43 +00:00
|
|
|
test x$res = x0 && printf "yes\n" || printf "no\n"
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
|
|
|
check_compile_run() {
|
|
|
|
printf "checking %s ... " "$1"
|
2016-10-08 19:59:37 +00:00
|
|
|
printf "$2" > "$tmpc"
|
2016-02-04 12:49:43 +00:00
|
|
|
local res=0
|
2016-10-16 11:28:05 +00:00
|
|
|
$CC $OUR_CPPFLAGS $CPPFLAGS $CFLAGS "$tmpc" -o "$tmpc".out >/dev/null 2>&1 \
|
2016-02-04 12:49:43 +00:00
|
|
|
|| res=1
|
2016-10-08 19:59:37 +00:00
|
|
|
test x$res = x0 && { "$tmpc".out || res=1 ; }
|
|
|
|
rm -f "$tmpc".out
|
2016-02-04 12:49:43 +00:00
|
|
|
test x$res = x0 && printf "yes\n" || printf "no\n"
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:41:57 +00:00
|
|
|
check_link_silent() {
|
|
|
|
printf "$2" > "$tmpc"
|
|
|
|
$CC $OUR_CPPFLAGS $CPPFLAGS $1 $CFLAGS "$tmpc" -o /dev/null >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
check_link() {
|
|
|
|
printf "checking %s ... " "$1"
|
|
|
|
local res=0
|
|
|
|
check_link_silent "$2" "$3" || res=1
|
|
|
|
test x$res = x0 && printf "yes\n" || printf "no\n"
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2012-07-07 22:35:59 +00:00
|
|
|
usage() {
|
|
|
|
echo "supported arguments"
|
2016-02-04 12:56:00 +00:00
|
|
|
echo "--prefix=/path default: $prefix"
|
|
|
|
echo "--exec_prefix=/path default: $prefix/bin"
|
|
|
|
echo "--bindir=/path default: $prefix/bin"
|
|
|
|
echo "--libdir=/path default: $prefix/lib"
|
|
|
|
echo "--includedir=/path default: $prefix/include"
|
|
|
|
echo "--sysconfdir=/path default: $prefix/etc"
|
|
|
|
echo "--ignore-cve default: no"
|
2015-05-21 12:46:17 +00:00
|
|
|
echo " if set to yes ignores CVE-2015-3887 and makes it possible"
|
|
|
|
echo " to preload from current dir (insecure)"
|
2018-01-09 13:50:08 +00:00
|
|
|
echo "--fat-binary : build for both i386 and x86_64 architectures on 64-bit Macs"
|
2012-07-07 22:35:59 +00:00
|
|
|
echo "--help : show this text"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2011-09-11 14:45:40 +00:00
|
|
|
spliteq() {
|
|
|
|
arg=$1
|
|
|
|
echo "${arg#*=}"
|
|
|
|
#alternatives echo "$arg" | cut -d= -f2-
|
|
|
|
# or echo "$arg" | sed 's/[^=]*=//'
|
|
|
|
}
|
|
|
|
|
2014-01-02 00:11:04 +00:00
|
|
|
fat_binary=
|
2015-05-21 12:46:17 +00:00
|
|
|
ignore_cve=no
|
2011-09-11 14:45:40 +00:00
|
|
|
parsearg() {
|
|
|
|
case "$1" in
|
2012-01-30 17:26:38 +00:00
|
|
|
--prefix=*) prefix=`spliteq $1`;;
|
2011-09-11 14:45:40 +00:00
|
|
|
--exec_prefix=*) exec_prefix=`spliteq $1`;;
|
|
|
|
--bindir=*) bindir=`spliteq $1`;;
|
|
|
|
--libdir=*) libdir=`spliteq $1`;;
|
|
|
|
--includedir=*) includedir=`spliteq $1`;;
|
2012-01-30 17:26:38 +00:00
|
|
|
--sysconfdir=*) sysconfdir=`spliteq $1`;;
|
2015-05-21 12:46:17 +00:00
|
|
|
--ignore-cve) ignore_cve=1;;
|
|
|
|
--ignore-cve=*) ignore_cve=`spliteq $1`;;
|
2014-01-02 00:11:04 +00:00
|
|
|
--fat-binary) fat_binary=1;;
|
2012-07-07 22:35:59 +00:00
|
|
|
--help) usage;;
|
2011-09-11 14:45:40 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
while true ; do
|
|
|
|
case $1 in
|
|
|
|
-*) parsearg "$1"; shift;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$exec_prefix" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
exec_prefix=$prefix
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$libdir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
libdir=$prefix/lib
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$includedir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
includedir=$prefix/include
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$sysconfdir" ] ; then
|
2012-01-30 17:26:38 +00:00
|
|
|
sysconfdir=$prefix/etc
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$bindir" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
bindir=$exec_prefix/bin
|
|
|
|
fi
|
|
|
|
|
2012-01-30 17:35:03 +00:00
|
|
|
if [ -z "$CC" ] ; then
|
2011-09-11 14:45:40 +00:00
|
|
|
CC=cc
|
|
|
|
fi
|
|
|
|
|
2018-04-12 06:13:26 +00:00
|
|
|
echo > config.mak
|
2018-01-09 13:50:08 +00:00
|
|
|
|
|
|
|
bsd_detected=false
|
|
|
|
isbsd() {
|
|
|
|
$bsd_detected
|
|
|
|
}
|
|
|
|
mac_detected=false
|
|
|
|
ismac() {
|
|
|
|
$mac_detected
|
|
|
|
}
|
|
|
|
mac_64=false
|
|
|
|
ismac64() {
|
|
|
|
$mac_64
|
|
|
|
}
|
2018-01-10 16:41:57 +00:00
|
|
|
solaris_detected=false
|
|
|
|
issolaris() {
|
|
|
|
$solaris_detected
|
|
|
|
}
|
2020-08-17 08:31:04 +00:00
|
|
|
haiku_detected=false
|
|
|
|
ishaiku() {
|
|
|
|
$haiku_detected
|
|
|
|
}
|
2018-01-09 13:50:08 +00:00
|
|
|
|
2020-12-18 12:33:49 +00:00
|
|
|
check_compile 'whether C compiler works' '' 'int main() {return 0;}' || fail 'error: install a C compiler and library'
|
|
|
|
|
2018-12-02 13:48:43 +00:00
|
|
|
check_compile 'whether we have GNU-style getservbyname_r()' "-DHAVE_GNU_GETSERVBYNAME_R" \
|
|
|
|
'#define _GNU_SOURCE\n#include <netdb.h>\nint main() {\nstruct servent *se = 0;struct servent se_buf;char buf[1024];\ngetservbyname_r("foo", (void*) 0, &se_buf, buf, sizeof(buf), &se);\nreturn 0;}'
|
|
|
|
|
2018-12-25 15:20:52 +00:00
|
|
|
check_compile 'whether we have pipe2() and O_CLOEXEC' "-DHAVE_PIPE2" \
|
|
|
|
'#define _GNU_SOURCE\n#include <fcntl.h>\n#include <unistd.h>\nint main() {\nint pipefd[2];\npipe2(pipefd, O_CLOEXEC);\nreturn 0;}'
|
|
|
|
|
experimental new feature: proxy_dns_daemon
since many users complain about issues with modern, ultracomplex
clusterfuck software such as chromium, nodejs, etc, i've reconsidered
one of my original ideas how to implement remote dns lookup support.
instead of having a background thread serving requests via a pipe,
the user manually starts a background daemon process before running
proxychains, and the two processes then communicate via UDP.
this requires much less hacks (like hooking of close() to prevent
pipes from getting closed) and doesn't need to call any async-signal
unsafe code like malloc(). this means it should be much more compatible
than the previous method, however it's not as practical and slightly
slower.
it's recommended that the proxychains4-daemon runs on localhost, and
if you use proxychains-ng a lot you might want to set ip up as a service
that starts on boot. a single proxychains4-daemon should theoretically
be able to serve many parallel proxychains4 instances, but this has not
yet been tested so far. it's also possible to run the daemon on other
computers, even over internet, but currently there is no error-checking/
timeout code at all; that means the UDP connection needs to be very
stable.
the library code used for the daemon sources are from my projects
libulz[0] and htab[1], and the server code is loosely based on
microsocks[2]. their licenses are all compatible with the GPL.
if not otherwise mentioned, they're released for this purpose under
the standard proxychains-ng license (see COPYING).
[0]: https://github.com/rofl0r/libulz
[1]: https://github.com/rofl0r/htab
[2]: https://github.com/rofl0r/microsocks
2020-09-23 21:00:29 +00:00
|
|
|
check_compile 'whether we have SOCK_CLOEXEC' "-DHAVE_SOCK_CLOEXEC" \
|
|
|
|
'#define _GNU_SOURCE\n#include <sys/socket.h>\nint main() {\nreturn socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);}'
|
|
|
|
|
2018-01-09 13:50:08 +00:00
|
|
|
check_define __APPLE__ && {
|
|
|
|
mac_detected=true
|
|
|
|
check_define __x86_64__ && mac_64=true
|
|
|
|
}
|
|
|
|
check_define __FreeBSD__ && bsd_detected=true
|
|
|
|
check_define __OpenBSD__ && {
|
|
|
|
bsd_detected=true
|
|
|
|
echo "CFLAGS+=-DIS_OPENBSD">>config.mak
|
2016-02-04 12:49:43 +00:00
|
|
|
check_compile_run 'whether OpenBSDs fclose() (illegally) calls close()' \
|
|
|
|
'#include <stdio.h>\n#include<stdlib.h>\nint close(int x){exit(0);}int main(){fclose(stdin);return 1;}' && \
|
2016-10-16 11:28:05 +00:00
|
|
|
OUR_CPPFLAGS="$OUR_CPPFLAGS -DBROKEN_FCLOSE"
|
2018-01-09 13:50:08 +00:00
|
|
|
}
|
2018-01-10 16:41:57 +00:00
|
|
|
check_define __sun && check_define __SVR4 && solaris_detected=true
|
2020-08-17 08:31:04 +00:00
|
|
|
check_define __HAIKU__ && haiku_detected=true
|
2016-02-04 12:49:43 +00:00
|
|
|
|
2018-04-12 06:13:26 +00:00
|
|
|
echo "CC=$CC">>config.mak
|
2016-12-24 12:48:41 +00:00
|
|
|
[ -z "$CPPFLAGS" ] || echo "CPPFLAGS=$CPPFLAGS">>config.mak
|
|
|
|
[ -z "$CFLAGS" ] || echo "USER_CFLAGS=$CFLAGS">>config.mak
|
|
|
|
[ -z "$LDFLAGS" ] || echo "USER_LDFLAGS=$LDFLAGS">>config.mak
|
2011-09-11 14:45:40 +00:00
|
|
|
echo prefix=$prefix>>config.mak
|
|
|
|
echo exec_prefix=$exec_prefix>>config.mak
|
|
|
|
echo bindir=$bindir>>config.mak
|
|
|
|
echo libdir=$libdir>>config.mak
|
|
|
|
echo includedir=$includedir>>config.mak
|
2012-01-30 17:26:38 +00:00
|
|
|
echo sysconfdir=$sysconfdir>>config.mak
|
2016-10-16 11:28:05 +00:00
|
|
|
[ "$ignore_cve" = "no" ] && echo "CPPFLAGS+= -DSUPER_SECURE">>config.mak
|
|
|
|
[ -z "$OUR_CPPFLAGS" ] || echo "CPPFLAGS+= $OUR_CPPFLAGS" >>config.mak
|
2018-01-10 16:41:57 +00:00
|
|
|
|
|
|
|
check_link "whether we can use -Wl,--no-as-needed" "-Wl,--no-as-needed" \
|
|
|
|
"int main() { return 0; }" || echo NO_AS_NEEDED= >> config.mak
|
|
|
|
|
|
|
|
LD_SONAME_FLAG=
|
|
|
|
printf "checking what's the option to use in linker to set library name ... "
|
|
|
|
for o in --soname -h -soname -install_name; do
|
|
|
|
check_link_silent "-shared -Wl,$o,libconftest.so" "void test_func(int a) {}" && LD_SONAME_FLAG=$o && break
|
|
|
|
done
|
|
|
|
if [ -z "$LD_SONAME_FLAG" ]; then
|
|
|
|
printf '\ncannot find an option to set library name\n'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$LD_SONAME_FLAG"
|
|
|
|
echo "LD_SET_SONAME = -Wl,$LD_SONAME_FLAG," >> config.mak
|
|
|
|
|
2014-07-22 12:56:49 +00:00
|
|
|
make_cmd=make
|
2012-01-27 19:21:06 +00:00
|
|
|
if ismac ; then
|
|
|
|
echo LDSO_SUFFIX=dylib>>config.mak
|
2012-01-27 19:48:24 +00:00
|
|
|
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
|
2018-01-09 13:50:08 +00:00
|
|
|
if ismac64 && [ "$fat_binary" = 1 ] ; then
|
2014-01-02 00:11:04 +00:00
|
|
|
echo "Configuring a fat binary for i386 and x86_64"
|
|
|
|
echo MAC_CFLAGS+=-arch i386 -arch x86_64>>config.mak
|
|
|
|
echo LDFLAGS+=-arch i386 -arch x86_64>>config.mak
|
|
|
|
fi
|
2012-12-25 18:08:05 +00:00
|
|
|
elif isbsd ; then
|
|
|
|
echo LIBDL=>>config.mak
|
|
|
|
echo "CFLAGS+=-DIS_BSD">>config.mak
|
2014-07-22 12:56:49 +00:00
|
|
|
make_cmd=gmake
|
2018-01-10 16:41:57 +00:00
|
|
|
elif issolaris; then
|
|
|
|
echo "CFLAGS+=-DIS_SOLARIS -D__EXTENSIONS__" >> config.mak
|
|
|
|
echo "SOCKET_LIBS=-lsocket -lnsl" >> config.mak
|
2020-08-17 08:31:04 +00:00
|
|
|
elif ishaiku ; then
|
|
|
|
echo LIBDL=>>config.mak
|
|
|
|
echo "CFLAGS+=-DIS_HAIKU" >> config.mak
|
2012-01-27 19:21:06 +00:00
|
|
|
fi
|
2011-09-11 14:45:40 +00:00
|
|
|
|
2014-07-22 12:56:49 +00:00
|
|
|
echo "Done, now run $make_cmd && $make_cmd install"
|