tsocks-1.8beta5/0000755000000000000000000000000011642034445010502 5ustar tsocks-1.8beta5/tsocks.h0000644000000000000000000000367311620231375012167 0ustar /* tsocks.h - Structures used by tsocks to form SOCKS requests */ #ifndef _TSOCKS_H #define _TSOCKS_H 1 #include /* Structure representing a socks connection request */ struct sockreq { int8_t version; int8_t command; int16_t dstport; int32_t dstip; /* A null terminated username goes here */ }; /* Structure representing a socks connection request response */ struct sockrep { int8_t version; int8_t result; int16_t ignore1; int32_t ignore2; }; /* Structure representing a socket which we are currently proxying */ struct connreq { /* Information about the socket and target */ int sockid; struct sockaddr_in connaddr; struct sockaddr_in serveraddr; /* Pointer to the config entry for the socks server */ struct serverent *path; /* Current state of this proxied socket */ int state; /* Next state to go to when the send or receive is finished */ int nextstate; /* When connections fail but an error number cannot be reported * because the socket is non blocking we keep the connreq struct until * the status is queried with connect() again, we then return * this value */ int err; /* Events that were set for this socket upon call to select() or * poll() */ int selectevents; /* Buffer for sending and receiving on the socket */ int datalen; int datadone; char buffer[1024]; struct connreq *next; }; /* Connection statuses */ #define UNSTARTED 0 #define CONNECTING 1 #define CONNECTED 2 #define SENDING 3 #define RECEIVING 4 #define SENTV4REQ 5 #define GOTV4REQ 6 #define SENTV5METHOD 7 #define GOTV5METHOD 8 #define SENTV5AUTH 9 #define GOTV5AUTH 10 #define SENTV5CONNECT 11 #define GOTV5CONNECT 12 #define DONE 13 #define FAILED 14 /* Flags to indicate what events a socket was select()ed for */ #define READ (1<<0) #define WRITE (1<<1) #define EXCEPT (1<<2) #define READWRITE (READ|WRITE) #define READWRITEEXCEPT (READ|WRITE|EXCEPT) #endif tsocks-1.8beta5/tsocks.announce0000644000000000000000000000140511620231375013535 0ustar tsocks 1.8- Provide transparent SOCKS support tsocks provides transparent network access through a SOCKS proxy. This is common in firewalled LAN environments where all connections to the internet need to pass through a SOCKS server on the firewall. tsocks intercepts the calls applications make to create tcp connections and determines if they can be directly accessed or need the SOCKS server. If they need the SOCKS server they connection is negotiated with the server transparently to the application. This allows existing applications to use SOCKS without recompilation or modification. tsocks is a wrapper library for a number of socket networking functions. Essentially it's the equivalent of the socksified winsock.dll libraries that are available for Windows. tsocks-1.8beta5/inspectsocks.c0000644000000000000000000001102611620231375013353 0ustar /* INSPECTSOCKS - Part of the tsocks package This utility can be used to determine the protocol level of a SOCKS server. Copyright (C) 2000 Shaun Clowes This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Global configuration variables */ char *progname = "inspectsocks"; /* Name for error msgs */ int defaultport = 1080; /* Default SOCKS port */ /* Header Files */ #include #include #include #include #include #include #include #include #include #include #include #include int send_request(struct sockaddr_in *server, void *req, int reqlen, void *rep, int replen); int main(int argc, char *argv[]) { char *usage = "Usage: [portno]"; char req[9]; char resp[100]; unsigned short int portno = defaultport; int ver = 0; int read_bytes; struct sockaddr_in server; if ((argc < 2) || (argc > 3)) { show_msg(MSGERR, "Invalid number of arguments\n"); show_msg(MSGERR, "%s\n", usage); exit(1); } switch (argc) { case 3: portno = (unsigned short int) strtol(argv[2], (char **) 0, 10); if ((portno == 0) || (errno == EINVAL)) { show_msg(MSGERR, "%s\n", usage); exit(1); } case 2: if ((server.sin_addr.s_addr = resolve_ip(argv[1], 1,HOSTNAMES)) == -1) { show_msg(MSGERR, "Invalid IP/host specified (%s)\n", argv[1]); show_msg(MSGERR, "%s\n", usage); exit(1); } } server.sin_family = AF_INET; /* host byte order */ server.sin_port = htons(portno); /* short, network byte order */ bzero(&(server.sin_zero), 8);/* zero the rest of the struct */ /* Now, we send a SOCKS V5 request which happens to be */ /* the same size as the smallest possible SOCKS V4 */ /* request. In this packet we specify we have 7 auth */ /* methods but specify them all as NO AUTH. */ bzero(req, sizeof(req)); req[0] = '\x05'; req[1] = '\x07'; read_bytes = send_request(&server, req, sizeof(req), resp, sizeof(resp)); if (read_bytes > 0) { if ((int) resp[0] == 0) { ver = 4; } else if ((int) resp[0] == 5) { ver = 5; } if (ver != 0) { printf("Reply indicates server is a version " "%d socks server\n", ver); } else { show_msg(MSGERR, "Invalid SOCKS version reply (%d), " "probably not a socks server\n", ver); } exit(0); } /* Hmmm.... disconnected so try a V4 request */ printf("Server disconnected V5 request, trying V4\n"); req[0] = '\x04'; req[1] = '\x01'; read_bytes = send_request(&server, req, sizeof(req), resp, sizeof(resp)); if (read_bytes > 0) { if ((int) resp[0] == 0) { ver = 4; } if (ver == 4) { printf("Reply indicates server is a version " "4 socks server\n"); } else { show_msg(MSGERR, "Invalid SOCKS version reply (%d), " "probably not a socks server\n", (int) resp[0]); } exit(0); } else { show_msg(MSGERR, "Server disconnected, probably not a " "socks server\n"); } return(0); } int send_request(struct sockaddr_in *server, void *req, int reqlen, void *rep, int replen) { int sock; int rc; if ((sock = socket(server->sin_family, SOCK_STREAM, 0)) < 0) { show_msg(MSGERR, "Could not create socket (%s)\n", strerror(errno)); exit(1); } if (connect(sock, (struct sockaddr *) server, sizeof(struct sockaddr_in)) != -1) { } else { show_msg(MSGERR, "Connect failed! (%s)\n", strerror(errno)); exit(1); } if (send(sock, (void *) req, reqlen,0) < 0) { show_msg(MSGERR, "Could not send to server (%s)\n", strerror(errno)); exit(1); } /* Now wait for reply */ if ((rc = recv(sock, (void *) rep, replen, 0)) < 0) { show_msg(MSGERR, "Could not read from server\n", strerror(errno)); exit(1); } close(sock); return(rc); } tsocks-1.8beta5/parser.h0000644000000000000000000000302511642034445012147 0ustar /* parser.h - Structures, functions and global variables for the */ /* tsocks parsing routines */ #ifndef _PARSER_H #define _PARSER_H 1 /* Structure definitions */ /* Structure representing one server specified in the config */ struct serverent { int lineno; /* Line number in conf file this path started on */ char *address; /* Address/hostname of server */ int port; /* Port number of server */ int type; /* Type of server (4/5) */ char *defuser; /* Default username for this socks server */ char *defpass; /* Default password for this socks server */ struct netent *reachnets; /* Linked list of nets from this server */ struct serverent *next; /* Pointer to next server entry */ }; /* Structure representing a network */ struct netent { struct in_addr localip; /* Base IP of the network */ struct in_addr localnet; /* Mask for the network */ unsigned long startport; /* Range of ports for the */ unsigned long endport; /* network */ struct netent *next; /* Pointer to next network entry */ }; /* Structure representing a complete parsed file */ struct parsedfile { struct netent *localnets; struct serverent defaultserver; struct serverent *paths; }; /* Functions provided by parser module */ int read_config(char *, struct parsedfile *); int is_local(struct parsedfile *, struct in_addr *); int pick_server(struct parsedfile *, struct serverent **, struct in_addr *, unsigned int port); char *strsplit(char *separator, char **text, const char *search); #endif tsocks-1.8beta5/mkinstalldirs0000755000000000000000000000133211620231375013304 0ustar #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Last modified: 1994-03-25 # Public domain errstatus=0 for file in ${1+"$@"} ; do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d in ${1+"$@"} ; do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$? fi if test ! -d "$pathcomp"; then errstatus=$lasterr fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here tsocks-1.8beta5/common.h0000644000000000000000000000041511642003217012134 0ustar /* Common functions provided in common.c */ void set_log_options(int, char *, int); void show_msg(int level, char *, ...); unsigned int resolve_ip(char *, int, int); #define MSGNONE -1 #define MSGERR 0 #define MSGWARN 1 #define MSGNOTICE 2 #define MSGDEBUG 2 tsocks-1.8beta5/debian/0000755000000000000000000000000012646563533011736 5ustar tsocks-1.8beta5/debian/plus/0000755000000000000000000000000011642003217012700 5ustar tsocks-1.8beta5/debian/plus/tsocks0000644000000000000000000000423511642003217014135 0ustar #!/bin/sh # Wrapper script for use of the tsocks(8) transparent socksification library # # There are three forms of usage for this script: # # /usr/bin/tsocks program [program arguments...] # # This form sets the users LD_PRELOAD environment variable so that tsocks(8) # will be loaded to socksify the application then executes the specified # program (with the provided arguments). The following simple example might # be used to telnet to www.foo.org via a tsocks.conf(5) configured socks server: # # /usr/bin/tsocks telnet www.foo.org # # The second form allows for tsocks(8) to be switched on and off for a # session (that is, it adds and removes tsocks from the LD_PRELOAD environment # variable). This form must be _sourced_ into the user's existing session # (and will only work with bourne shell users): # # . /usr/bin/tsocks on # telnet www.foo.org # . /usr/bin/tsocks off # # Or # # source /usr/bin/tsocks on # telnet www.foo.org # source /usr/bin/tsocks off # # The third form creates a new shell with LD_PRELOAD set and is achieved # simply by running the script with no arguments # # /usr/bin/tsocks # # When finished the user can simply terminate the shell with 'exit' # # This script is originally from the debian tsocks package by # Tamas Szerb #if [ $# = 0 ] ; then # echo "$0: insufficient arguments" # exit #fi case "$1" in -on) if [ -z "$LD_PRELOAD" ] then export LD_PRELOAD="/usr/lib/libtsocks.so" else echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \ export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD" fi ;; -off) export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/usr\/lib\/libtsocks.so \?//'` if [ -z "$LD_PRELOAD" ] then unset LD_PRELOAD fi ;; -show|-sh) echo "LD_PRELOAD=\"$LD_PRELOAD\"" ;; -h|-?) echo "$0: Please see tsocks(1) or read comment at top of $0" ;; *) if [ -z "$LD_PRELOAD" ] then export LD_PRELOAD="/usr/lib/libtsocks.so" else echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \ export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD" fi if [ $# = 0 ] then ${SHELL:-/bin/sh} fi if [ $# -gt 0 ] then exec "$@" fi ;; esac #EOF tsocks-1.8beta5/debian/plus/saveme.80000644000000000000000000000065611642003217014260 0ustar .TH saveme 8 "" "saveme" .SH NAME .BR saveme \- unlink ld.so.preload .RB .SH DESCRIPTION .B saveme is part of the tsocks package This program is designed to be statically linked so that if a user breaks their ld.so.preload file and cannot run any dynamically linked program it can delete the offending ld.so.preload file. .PP .SH AUTHOR This manpage was created by Nico Golde for the debian package of tsocks. tsocks-1.8beta5/debian/plus/tsocks.10000644000000000000000000000303411642003217014270 0ustar .TH TSOCKS 1 "" "TSOCKS" .SH NAME .BR tsocks \- Shell wrapper to simplify the use of the tsocks(8) library to transparently allow an application to use a SOCKS proxy .SH SYNOPSIS .B tsocks .RB [application\ [application's\ arguments]] .br or .B tsocks .RB [\-on|\-off] .br or .B tsocks .SH DESCRIPTION .B tsocks is a wrapper between the tsocks library and the application what you would like to run socksified. .SH OPTIONS .IP \fB[application\ \fB[application's\ arguments]] run the application as specified with the environment (LD_PRELOAD) set such that tsocks(8) will transparently proxy SOCKS connections in that program .IP \fB[\-on|\-off] this option adds or removes tsocks(8) from the LD_PRELOAD environment variable. When tsocks(8) is in this variable all executed applications are automatically socksified. If you want to use this function, you HAVE to source the shell script from yours, like this: "source /usr/bin/tsocks" or ". /usr/bin/tsocks" .br Example: .br ". tsocks \-on" \-\- add the tsocks lib to LD_PRELOAD (don't forget the leading dot!) .br ". tsocks \-off" \-\- remove the tsocks lib from LD_PRELOAD (don't forget the leading dot!) .IP \fB[\-show|\-sh] show the current value of the LD_PRELOAD variable .IP \fB create a new shell with LD_PRELOAD including tsocks(8). .PP .SH SEE ALSO tsocks.conf(5) tsocks(8) .SH AUTHOR This script was created by Tamas SZERB for the debian package of tsocks. It (along with this manual page) have since been adapted into the main tsocks project and modified. tsocks-1.8beta5/debian/dirs0000644000000000000000000000000411642003217012573 0ustar etc tsocks-1.8beta5/debian/compat0000644000000000000000000000000211642003217013113 0ustar 6 tsocks-1.8beta5/debian/changelog0000644000000000000000000001266012646563533013615 0ustar tsocks (1.8beta5-9.3) unstable; urgency=medium * Non-maintainer upload. * Document with Built-Using that tsocks ships the saveme binary, that is statically linked against libc6 (Closes: #769343). * Rebuilding with a recent pbuilder incidentally removes the spurious .git directory and debian/.rules.swp file (Closes: #718750). -- intrigeri Sun, 17 Jan 2016 00:23:55 +0000 tsocks (1.8beta5-9.2) unstable; urgency=low * Added SONAME (Closes: 636384) -- Tamas SZERB Sun, 02 Oct 2011 08:42:33 +0200 tsocks (1.8beta5-9.1) unstable; urgency=medium * Non-maintainer upload. * Fix bashism in debian/rules (Closes: #478633) * Bump Standards-Version to 3.8.0. -- Chris Lamb Sat, 07 Jun 2008 21:50:24 +0100 tsocks (1.8beta5-9) unstable; urgency=low * Applied `fallback' patch to allow to fall back to establish direct connection instead of sockified if the fallback = yes option found in the tsocks.conf to make sure that the user won't open a direct one accidentally. (Closes: #471112) -- Tamas SZERB Sun, 16 Mar 2008 13:04:44 +0100 tsocks (1.8beta5-8) unstable; urgency=low * Applied Viktor Radnai's patch to fall back to real connect if there is no default server specified. Sam patch request from Joachim Breitner (Closes: #373642). -- Tamas SZERB Sat, 15 Mar 2008 12:03:56 +0100 tsocks (1.8beta5-7) unstable; urgency=low * Switch to compat level 6 as it the recommend level now and move this from rules to the compat file. * Switch from Homepage tag to Homepage control field. * Bump standards version to 3.7.3, no changes needed. * Include patch (05_config_in_home.dpatch) by Reinhard Tartler to make sure that tsocks looks for tsocks.conf in the user home directory first (Closes: #465325). * Fix debian-rules-ignores-make-clean-error lintian warning. -- Nico Golde Mon, 03 Mar 2008 13:54:19 +0100 tsocks (1.8beta5-6) unstable; urgency=low * Integrated two patches by Peter Palfrader to fix an infinite loop if recv returns 0 and to intercept getpeername (Closes: #240429, #239025). * Removed everything except etc from dirs since the directories are created by Makefile. -- Nico Golde Mon, 02 Apr 2007 20:08:32 +0200 tsocks (1.8beta5-5) unstable; urgency=low * Corrected Homepage tag. -- Nico Golde Fri, 30 Mar 2007 13:27:10 +0200 tsocks (1.8beta5-4) unstable; urgency=low * Added myself to uploaders (Closes: #387473). * Bumped compat level. * Conformed to Standards version 3.7.2. * Added Homepage tag to control. * Fixed broken copyright file. * Use $(CURDIR) instead of `pwd` in rules. * Added dependency on dpatch. * Included patch by Kapil Hari Paranjape to prevent export of specific symbol (Closes: #278906, #134729) * Fix hyphens in manpage (Closes: #295568). * Added saveme manpage (Closes: #316024). * Removed conffiles, not needed anymore. -- Nico Golde Fri, 30 Mar 2007 10:45:19 +0200 tsocks (1.8beta5-3) unstable; urgency=low * TSOCKS_CONFFILE -> TSOCKS_CONF_FILE manpage bug (closes: #311805) -- Tamas SZERB Tue, 10 Oct 2006 20:48:35 +0200 tsocks (1.8beta5-2) unstable; urgency=low * Not using socks server for name resolution --enable-socksdns removed. (closes: #233051, #175011, #184654, #204948) * debconf not needed, because it will have an user defined config too. (closes: #179646) * manpages cleanup, references, missings fixed (closes: #226801) * config.{guess,sub} up2date from autotools-dev -- Tamas SZERB Thu, 22 Apr 2004 10:34:02 +0200 tsocks (1.8beta5-1) unstable; urgency=low * new upstream version * mostly bugfixes, eg. close() * remote dns resolving (closes: #166773) with --enable-socksdns --enable-hostnames so please get rid of hostnames in the config file and use ip addresses only! (NOTE: doesn't work as expected) * sed, fileutils are required pkgs (from Build-Depends) so removed * Irritating tsocks script -- sh conflict (closes: #174047) * modified tsocks(8) manpage regarding TSOCKS_CONF_FILE environment variable -- Tamas SZERB Mon, 23 Dec 2002 09:24:55 +0100 tsocks (1.8beta4-2) unstable; urgency=low * --disable-hostnames bugfix (closes: #140094) -- Tamas SZERB Wed, 27 Mar 2002 14:31:19 +0100 tsocks (1.8beta4-1) unstable; urgency=low * new upstream release * segfault fix on ia64 (closes: #131334) * Allow TSOCKS_CONF_FILE to specify location of config (closes: #135597) * Now respects the default_user and pass specified for path (closes: #135291) -- Tamas SZERB Mon, 25 Mar 2002 19:28:40 +0100 tsocks (1.7-4) unstable; urgency=low * modified description for the sake of Pista ;) -- Tamas SZERB Wed, 29 Aug 2001 01:24:11 +0200 tsocks (1.7-3) unstable; urgency=low * license missed * upload wnpp fix (closes: #105457) -- Tamas SZERB Mon, 23 Jul 2001 22:35:10 +0200 tsocks (1.7-2) unstable; urgency=low * ts -> tsocks (bin, and man too) because the ts package has a ts binary -- Tamas SZERB Mon, 23 Jul 2001 22:34:49 +0200 tsocks (1.7-1) unstable; urgency=low * Initial release. * first upload - wnpp (closes: #105457) -- Tamas SZERB Sun, 15 Jul 2001 11:03:59 +0200 Local variables: mode: debian-changelog End: tsocks-1.8beta5/debian/rules0000755000000000000000000000606012646562753013023 0ustar #!/usr/bin/make -f # Made with the aid of debmake, by Christoph Lameter, # based on the sample debian/rules file for GNU hello by Ian Jackson. package=tsocks # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 include /usr/share/dpatch/dpatch.make build: patch build-stamp build-stamp: dh_testdir -rm -f config.cache config.status .ChangeLog.swp cp /usr/share/misc/config.guess . cp /usr/share/misc/config.sub . ./configure --prefix=/usr \ --libdir=/usr/lib \ --mandir=/usr/share/man \ --with-conf=/etc/tsocks.conf \ --enable-hostnames \ #--enable-socksdns \ $(MAKE) CFLAGS="-O2 -g -Wall -Wl,-soname,libtsocks.so.1" touch build-stamp clean: unpatch dh_testdir dh_testroot rm -f build-stamp install-stamp config.status config.guess [ ! -f Makefile ] || $(MAKE) distclean -rm -f `find . -name "*~"` -rm -rf debian/$(package) debian/files* core debian/*substvars #-rm -rf debian/plus/tsocks.8* #-rm -rf debian/conffiles dh_clean install: install-stamp install-stamp: build dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install prefix=$(CURDIR)/debian/$(package)/usr \ libdir=$(CURDIR)/debian/$(package)/usr/lib \ mandir=$(CURDIR)/debian/$(package)/usr/share/man install -m 600 tsocks.conf.complex.example $(CURDIR)/debian/$(package)/etc/tsocks.conf install validateconf $(CURDIR)/debian/$(package)/usr/bin install inspectsocks $(CURDIR)/debian/$(package)/usr/bin install saveme $(CURDIR)/debian/$(package)/usr/bin #in the upstream now: #rm -f $(CURDIR)/debian/$(package)/usr/bin/tsocks install -m 755 $(CURDIR)/debian/plus/tsocks $(CURDIR)/debian/$(package)/usr/bin touch install-stamp binary-indep: build install # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. binary-arch: build install # -rm -rf debian/$(package) dh_testroot dh_testdir # dpkg-gencontrol -isp dh_undocumented dh_installdocs #dh_installdebconf #how to solve that with dh_installman? (buggy manpage replacing) #rm -f $(CURDIR)/debian/$(package)/usr/share/man/man8/tsocks.8 ##in the upstream now: ##sed s:/lib/:/usr/lib/:g $(CURDIR)/tsocks.8 > $(CURDIR)/debian/plus/tsocks.8 ###dh_compress $(CURDIR)/debian/plus/tsocks.8 ###dh_compress $(CURDIR)/debian/plus/tsocks.1 #install -o root -g root $(CURDIR)/debian/plus/tsocks.8 $(CURDIR)/debian/$(package)/usr/share/man/man8/ install -o root -g root $(CURDIR)/debian/plus/tsocks.1 $(CURDIR)/debian/$(package)/usr/share/man/man1/ install -o root -g root $(CURDIR)/debian/plus/saveme.8 $(CURDIR)/debian/$(package)/usr/share/man/man8/ dh_installman dh_installchangelogs ChangeLog upstream dh_installchangelogs dh_link dh_strip dh_lintian dh_compress dh_fixperms dh_makeshlibs ./debian/util/write-built-using #create conffiles automagically: #find $(CURDIR)/debian/$(package)/etc -type f|sed s:$(CURDIR)/debian/$(package):: >$(CURDIR)/debian/conffiles dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install tsocks-1.8beta5/debian/tsocks.lintian-overrides0000644000000000000000000000021611642034322016603 0ustar # provide statically linked binary to let save the environment if # the ld.preload is broken: tsocks: statically-linked-binary usr/bin/saveme tsocks-1.8beta5/debian/util/0000755000000000000000000000000012646562753012716 5ustar tsocks-1.8beta5/debian/util/write-built-using0000755000000000000000000000042112646562753016233 0ustar #!/bin/sh EXTRA_PACKAGES="libc6" echo -n "extra:Built-Using=" >> debian/tsocks.substvars for package in $EXTRA_PACKAGES; do dpkg-query -f '${source:Package} (= ${source:Version}), ' -W $package 2>/dev/null done >> debian/tsocks.substvars echo >> debian/tsocks.substvars tsocks-1.8beta5/debian/patches/0000755000000000000000000000000011642031427013350 5ustar tsocks-1.8beta5/debian/patches/03_fixloop.dpatch0000755000000000000000000000152011642031427016520 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 03_fixloop.dpatch by Nico Golde ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad tsocks-1.8beta5~/tsocks.c tsocks-1.8beta5/tsocks.c --- tsocks-1.8beta5~/tsocks.c 2002-07-16 00:50:52.000000000 +0200 +++ tsocks-1.8beta5/tsocks.c 2007-04-02 19:48:26.000000000 +0200 @@ -988,6 +988,10 @@ if (rc > 0) { conn->datadone += rc; rc = 0; + } else if (rc == 0) { + show_msg(MSGDEBUG, "Peer has shutdown but we only read %d of %d bytes.\n", + conn->datadone, conn->datalen); + rc = ENOTCONN; /* ENOTCONN seems like the most fitting error message */ } else { if (errno != EWOULDBLOCK) show_msg(MSGDEBUG, "Read failed, %s\n", strerror(errno)); tsocks-1.8beta5/debian/patches/02_hyphenfix.dpatch0000755000000000000000000001343511642031427017051 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 02_hyphenfix.dpatch by Nico Golde ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad tsocks-1.8beta5~/tsocks.8 tsocks-1.8beta5/tsocks.8 --- tsocks-1.8beta5~/tsocks.8 2007-03-30 11:07:38.000000000 +0200 +++ tsocks-1.8beta5/tsocks.8 2007-03-30 11:15:41.000000000 +0200 @@ -13,11 +13,11 @@ The syntax to force preload of the library for different shells is specified below: -Bash, Ksh and Bourne shell - +Bash, Ksh and Bourne shell \- export LD_PRELOAD=/lib/libtsocks.so -C Shell - +C Shell \- setenv LD_PRELOAD=/lib/libtsocks.so @@ -52,7 +52,7 @@ Most arguments to .BR tsocks are provided in the configuration file (the location of which is defined -at configure time by the --with-conf= argument but defaults to +at configure time by the \-\-with\-conf= argument but defaults to /etc/tsocks.conf). The structure of this file is documented in tsocks.conf(8) Some configuration options can be specified at run time using environment @@ -63,7 +63,7 @@ This environment variable overrides the default location of the tsocks configuration file. This variable is not honored if the program tsocks is embedded in is setuid. In addition this environment variable can -be compiled out of tsocks with the --disable-envconf argument to +be compiled out of tsocks with the \-\-disable\-envconf argument to configure at build time .TP @@ -73,10 +73,10 @@ standard error). If this variable is not present by default the logging level is set to 0 which indicates that only error messages should be output. Setting it to higher values will cause tsocks to generate more messages -describing what it is doing. If set to -1 tsocks will output absolutely no +describing what it is doing. If set to \-1 tsocks will output absolutely no error or debugging messages. This is only needed if tsocks output interferes with a program it is embedded in. Message output can be permanently compiled -out of tsocks by specifying the --disable-debug option to configure at +out of tsocks by specifying the \-\-disable\-debug option to configure at build time .TP @@ -85,7 +85,7 @@ be sent to standard error) to a file. This variable is not honored if the program tsocks is embedded in is setuid. For programs where tsocks output interferes with normal operation this option is generally better than -disabling messages (with TSOCKS_DEBUG = -1) +disabling messages (with TSOCKS_DEBUG = \-1) .TP .I TSOCKS_USERNAME @@ -115,8 +115,8 @@ .BR tsocks will generate error messages and print them to stderr when there are problems with the configuration file or the SOCKS negotiation with the -server if the TSOCKS_DEBUG environment variable is not set to -1 or and ---disable-debug was not specified at compile time. This output may cause +server if the TSOCKS_DEBUG environment variable is not set to \-1 or and +\-\-disable\-debug was not specified at compile time. This output may cause some problems with programs that redirect standard error. .SS CAVEATS @@ -157,12 +157,12 @@ .BR tsocks uses ELF dynamic loader features to intercept dynamic function calls from programs in which it is embedded. As a result, it cannot trace the -actions of statically linked executables, non-ELF executables, or +actions of statically linked executables, non\-ELF executables, or executables that make system calls directly with the system call trap or through the syscall() routine. .SH FILES -/etc/tsocks.conf - default tsocks configuration file +/etc/tsocks.conf \- default tsocks configuration file .SH SEE ALSO tsocks.conf(5) diff -urNad tsocks-1.8beta5~/tsocks.conf.5 tsocks-1.8beta5/tsocks.conf.5 --- tsocks-1.8beta5~/tsocks.conf.5 2002-05-18 04:13:08.000000000 +0200 +++ tsocks-1.8beta5/tsocks.conf.5 2007-03-30 11:16:38.000000000 +0200 @@ -66,7 +66,7 @@ .I server The IP address of the SOCKS server (e.g "server = 10.1.4.253"). Only one server may be specified per path block, or one outside a path -block (to define the default server). Unless --disable-hostnames was +block (to define the default server). Unless \-\-disable\-hostnames was specified to configure at compile time the server can be specified as a hostname (e.g "server = socks.nec.com") @@ -118,13 +118,13 @@ .TP .I reaches This directive is only valid inside a path block. Its parameter is formed -as IP[:startport[-endport]]/Subnet and it specifies a network (and a range +as IP[:startport[\-endport]]/Subnet and it specifies a network (and a range of ports on that network) that can be accessed by the SOCKS server specified in this path block. For example, in a path block "reaches = -150.0.0.0:80-1024/255.0.0.0" indicates to tsocks that the SOCKS server +150.0.0.0:80\-1024/255.0.0.0" indicates to tsocks that the SOCKS server specified in the current path block should be used to access any IPs in the range 150.0.0.0 to 150.255.255.255 when the connection request is for ports -80-1024. +80\-1024. .SH UTILITIES tsocks comes with two utilities that can be useful in creating and verifying @@ -146,12 +146,12 @@ extremely useful in debugging problems. validateconf can read a configuration file from a location other than the -location specified at compile time with the -f command line +location specified at compile time with the \-f command line option. Normally validateconf simply dumps the configuration read to the screen (in a nicely readable format), however it also has a useful 'test' mode. When -passed a hostname/ip on the command line like -t , validateconf +passed a hostname/ip on the command line like \-t , validateconf determines which of the SOCKS servers specified in the configuration file would be used by tsocks to access the specified host. tsocks-1.8beta5/debian/patches/04_getpeername.dpatch0000755000000000000000000002104411642031427017340 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 04_getpeername.dpatch by Nico Golde ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad tsocks-1.8beta5~/acconfig.h tsocks-1.8beta5/acconfig.h --- tsocks-1.8beta5~/acconfig.h 2002-05-18 06:59:38.000000000 +0200 +++ tsocks-1.8beta5/acconfig.h 2007-04-02 20:05:30.000000000 +0200 @@ -43,6 +43,9 @@ /* Prototype and function header for close function */ #undef CLOSE_SIGNATURE +/* Prototype and function header for getpeername function */ +#undef GETPEERNAME_SIGNATURE + /* Work out which function we have for conversion from string IPs to numerical ones */ #undef HAVE_INET_ADDR diff -urNad tsocks-1.8beta5~/config.h.in tsocks-1.8beta5/config.h.in --- tsocks-1.8beta5~/config.h.in 2002-05-18 06:59:42.000000000 +0200 +++ tsocks-1.8beta5/config.h.in 2007-04-02 20:05:30.000000000 +0200 @@ -46,6 +46,9 @@ /* Prototype and function header for close function */ #undef CLOSE_SIGNATURE +/* Prototype and function header for close function */ +#undef GETPEERNAME_SIGNATURE + /* Work out which function we have for conversion from string IPs to numerical ones */ #undef HAVE_INET_ADDR diff -urNad tsocks-1.8beta5~/configure tsocks-1.8beta5/configure --- tsocks-1.8beta5~/configure 2002-07-16 00:51:08.000000000 +0200 +++ tsocks-1.8beta5/configure 2007-04-02 20:05:30.000000000 +0200 @@ -2225,14 +2225,60 @@ EOF + +echo $ac_n "checking for correct getpeername prototype""... $ac_c" 1>&6 +echo "configure:2231: checking for correct getpeername prototype" >&5 +PROTO= +PROTO1='int __fd, const struct sockaddr * __name, int *__namelen' +PROTO2='int __fd, const struct sockaddr_in * __name, socklen_t *__namelen' +PROTO3='int __fd, struct sockaddr * __name, socklen_t *__namelen' +PROTO4='int __fd, const struct sockaddr * __name, socklen_t *__namelen' +for testproto in "${PROTO1}" \ + "${PROTO2}" \ + "${PROTO3}" \ + "${PROTO4}" +do + if test "${PROTO}" = ""; then + cat > conftest.$ac_ext < + int getpeername($testproto); + +int main() { + +; return 0; } +EOF +if { (eval echo configure:2254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + PROTO="$testproto"; +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + fi +done +if test "${PROTO}" = ""; then + { echo "configure: error: "no match found!"" 1>&2; exit 1; } +fi +echo "$ac_t""getpeername(${PROTO})" 1>&6 +cat >> confdefs.h <&6 -echo "configure:2230: checking for correct poll prototype" >&5 +echo "configure:2276: checking for correct poll prototype" >&5 PROTO= for testproto in 'struct pollfd *ufds, unsigned long nfds, int timeout' do if test "${PROTO}" = ""; then cat > conftest.$ac_ext < @@ -2242,7 +2288,7 @@ ; return 0; } EOF -if { (eval echo configure:2246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2292: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* PROTO="$testproto"; else diff -urNad tsocks-1.8beta5~/configure.in tsocks-1.8beta5/configure.in --- tsocks-1.8beta5~/configure.in 2002-07-16 00:51:03.000000000 +0200 +++ tsocks-1.8beta5/configure.in 2007-04-02 20:05:30.000000000 +0200 @@ -309,6 +309,34 @@ AC_MSG_RESULT([close(${PROTO})]) AC_DEFINE_UNQUOTED(CLOSE_SIGNATURE, [${PROTO}]) + +dnl Find the correct getpeername prototype on this machine +AC_MSG_CHECKING(for correct getpeername prototype) +PROTO= +PROTO1='int __fd, const struct sockaddr * __name, int *__namelen' +PROTO2='int __fd, const struct sockaddr_in * __name, socklen_t *__namelen' +PROTO3='int __fd, struct sockaddr * __name, socklen_t *__namelen' +PROTO4='int __fd, const struct sockaddr * __name, socklen_t *__namelen' +for testproto in "${PROTO1}" \ + "${PROTO2}" \ + "${PROTO3}" \ + "${PROTO4}" +do + if test "${PROTO}" = ""; then + AC_TRY_COMPILE([ + #include + int getpeername($testproto); + ],,[PROTO="$testproto";],) + fi +done +if test "${PROTO}" = ""; then + AC_MSG_ERROR("no match found!") +fi +AC_MSG_RESULT([getpeername(${PROTO})]) +AC_DEFINE_UNQUOTED(GETPEERNAME_SIGNATURE, [${PROTO}]) + + + dnl Find the correct poll prototype on this machine AC_MSG_CHECKING(for correct poll prototype) PROTO= diff -urNad tsocks-1.8beta5~/tsocks.c tsocks-1.8beta5/tsocks.c --- tsocks-1.8beta5~/tsocks.c 2002-07-16 00:50:52.000000000 +0200 +++ tsocks-1.8beta5/tsocks.c 2007-04-02 20:05:30.000000000 +0200 @@ -62,6 +62,7 @@ static int (*realselect)(SELECT_SIGNATURE); static int (*realpoll)(POLL_SIGNATURE); static int (*realclose)(CLOSE_SIGNATURE); +static int (*realgetpeername)(GETPEERNAME_SIGNATURE); static struct parsedfile *config; static struct connreq *requests = NULL; static int suid = 0; @@ -73,6 +74,7 @@ int select(SELECT_SIGNATURE); int poll(POLL_SIGNATURE); int close(CLOSE_SIGNATURE); +int getpeername(GETPEERNAME_SIGNATURE); #ifdef USE_SOCKS_DNS int res_init(void); #endif @@ -109,14 +111,15 @@ /* most programs that are run won't use our services, so */ /* we do our general initialization on first call */ - /* Determine the logging level */ - suid = (getuid() != geteuid()); + /* Determine the logging level */ + suid = (getuid() != geteuid()); #ifndef USE_OLD_DLSYM realconnect = dlsym(RTLD_NEXT, "connect"); realselect = dlsym(RTLD_NEXT, "select"); realpoll = dlsym(RTLD_NEXT, "poll"); realclose = dlsym(RTLD_NEXT, "close"); + realgetpeername = dlsym(RTLD_NEXT, "getpeername"); #ifdef USE_SOCKS_DNS realresinit = dlsym(RTLD_NEXT, "res_init"); #endif @@ -125,14 +128,15 @@ realconnect = dlsym(lib, "connect"); realselect = dlsym(lib, "select"); realpoll = dlsym(lib, "poll"); + realgetpeername = dlsym(lib, "getpeername"); #ifdef USE_SOCKS_DNS realresinit = dlsym(lib, "res_init"); #endif - dlclose(lib); + dlclose(lib); lib = dlopen(LIBC, RTLD_LAZY); - realclose = dlsym(lib, "close"); - dlclose(lib); + realclose = dlsym(lib, "close"); + dlclose(lib); #endif } @@ -348,8 +352,10 @@ /* If we're not currently managing any requests we can just * leave here */ - if (!requests) + if (!requests) { + show_msg(MSGDEBUG, "No requests waiting, calling real select\n"); return(realselect(n, readfds, writefds, exceptfds, timeout)); + } get_environment(); @@ -703,6 +709,50 @@ return(rc); } +/* If we are not done setting up the connection yet, return + * -1 and ENOTCONN, otherwise call getpeername + * + * This is necessary since some applications, when using non-blocking connect, + * (like ircII) use getpeername() to find out if they are connected already. + * + * This results in races sometimes, where the client sends data to the socket + * before we are done with the socks connection setup. Another solution would + * be to intercept send(). + * + * This could be extended to actually set the peername to the peer the + * client application has requested, but not for now. + * + * PP, Sat, 27 Mar 2004 11:30:23 +0100 + */ +int getpeername(GETPEERNAME_SIGNATURE) { + struct connreq *conn; + int rc; + + if (realgetpeername == NULL) { + show_msg(MSGERR, "Unresolved symbol: getpeername\n"); + return(-1); + } + + show_msg(MSGDEBUG, "Call to getpeername for fd %d\n", __fd); + + + rc = realgetpeername(__fd, __name, __namelen); + if (rc == -1) + return rc; + + /* Are we handling this connect? */ + if ((conn = find_socks_request(__fd, 1))) { + /* While we are at it, we might was well try to do something useful */ + handle_request(conn); + + if (conn->state != DONE) { + errno = ENOTCONN; + return(-1); + } + } + return rc; +} + static struct connreq *new_socks_request(int sockid, struct sockaddr_in *connaddr, struct sockaddr_in *serveraddr, struct serverent *path) { @@ -852,7 +902,7 @@ sizeof(conn->serveraddr)); show_msg(MSGDEBUG, "Connect returned %d, errno is %d\n", rc, errno); - if (rc) { + if (rc) { if (errno != EINPROGRESS) { show_msg(MSGERR, "Error %d attempting to connect to SOCKS " "server (%s)\n", errno, strerror(errno)); tsocks-1.8beta5/debian/patches/01_symbolexport.dpatch0000755000000000000000000000611111642031427017606 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 01_symbolexport.dpatch by Nico Golde ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad tsocks-1.8beta5~/common.c tsocks-1.8beta5/common.c --- tsocks-1.8beta5~/common.c 2002-07-16 00:35:06.000000000 +0200 +++ tsocks-1.8beta5/common.c 2007-03-30 11:08:29.000000000 +0200 @@ -25,7 +25,8 @@ FILE *logfile = NULL; /* File to which messages should be logged */ int logstamp = 0; /* Timestamp (and pid stamp) messages */ -unsigned int resolve_ip(char *host, int showmsg, int allownames) { +unsigned int __attribute__ ((visibility ("hidden"))) +resolve_ip(char *host, int showmsg, int allownames) { struct hostent *new; unsigned int hostaddr; struct in_addr *ip; @@ -64,7 +65,8 @@ /* be logged instead of to standard error */ /* timestamp - This indicates that messages should be prefixed */ /* with timestamps (and the process id) */ -void set_log_options(int level, char *filename, int timestamp) { +void __attribute__ ((visibility ("hidden"))) +set_log_options(int level, char *filename, int timestamp) { loglevel = level; if (loglevel < MSGERR) @@ -78,7 +80,8 @@ logstamp = timestamp; } -void show_msg(int level, char *fmt, ...) { +void __attribute__ ((visibility ("hidden"))) +show_msg(int level, char *fmt, ...) { va_list ap; int saveerr; extern char *progname; diff -urNad tsocks-1.8beta5~/parser.c tsocks-1.8beta5/parser.c --- tsocks-1.8beta5~/parser.c 2002-03-13 13:34:22.000000000 +0100 +++ tsocks-1.8beta5/parser.c 2007-03-30 11:08:29.000000000 +0200 @@ -33,7 +33,8 @@ static int handle_defpass(struct parsedfile *, int, char *); static int make_netent(char *value, struct netent **ent); -int read_config (char *filename, struct parsedfile *config) { +int __attribute__ ((visibility ("hidden"))) +read_config (char *filename, struct parsedfile *config) { FILE *conf; char line[MAXLINE]; int rc = 0; @@ -577,7 +578,8 @@ return(0); } -int is_local(struct parsedfile *config, struct in_addr *testip) { +int __attribute__ ((visibility ("hidden"))) +is_local(struct parsedfile *config, struct in_addr *testip) { struct netent *ent; for (ent = (config->localnets); ent != NULL; ent = ent -> next) { @@ -591,7 +593,8 @@ } /* Find the appropriate server to reach an ip */ -int pick_server(struct parsedfile *config, struct serverent **ent, +int __attribute__ ((visibility ("hidden"))) +pick_server(struct parsedfile *config, struct serverent **ent, struct in_addr *ip, unsigned int port) { struct netent *net; char ipbuf[64]; @@ -635,7 +638,8 @@ /* the start pointer is set to be NULL. The difference between */ /* standard strsep and this function is that this one will */ /* set *separator to the character separator found if it isn't null */ -char *strsplit(char *separator, char **text, const char *search) { +char __attribute__ ((visibility ("hidden"))) +*strsplit(char *separator, char **text, const char *search) { int len; char *ret; tsocks-1.8beta5/debian/patches/06_fallback.dpatch0000755000000000000000000001035111642031427016604 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 06_fallback.dpatch by Tamas SZERB ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Establish direct connection instead of sockified if ## DP: there is no default server specified and the ## DP: fallback = yes. @DPATCH@ --- tsocks-1.8beta5.orig/parser.h 2002-02-10 08:26:27.000000000 +0100 +++ tsocks-1.8beta5/parser.h 2008-03-16 13:33:49.000000000 +0100 @@ -33,6 +33,7 @@ struct netent *localnets; struct serverent defaultserver; struct serverent *paths; + int fallback; }; /* Functions provided by parser module */ --- tsocks-1.8beta5.orig/parser.c 2008-03-16 13:32:47.000000000 +0100 +++ tsocks-1.8beta5/parser.c 2008-03-16 13:36:37.000000000 +0100 @@ -35,6 +35,7 @@ static int handle_defuser(struct parsedfile *, int, char *); static int handle_defpass(struct parsedfile *, int, char *); static int make_netent(char *value, struct netent **ent); +static int handle_fallback(struct parsedfile *, int, char *); char __attribute__ ((visibility ("hidden"))) *find_config(char *line) { @@ -181,6 +182,8 @@ handle_defpass(config, lineno, words[2]); } else if (!strcmp(words[0], "local")) { handle_local(config, lineno, words[2]); + } else if (!strcmp(words[0], "fallback")) { + handle_fallback(config, lineno, words[2]); } else { show_msg(MSGERR, "Invalid pair type (%s) specified " "on line %d in configuration file, " @@ -512,6 +515,19 @@ return(0); } +static int handle_fallback(struct parsedfile *config, int lineno, char *value) { + char *v = strsplit(NULL, &value, " "); + if (config->fallback !=0) { + show_msg(MSGERR, "Fallback may only be specified " + "once in configuration file.\n", + lineno, currentcontext->lineno); + } else { + if(!strcmp(v, "yes")) config->fallback = 1; + if(!strcmp(v, "no")) config->fallback = 0; + } + return(0); +} + /* Construct a netent given a string like */ /* "198.126.0.1[:portno[-portno]]/255.255.255.0" */ int make_netent(char *value, struct netent **ent) { --- tsocks-1.8beta5.orig/tsocks.c 2008-03-16 13:32:47.000000000 +0100 +++ tsocks-1.8beta5/tsocks.c 2008-03-16 13:40:23.000000000 +0100 @@ -294,11 +294,20 @@ (path->address ? path->address : "(Not Provided)")); if (path->address == NULL) { if (path == &(config->defaultserver)) { - show_msg(MSGERR, "Connection needs to be made " - "via default server but " - "the default server has not " - "been specified. Falling back to direct connection.\n"); - return(realconnect(__fd, __addr, __len)); + if (config->fallback) { + show_msg(MSGERR, "Connection needs to be made " + "via default server but " + "the default server has not " + "been specified. Fallback is 'yes' so " + "Falling back to direct connection.\n"); + return(realconnect(__fd, __addr, __len)); + } else { + show_msg(MSGERR, "Connection needs to be made " + "via default server but " + "the default server has not " + "been specified. Fallback is 'no' so " + "coudln't establish the connection.\n"); + } } else show_msg(MSGERR, "Connection needs to be made " --- tsocks-1.8beta5.orig/tsocks.conf.5 2002-05-18 04:13:08.000000000 +0200 +++ tsocks-1.8beta5/tsocks.conf.5 2008-03-16 22:54:41.000000000 +0100 @@ -126,6 +126,15 @@ range 150.0.0.0 to 150.255.255.255 when the connection request is for ports 80-1024. +.TP +.I fallback +This directive allows to fall back to direct connection if no default +server present in the configuration and fallback = yes. +If fallback = no or not specified and there is no default server, the +tsocks gives an error message and aborts. +This parameter protects the user against accidentally establishing +unwanted unsockified (ie. direct) connection. + .SH UTILITIES tsocks comes with two utilities that can be useful in creating and verifying the tsocks configuration file. tsocks-1.8beta5/debian/patches/05_config_in_home.dpatch0000755000000000000000000000235611642031427020015 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 05_config_in_home.dpatch by Reinhard Tartler ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Additionally search for the configuration file in user home directory @DPATCH@ diff -urNad tsocks-1.8beta5~/parser.c tsocks-1.8beta5/parser.c --- tsocks-1.8beta5~/parser.c 2008-03-03 14:05:14.000000000 +0100 +++ tsocks-1.8beta5/parser.c 2008-03-03 14:05:36.000000000 +0100 @@ -36,6 +36,32 @@ static int handle_defpass(struct parsedfile *, int, char *); static int make_netent(char *value, struct netent **ent); +char __attribute__ ((visibility ("hidden"))) +*find_config(char *line) { + struct passwd* pw; + + errno = 0; + + pw = getpwuid(getuid()); + if (errno) { + perror("getpwuid"); + return NULL; + } + + /* check for config in $HOME */ + snprintf(line, MAXLINE - 1, "%s/.tsocks.conf", pw->pw_dir); + + if (access(line, R_OK)) { + show_msg(MSGDEBUG, "Can't access %s, using " CONF_FILE " instead.\n", line); + strncpy(line, CONF_FILE, MAXLINE - 1); + } + + /* Insure null termination */ + line[MAXLINE - 1] = (char) 0; + + return line; +} + int __attribute__ ((visibility ("hidden"))) read_config (char *filename, struct parsedfile *config) { FILE *conf; tsocks-1.8beta5/debian/patches/00list0000644000000000000000000000012511642003217014400 0ustar 01_symbolexport 02_hyphenfix 03_fixloop 04_getpeername 05_config_in_home 06_fallback tsocks-1.8beta5/debian/README.debian0000644000000000000000000000057511620231375014031 0ustar tsocks for Debian ---------------------- - libtsocks.so - the libtsocks library - validateconf - a utility to verify the tsocks configuration file - inspectsocks - a utility to determine the version of a socks server - saveme - a statically linked utility to remove /etc/ld.so.preload if it becomes corrupt Tamas SZERB , Sun, 15 Jul 2001 11:03:59 +0200 tsocks-1.8beta5/debian/tsocks.manpages0000644000000000000000000000010111642003217014730 0ustar debian/plus/tsocks.1 debian/plus/saveme.8 tsocks.8 tsocks.conf.5 tsocks-1.8beta5/debian/copyright0000644000000000000000000000210311642003217013644 0ustar This package was debianized by Tamas SZERB on Sun, 15 Jul 2001 11:03:59 +0200. It was downloaded from http://tsocks.sourceforge.net/ Upstream Author: Shaun Clowes Copyright: Copyright (C) 2000 Shaun Clowes License: This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. tsocks-1.8beta5/debian/undocumented0000644000000000000000000000003611642003217014331 0ustar inspectsocks.8 validateconf.8 tsocks-1.8beta5/debian/control0000644000000000000000000000132012646562753013340 0ustar Source: tsocks Section: net Priority: optional Maintainer: Tamas SZERB Uploaders: Nico Golde Build-Depends: debhelper (>= 6), autotools-dev, dpatch Standards-Version: 3.8.0 Homepage: http://tsocks.sf.net Package: tsocks Architecture: any Depends: ${shlibs:Depends} Built-Using: ${extra:Built-Using} Description: transparent network access through a SOCKS 4 or 5 proxy tsocks provides transparent network access through a SOCKS version 4 or 5 proxy (usually on a firewall). tsocks intercepts the calls applications make to establish TCP connections and transparently proxies them as necessary. This allows existing applications to use SOCKS without recompilation or modification. tsocks-1.8beta5/config.sub0000755000000000000000000010460611642034351012470 0ustar #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-03-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; # This must be matched before tile*. tilegx*) basic_machine=tilegx-unknown os=-linux-gnu ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: tsocks-1.8beta5/tsocks.conf.50000644000000000000000000001644111642034445013030 0ustar .TH TSOCKS.CONF 5 "" "Shaun Clowes" \" -*- \" nroff -* .SH NAME .BR tsocks.conf \- configuration file for tsocks(8) .SH OVERVIEW The configuration for tsocks can be anything from two lines to hundreds of lines based on the needs at any particular site. The basic idea is to define any networks the machine can access directly (i.e without the use of a SOCKS server) and define one or many SOCKS servers to be used to access other networks (including a 'default' server). Local networks are declared using the 'local' keyword in the configuration file. When applications attempt to connect to machines in networks marked as local tsocks will not attempt to use a SOCKS server to negotiate the connection. Obviously if a connection is not to a locally accessible network it will need to be proxied over a SOCKS server. However, many installations have several different SOCKS servers to be used to access different internal (and external) networks. For this reason the configuration file allows the definition of 'paths' as well as a default SOCKS server. Paths are declared as blocks in the configuration file. That is, they begin with a 'path {' line in the configuration file and end with a '}' line. Inside this block directives should be used to declare a SOCKS server (as documented later in this manual page) and 'reaches' directives should be used to declare networks and even destination ports in those networks that this server should be used to reach. N.B Each path MUST define a SOCKS server and contain one or more 'reaches' directives. SOCKS server declaration directives that are not contained within a 'path' block define the default SOCKS server. If tsocks needs to connect to a machine via a SOCKS server (i.e it isn't a network declared as 'local') and no 'path' has declared it can reach that network via a 'reaches' directive this server is used to negotiate the connection. .SH CONFIGURATION SYNTAX The basic structure of all lines in the configuration file is: .RS = .RE The exception to this is 'path' blocks which look like: .RS path { .RS = .RE } .RE Empty lines are ignored and all input on a line after a '#' character is ignored. .SS DIRECTIVES The following directives are used in the tsocks configuration file: .TP .I server The IP address of the SOCKS server (e.g "server = 10.1.4.253"). Only one server may be specified per path block, or one outside a path block (to define the default server). Unless --disable-hostnames was specified to configure at compile time the server can be specified as a hostname (e.g "server = socks.nec.com") .TP .I server_port The port on which the SOCKS server receives requests. Only one server_port may be specified per path block, or one outside a path (for the default server). This directive is not required if the server is on the standard port (1080). .TP .I server_type SOCKS version used by the server. Versions 4 and 5 are supported (but both for only the connect operation). The default is 4. Only one server_type may be specified per path block, or one outside a path (for the default server). You can use the inspectsocks utility to determine the type of server, see the 'UTILITIES' section later in this manual page. .TP .I default_user This specifies the default username to be used for username and password authentication in SOCKS version 5. In order to determine the username to use (if the socks server requires username and password authentication) tsocks first looks for the environment variable TSOCKS_USERNAME, then looks for this configuration option, then tries to get the local username. This option is not valid for SOCKS version 4 servers. Only one default_user may be specified per path block, or one outside a path (for the default server) .TP .I default_pass This specified the default password to be used for username and password authentication in SOCKS version 5. In order to determine the password to use (if the socks server requires username and password authentication) tsocks first looks for the environment variable TSOCKS_PASSWORD, then looks for this configuration option. This option is not valid for SOCKS version 4 servers. Onle one default_pass may be specified per path block, or one outside a path (for the default server) .TP .I local An IP/Subnet pair specifying a network which may be accessed directly without proxying through a SOCKS server (e.g "local = 10.0.0.0/255.0.0.0"). Obviously all SOCKS server IP addresses must be in networks specified as local, otherwise tsocks would need a SOCKS server to reach SOCKS servers. .TP .I reaches This directive is only valid inside a path block. Its parameter is formed as IP[:startport[-endport]]/Subnet and it specifies a network (and a range of ports on that network) that can be accessed by the SOCKS server specified in this path block. For example, in a path block "reaches = 150.0.0.0:80-1024/255.0.0.0" indicates to tsocks that the SOCKS server specified in the current path block should be used to access any IPs in the range 150.0.0.0 to 150.255.255.255 when the connection request is for ports 80-1024. .TP .I fallback This directive allows to fall back to direct connection if no default server present in the configuration and fallback = yes. If fallback = no or not specified and there is no default server, the tsocks gives an error message and aborts. This parameter protects the user against accidentally establishing unwanted unsockified (ie. direct) connection. .SH UTILITIES tsocks comes with two utilities that can be useful in creating and verifying the tsocks configuration file. .TP inspectsocks inspectsocks can be used to determine the SOCKS version that a server supports. Inspectsocks takes as its arguments the ip address/hostname of the SOCKS server and optionally the port number for socks (e.g 'inspectsocks socks.nec.com 1080'). It then inspects that server to attempt to determine the version that server supports. .TP validateconf validateconf can be used to verify the configuration file. It checks the format of the file and also the contents for errors. Having read the file it dumps the configuration to the screen in a formatted, readable manner. This can be extremely useful in debugging problems. validateconf can read a configuration file from a location other than the location specified at compile time with the -f command line option. Normally validateconf simply dumps the configuration read to the screen (in a nicely readable format), however it also has a useful 'test' mode. When passed a hostname/ip on the command line like -t , validateconf determines which of the SOCKS servers specified in the configuration file would be used by tsocks to access the specified host. .SH SEE ALSO tsocks(8) .SH AUTHOR Shaun Clowes (delius@progsoc.uts.edu.au) .SH COPYRIGHT Copyright 2000 Shaun Clowes tsocks and its documentation may be freely copied under the terms and conditions of version 2 of the GNU General Public License, as published by the Free Software Foundation (Cambridge, Massachusetts, United States of America). This documentation is based on the documentation for logwrites, another shared library interceptor. One line of code from it was used in tsocks and a lot of the documentation :) logwrites is by adam@yggdrasil.com (Adam J. Richter) and can be had from ftp.yggdrasil.com pub/dist/pkg tsocks-1.8beta5/INSTALL0000644000000000000000000001217411642003217011531 0ustar Quick Installation Instructions ------------------------------- 1. Unpack the archive (though if you're reading this you've already achieved that) tar -zxvf tsocks-.tar.gx 2. Run ./configure, options which might be of interest (and that are specific to tsocks include): --enable-socksdns This option causes tsocks to intercept DNS lookups and attempt to force them to use TCP instead of UDP and thus be proxied through the socks server. This is not a very elegant thing to do and should be avoided where possible. --disable-debug This configuration option tells tsocks to never output error messages to stderr. This can also be achieved at run time by defining the environment variable TSOCKS_NO_ERROR to be "yes" --enable-oldmethod This forces tsocks not to use the RTLD_NEXT parameter to dlsym to get the address of the connect() method tsocks overrides, instead it loads a reference to the libc shared library and then uses dlsym(). Again this is not very elegant and shouldn't be required. --disable-hostnames This disables DNS lookups on names provided as socks servers in the config file. This option is necessary if socks dns is enabled since tsocks can't send a socks dns request to resolve the location of the socks server. --with-conf= You can specify the location of the tsocks configuration file using this option, it defaults to '/etc/tsocks.conf' Other standard autoconf options are provided by typing './configure --help' NOTE: The install path for the library is _NOT_ prefixed with --prefix, this is because it is strongly recommended that tsocks is installed into /lib (and not /usr/lib). This is important if tsocks is put into /etc/ld.so.preload since /usr is not mounted on many systems at boot time, meaning that programs running before /usr is mounted will try to preload tsocks, fail to find it and die, making the machine unusable. If you really wish to install the library into some other path use --libdir. 3. Compile the code by typing: make This should result in the creation of the following: - libtsocks.so - the libtsocks library - validateconf - a utility to verify the tsocks configuration file - inspectsocks - a utility to determine the version of a socks server - saveme - a statically linked utility to remove /etc/ld.so.preload if it becomes corrupt 4. If you experience any errors at this step and don't know how to fix them, seek help using the contacts listed on http://tsocks.sourceforge.net/contact.php 5. Install the compiled library. You can skip this step if you only plan to use the library for personal use. If you want all users on the machine to be able to use it however, su to root then type make install This will install the library, the tsocks script and its man pages (tsocks(8), tsocks(1) and tsocks.conf(5)) to the paths specified to configure. Note that by default the library is installed to /lib and that the configure --prefix is IGNORED. See above for more detail. 6. At this point you'll need to create the tsocks configuration file. There are two samples provided in the build directory called tsocks.conf.simple.example and tsocks.conf.complex.example. Documentation on the configuration file format is provided in the tsocks.conf man page ('man tsocks.conf'). 7. Having created the tsocks.conf file you should verify it using validateconf (some detail on validateconf can be found in the tsocks.conf man page). Normally validateconf is run without arguments ('./validateconf'). Any errors which are displayed by validateconf need to be rectified before tsocks will function correctly. 8. You can now choose to make the library affect all users or just those who choose to use it. If you want users to use it themselves, they can simply use the tsocks(1) shell script to run programs (see 'man tsocks') or do the following in their shell before running applications that need to be transparently proxied: (in Bash) export LD_PRELOAD= (in CSH) setenv LD_PRELOAD = e.g /lib/libtsocks.so.1.8 If you want all users to pick up the library, place the full path to the full library in the file /etc/ld.so.preload (e.g "/lib/libtsocks.so"). Be EXTREMELY careful if you do this, if you mistype it or in some way get it wrong this will make your machine UNUSABLE. Also, if you do this, make sure the directory you put the library in is in the root of the filesystem, if the library is not available at boot time, again, your machine will be UNUSABLE. 9. Go ahead and use it! At this point everything should work. Again, if you experience any problems, use the contact points listed at http://tsocks.sourceforge.net/contact.php. If you do happen to break your machine with /etc/ld.so.preload, the build process creates a statically linked executable called saveme in the build directory. This executable simply unlinks /etc/ld.so.preload, this may or may not save you so give it a try. If it fails, you'll need to switch off the machine and get a rescue disk (e.g tomsrtbt) mount the disk and remove the file manually. Thats it, Thanks, Shaun Clowes (delius@progsoc.org) tsocks-1.8beta5/tsocks.conf.complex.example0000644000000000000000000000322011620231375015751 0ustar # This is the configuration for libtsocks (transparent socks) # Lines beginning with # and blank lines are ignored # # The basic idea is to specify: # - Local subnets - Networks that can be accessed directly without # assistance from a socks server # - Paths - Paths are basically lists of networks and a socks server # which can be used to reach these networks # - Default server - A socks server which should be used to access # networks for which no path is available # Much more documentation than provided in these comments can be found in # the man pages, tsocks(8) and tsocks.conf(8) # Local networks # For this example this machine can directly access 192.168.0.0/255.255.255.0 # (192.168.0.*) and 10.0.0.0/255.0.0.0 (10.*) local = 192.168.0.0/255.255.255.0 local = 10.0.0.0/255.0.0.0 # Paths # For this example this machine needs to access 150.0.0.0/255.255.0.0 as # well as port 80 on the network 150.1.0.0/255.255.0.0 through # the socks 5 server at 10.1.7.25 (if this machines hostname was # "socks.hello.com" we could also specify that, unless --disable-hostnames # was specified to ./configure). path { reaches = 150.0.0.0/255.255.0.0 reaches = 150.1.0.0:80/255.255.0.0 server = 10.1.7.25 server_type = 5 default_user = delius default_pass = hello } # Default server # For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0 # the server at 192.168.0.1 should be used (again, hostnames could be used # too, see note above) server = 192.168.0.1 # Server type defaults to 4 so we need to specify it as 5 for this one server_type = 5 # The port defaults to 1080 but I've stated it here for clarity server_port = 1080 tsocks-1.8beta5/saveme.c0000644000000000000000000000205311620231375012123 0ustar /* SAVEME - Part of the tsocks package This program is designed to be statically linked so that if a user breaks their ld.so.preload file and cannot run any dynamically linked program it can delete the offending ld.so.preload file. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include int main() { unlink("/etc/ld.so.preload"); return(0); } tsocks-1.8beta5/tsocks.80000644000000000000000000001657111642034445012113 0ustar .TH TSOCKS 8 "" "Shaun Clowes" \" -*- \" nroff -* .SH NAME .BR tsocks \- Library for intercepting outgoing network connections and redirecting them through a SOCKS server. .SH SYNOPSIS Set LD_PRELOAD to load the library then use applications as normal The syntax to force preload of the library for different shells is specified below: Bash, Ksh and Bourne shell - export LD_PRELOAD=/lib/libtsocks.so C Shell - setenv LD_PRELOAD=/lib/libtsocks.so This process can be automated (for Bash, Bourne and Korn shell users) for a single command or for all commands in a shell session by using the tsocks(1) script You can also setup tsocks in such a way that all processes automatically use it, a very useful configuration. For more information on this configuration see the CAVEATS section of this manual page. .SH DESCRIPTION .BR tsocks is a library to allow transparent SOCKS proxying. It wraps the normal connect() function. When a connection is attempted, it consults the configuration file (which is defined at configure time but defaults to ~/.tsocks.conf and if that file cannot be accessed, to /etc/tsocks.conf) and determines if the IP address specified is local. If it is not, the library redirects the connection to a SOCKS server specified in the configuration file. It then negotiates that connection with the SOCKS server and passes the connection back to the calling program. .BR tsocks is designed for use in machines which are firewalled from then internet. It avoids the need to recompile applications like lynx or telnet so they can use SOCKS to reach the internet. It behaves much like the SOCKSified TCP/IP stacks seen on other platforms. .SS ARGUMENTS Most arguments to .BR tsocks are provided in the configuration file (the location of which is defined at configure time by the --with-conf= argument but defaults to /etc/tsocks.conf). The structure of this file is documented in tsocks.conf(8) Some configuration options can be specified at run time using environment variables as follows: .TP .I TSOCKS_CONF_FILE This environment variable overrides the default location of the tsocks configuration file. This variable is not honored if the program tsocks is embedded in is setuid. In addition this environment variable can be compiled out of tsocks with the --disable-envconf argument to configure at build time .TP .I TSOCKS_DEBUG This environment variable sets the level of debug output that should be generated by tsocks (debug output is generated in the form of output to standard error). If this variable is not present by default the logging level is set to 0 which indicates that only error messages should be output. Setting it to higher values will cause tsocks to generate more messages describing what it is doing. If set to -1 tsocks will output absolutely no error or debugging messages. This is only needed if tsocks output interferes with a program it is embedded in. Message output can be permanently compiled out of tsocks by specifying the --disable-debug option to configure at build time .TP .I TSOCKS_DEBUG_FILE This option can be used to redirect the tsocks output (which would normally be sent to standard error) to a file. This variable is not honored if the program tsocks is embedded in is setuid. For programs where tsocks output interferes with normal operation this option is generally better than disabling messages (with TSOCKS_DEBUG = -1) .TP .I TSOCKS_USERNAME This environment variable can be used to specify the username to be used when version 5 SOCKS servers request username/password authentication. This overrides the default username that can be specified in the configuration file using 'default_user', see tsocks.conf(8) for more information. This variable is ignored for version 4 SOCKS servers. .TP .I TSOCKS_PASSWORD This environment variable can be used to specify the password to be used when version 5 SOCKS servers request username/password authentication. This overrides the default password that can be specified in the configuration file using 'default_pass', see tsocks.conf(8) for more information. This variable is ignored for version 4 SOCKS servers. .SS DNS ISSUES .BR tsocks will normally not be able to send DNS queries through a SOCKS server since SOCKS V4 works on TCP and DNS normally uses UDP. Version 1.5 and up do however provide a method to force DNS lookups to use TCP, which then makes them proxyable. This option can only enabled at compile time, please consult the INSTALL file for more information. .SS ERRORS .BR tsocks will generate error messages and print them to stderr when there are problems with the configuration file or the SOCKS negotiation with the server if the TSOCKS_DEBUG environment variable is not set to -1 or and --disable-debug was not specified at compile time. This output may cause some problems with programs that redirect standard error. .SS CAVEATS .BR tsocks will not in the above configuration be able to provide SOCKS proxying to setuid applications or applications that are not run from a shell. You can force all applications to LD_PRELOAD the library by placing the path to libtsocks in /etc/ld.so.preload. Please make sure you correctly enter the full path to the library in this file if you do this. If you get it wrong, you will be UNABLE TO DO ANYTHING with the machine and will have to boot it with a rescue disk and remove the file (or try the saveme program, see the INSTALL file for more info). THIS IS A ***WARNING***, please be careful. Also be sure the library is in the root filesystem as all hell will break loose if the directory it is in is not available at boot time. .SH BUGS .BR tsocks can only proxy outgoing TCP connections .BR tsocks does NOT work correctly with asynchronous sockets (though it does work with non blocking sockets). This bug would be very difficult to fix and there appears to be no demand for it (I know of no major application that uses asynchronous sockets) .BR tsocks is NOT fully RFC compliant in its implementation of version 5 of SOCKS, it only supports the 'username and password' or 'no authentication' authentication methods. The RFC specifies GSSAPI must be supported by any compliant implementation. I haven't done this, anyone want to help? .BR tsocks can force the libc resolver to use TCP for name queries, if it does this it does it regardless of whether or not the DNS to be queried is local or not. This introduces overhead and should only be used when needed. .BR tsocks uses ELF dynamic loader features to intercept dynamic function calls from programs in which it is embedded. As a result, it cannot trace the actions of statically linked executables, non-ELF executables, or executables that make system calls directly with the system call trap or through the syscall() routine. .SH FILES /etc/tsocks.conf - default tsocks configuration file .SH SEE ALSO tsocks.conf(5) tsocks(1) .SH AUTHOR Shaun Clowes (delius@progsoc.uts.edu.au) .SH COPYRIGHT Copyright 2000 Shaun Clowes tsocks and its documentation may be freely copied under the terms and conditions of version 2 of the GNU General Public License, as published by the Free Software Foundation (Cambridge, Massachusetts, United States of America). This documentation is based on the documentation for logwrites, another shared library interceptor. One line of code from it was used in tsocks and a lot of the documentation :) logwrites is by adam@yggdrasil.com (Adam J. Richter) and can be had from ftp.yggdrasil.com pub/dist/pkg tsocks-1.8beta5/tsocks0000755000000000000000000000422511620231375011736 0ustar #!/bin/sh # Wrapper script for use of the tsocks(8) transparent socksification library # # There are three forms of usage for this script: # # /usr/bin/tsocks program [program arguments...] # # This form sets the users LD_PRELOAD environment variable so that tsocks(8) # will be loaded to socksify the application then executes the specified # program (with the provided arguments). The following simple example might # be used to telnet to www.foo.org via a tsocks.conf(5) configured socks server: # # /usr/bin/tsocks telnet www.foo.org # # The second form allows for tsocks(8) to be switched on and off for a # session (that is, it adds and removes tsocks from the LD_PRELOAD environment # variable). This form must be _sourced_ into the user's existing session # (and will only work with bourne shell users): # # . /usr/bin/tsocks on # telnet www.foo.org # . /usr/bin/tsocks off # # Or # # source /usr/bin/tsocks on # telnet www.foo.org # source /usr/bin/tsocks off # # The third form creates a new shell with LD_PRELOAD set and is achieved # simply by running the script with no arguments # # /usr/bin/tsocks # # When finished the user can simply terminate the shell with 'exit' # # This script is originally from the debian tsocks package by # Tamas Szerb if [ $# = 0 ] ; then echo "$0: insufficient arguments" exit fi case "$1" in on) if [ -z "$LD_PRELOAD" ] then export LD_PRELOAD="/usr/lib/libtsocks.so" else echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \ export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD" fi ;; off) export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/usr\/lib\/libtsocks.so \?//'` if [ -z "$LD_PRELOAD" ] then unset LD_PRELOAD fi ;; show|sh) echo "LD_PRELOAD=\"$LD_PRELOAD\"" ;; -h|-?) echo "$0: Please see tsocks(1) or read comment at top of $0" ;; *) if [ -z "$LD_PRELOAD" ] then export LD_PRELOAD="/usr/lib/libtsocks.so" else echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \ export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD" fi if [ $# = 0 ] then ${SHELL:-/bin/sh} fi if [ $# -gt 0 ] then exec "$@" fi ;; esac #EOF tsocks-1.8beta5/common.c0000644000000000000000000000655511642034445012151 0ustar /* commmon.c - Common routines for the tsocks package */ #include #include #include #include #include #include #include #include #include #include #include #include /* Globals */ int loglevel = MSGERR; /* The default logging level is to only log error messages */ char logfilename[256]; /* Name of file to which log messages should be redirected */ FILE *logfile = NULL; /* File to which messages should be logged */ int logstamp = 0; /* Timestamp (and pid stamp) messages */ unsigned int resolve_ip(char *host, int showmsg, int allownames) { struct hostent *new; unsigned int hostaddr; struct in_addr *ip; if ((hostaddr = inet_addr(host)) == (unsigned int) -1) { /* We couldn't convert it as a numerical ip so */ /* try it as a dns name */ if (allownames) { #ifdef HAVE_GETHOSTBYNAME if ((new = gethostbyname(host)) == (struct hostent *) 0) { #endif return(-1); #ifdef HAVE_GETHOSTBYNAME } else { ip = ((struct in_addr *) * new->h_addr_list); hostaddr = ip -> s_addr; if (showmsg) printf("Connecting to %s...\n", inet_ntoa(*ip)); } #endif } else return(-1); } return (hostaddr); } /* Set logging options, the options are as follows: */ /* level - This sets the logging threshold, messages with */ /* a higher level (i.e lower importance) will not be */ /* output. For example, if the threshold is set to */ /* MSGWARN a call to log a message of level MSGDEBUG */ /* would be ignored. This can be set to -1 to disable */ /* messages entirely */ /* filename - This is a filename to which the messages should */ /* be logged instead of to standard error */ /* timestamp - This indicates that messages should be prefixed */ /* with timestamps (and the process id) */ void set_log_options(int level, char *filename, int timestamp) { loglevel = level; if (loglevel < MSGERR) loglevel = MSGNONE; if (filename) { strncpy(logfilename, filename, sizeof(logfilename)); logfilename[sizeof(logfilename) - 1] = '\0'; } logstamp = timestamp; } void show_msg(int level, char *fmt, ...) { va_list ap; int saveerr; extern char *progname; char timestring[20]; time_t timestamp; if ((loglevel == MSGNONE) || (level > loglevel)) return; if (!logfile) { if (logfilename[0]) { logfile = fopen(logfilename, "a"); if (logfile == NULL) { logfile = stderr; show_msg(MSGERR, "Could not open log file, %s, %s\n", logfilename, strerror(errno)); } } else logfile = stderr; } if (logstamp) { timestamp = time(NULL); strftime(timestring, sizeof(timestring), "%H:%M:%S", localtime(×tamp)); fprintf(logfile, "%s ", timestring); } fputs(progname, logfile); if (logstamp) { fprintf(logfile, "(%d)", getpid()); } fputs(": ", logfile); va_start(ap, fmt); /* Save errno */ saveerr = errno; vfprintf(logfile, fmt, ap); fflush(logfile); errno = saveerr; va_end(ap); } tsocks-1.8beta5/ChangeLog0000644000000000000000000001016111642003217012244 0ustar version 1.80Beta5 - 2002.?.?? delius@progsoc.uts.edu.au Intercept close() to fix problems with tsocks and kmail Add FAQ to distribution version 1.80Beta4 - 2002.3.17 delius@progsoc.uts.edu.au Allow TSOCKS_CONF_FILE to specify location of config If the config is not found, assume all local Now respects the default_user and pass specified for path Added the tsocks shell script and tsocks(1) from the debian package version 1.80Beta3 - 2002.2.20 delius@progsoc.uts.edu.au A large portion of tsocks has been rewritten Relax parser handling of whitespace, i.e it's ignored Fix validateconf path detection to handle local paths Expand logging/debugging support, can now provide detailed debugging info to stderr or file) Improve autoconf script, much more robust Default to ECONNREFUSED when no valid server found Support for non-blocking sockets by intercepting select() and poll() Add support for DESTDIR during make for RPM build, Don't insist on root.root installation Document the --libdir vs --prefix difference better in INSTALL and tsocks.8 version 1.80Beta2 - 2002.1.19 delius@progsoc.uts.edu.au Fix showstopper bug with SOCKS server port numbers version 1.80Beta - 2002.1.12 delius@progsoc.uts.edu.au Allow choice of SOCKS server by port number (based on suggestions from Joakim Recht) Fix bugs with error logging (reported by Paul Pot) version 1.70Beta4 - 2001.7.11 delius@progsoc.uts.edu.au References to verifyconf fixed to point to validateconf version 1.70Beta3 - 2001.3.13 delius@progsoc.uts.edu.au Late resolution of socks servers Addition of validateconf to check configuration Conf file location can now be specified to configure script Much advanced configuration syntax allowing multiple socks servers Default user can now be specified without password (but not password without user) Much improved documentation (with new tsocks.conf(5) page) version 1.70Beta2 - 2001.3.3 delius@progsoc.uts.edu.au Showstopper bug with socks server subnet verification fixed Return code and errno issues corrected Correct use of sockaddr union under Linux version 1.70Beta - 2001.2.27 delius@progsoc.uts.edu.au Automated configuration using the GNU autoconf suite RH7 Compilation issues resolved SOCKS servers can now be specified as hostnames Security problems with lengths of usernames and passwords resolved Installation process in makefile improved Common functions cleaned up and moved to seperate module Configuration read delayed to reduce overhead for UDP etc Silly debug messages removed version 1.60 - 2000.7.11 delius@progsoc.uts.edu.au Fixed segmentation fault when reading configuration file Fixed Makefile.solaris issues Corrected Solaris support, should now work I hope :) Fixed Makefile problem Fixed localhost issues (127.0.0.0/255.0.0.0 is now automatically added as a local network) Removed limitation to number of local nets and reduced memory footprint Added inspectsocks utility Added initial support for SOCKS version 5 Fixed bad connect return codes Update man page, announce and README version 1.50 - 2000.5.23 delius@progsoc.uts.edu.au Fixed bug with setsockopt code thanks to Ronnie Misra Added support to force TCP dns lookups (i.e allow socksified DNS) thanks to Joris van Rantwijk Properly generate errors for unresolved symbols version 1.40 - 2000.5.12 delius@progsoc.uts.edu.au Fix Solaris support, should now compile on 2.6, 7 and 8 Fix Makefile problem version 1.30 - 2000.5.10 delius@progsoc.uts.edu.au Added server_port configuration option Experimental Solaris support version 1.20 - 2000.5.5 delius@progsoc.uts.edu.au Correctly parse configuration file (finally :)) Configuration file renamed to tsocks.conf (conflict with Netscape) Detect non local SOCKS server and show error version 1.10 - 2000.5.3 delius@progsoc.uts.edu.au Correctly parse the SOCKS server's return code for our request Provide an INSTALL guide Improved error handling Provide a program to try to save those people who break their ld.so.preload file version 1.00 - 2000.5.2 delius@progsoc.uts.edu.au First Release tsocks-1.8beta5/configure0000755000000000000000000022736311642034445012426 0ustar #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_default_prefix=/usr ac_help="$ac_help --enable-socksdns force dns lookups to use tcp " ac_help="$ac_help --disable-debug disable ALL error messages from tsocks " ac_help="$ac_help --enable-oldmethod use the old method to override connect " ac_help="$ac_help --disable-hostnames disable hostname lookups for socks servers " ac_help="$ac_help --disable-envconf do not allow TSOCKS_CONF_FILE to specify configuration file " ac_help="$ac_help --with-conf= location of configuration file (/etc/tsocks.conf default)" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=saveme.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi test "$libdir" = "\${exec_prefix}/lib" && libdir="/lib" # Check whether --enable-socksdns or --disable-socksdns was given. if test "${enable_socksdns+set}" = set; then enableval="$enable_socksdns" : fi # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" : fi # Check whether --enable-oldmethod or --disable-oldmethod was given. if test "${enable_oldmethod+set}" = set; then enableval="$enable_oldmethod" : fi # Check whether --enable-hostnames or --disable-hostnames was given. if test "${enable_hostnames+set}" = set; then enableval="$enable_hostnames" : fi # Check whether --enable-envconf or --disable-envconf was given. if test "${enable_envconf+set}" = set; then enableval="$enable_envconf" : fi # Check whether --with-conf or --without-conf was given. if test "${with_conf+set}" = set; then withval="$with_conf" if test "${withval}" = "yes" ; then { echo "configure: error: "--with-conf requires the location of the configuration file as an argument"" 1>&2; exit 1; } else cat >> confdefs.h <> confdefs.h <&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Make sure we can run config.sub. if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 echo "configure:624: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:648: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:678: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:729: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:761: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 772 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:803: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:808: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:836: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:879: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 echo "configure:932: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftestdata if ln -s X conftestdata 2>/dev/null then rm -f conftestdata ac_cv_prog_LN_S="ln -s" else ac_cv_prog_LN_S=ln fi fi LN_S="$ac_cv_prog_LN_S" if test "$ac_cv_prog_LN_S" = "ln -s"; then echo "$ac_t""yes" 1>&6 else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking "if the C compiler accepts -Wall"""... $ac_c" 1>&6 echo "configure:954: checking "if the C compiler accepts -Wall"" >&5 OLDCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CFLAGS="$OLDCFLAGS" echo "$ac_t""no" 1>&6 fi rm -f conftest* echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:979: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1034: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:1059: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1072: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:1139: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 echo "configure:1165: checking for dlfcn.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1175: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: "dlfcn.h not found"" 1>&2; exit 1; } fi ac_safe=`echo "sys/socket.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sys/socket.h""... $ac_c" 1>&6 echo "configure:1200: checking for sys/socket.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1210: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: "sys/socket.h not found"" 1>&2; exit 1; } fi ac_safe=`echo "arpa/inet.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for arpa/inet.h""... $ac_c" 1>&6 echo "configure:1235: checking for arpa/inet.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: "arpa/inet.h not found"" 1>&2; exit 1; } fi ac_safe=`echo "fcntl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for fcntl.h""... $ac_c" 1>&6 echo "configure:1270: checking for fcntl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1280: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: "fcntl.h not found"" 1>&2; exit 1; } fi ac_safe=`echo "sys/poll.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sys/poll.h""... $ac_c" 1>&6 echo "configure:1305: checking for sys/poll.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: "sys/poll.h not found"" 1>&2; exit 1; } fi for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1342: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1352: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_func in strcspn strdup strerror strspn strtol do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1382: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: "Required function not found"" 1>&2; exit 1; } fi done OLDLIBS="${LIBS}" LIBS= CONNECTLIB= for LIB in c socket; do echo $ac_n "checking for connect in -l"${LIB}"""... $ac_c" 1>&6 echo "configure:1441: checking for connect in -l"${LIB}"" >&5 ac_lib_var=`echo "${LIB}"'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-l"${LIB}" $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 CONNECTLIB="${LIB}" break else echo "$ac_t""no" 1>&6 fi done LIBS="${OLDLIBS} -l${CONNECTLIB}" if test "${CONNECTLIB}" = ""; then { echo "configure: error: 'Could not find library containing connect()'" 1>&2; exit 1; } fi echo $ac_n "checking for socket""... $ac_c" 1>&6 echo "configure:1490: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_socket) || defined (__stub___socket) choke me #else socket(); #endif ; return 0; } EOF if { (eval echo configure:1518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_socket=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 echo "configure:1537: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 { echo "configure: error: "socket function not found"" 1>&2; exit 1; } fi fi echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 echo "configure:1588: checking for inet_aton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char inet_aton(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_inet_aton) || defined (__stub___inet_aton) choke me #else inet_aton(); #endif ; return 0; } EOF if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_aton=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_inet_aton=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'inet_aton`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_INET_ATON 1 EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for inet_addr""... $ac_c" 1>&6 echo "configure:1638: checking for inet_addr" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_addr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char inet_addr(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_inet_addr) || defined (__stub___inet_addr) choke me #else inet_addr(); #endif ; return 0; } EOF if { (eval echo configure:1666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_addr=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_inet_addr=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'inet_addr`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_INET_ADDR 1 EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 echo "configure:1688: checking for inet_addr in -lnsl" >&5 ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_INET_ADDR 1 EOF LIBS="${LIBS} -lnsl" else echo "$ac_t""no" 1>&6 { echo "configure: error: "Neither inet_aton or inet_addr present"" 1>&2; exit 1; } fi fi fi echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 echo "configure:1739: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else gethostbyname(); #endif ; return 0; } EOF if { (eval echo configure:1767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_gethostbyname=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_GETHOSTBYNAME 1 EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gethostbyname in -lxnet""... $ac_c" 1>&6 echo "configure:1789: checking for gethostbyname in -lxnet" >&5 ac_lib_var=`echo xnet'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lxnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_GETHOSTBYNAME 1 EOF else echo "$ac_t""no" 1>&6 { echo "configure: error: "gethostbyname not found, name lookups in " \ "tsocks and inspectsocks disabled"" 1>&2; exit 1; } fi fi SIMPLELIBS=${LIBS} LIBS= echo $ac_n "checking for dlsym in -ldl""... $ac_c" 1>&6 echo "configure:1841: checking for dlsym in -ldl" >&5 ac_lib_var=`echo dl'_'dlsym | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 { echo "configure: error: "libdl is required"" 1>&2; exit 1; } fi echo $ac_n "checking "for RTLD_NEXT from dlfcn.h"""... $ac_c" 1>&6 echo "configure:1890: checking "for RTLD_NEXT from dlfcn.h"" >&5 cat > conftest.$ac_ext < #ifdef RTLD_NEXT yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking "for RTLD_NEXT from dlfcn.h with _GNU_SOURCE"""... $ac_c" 1>&6 echo "configure:1912: checking "for RTLD_NEXT from dlfcn.h with _GNU_SOURCE"" >&5 cat > conftest.$ac_ext < #ifdef RTLD_NEXT yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define USE_GNU_SOURCE 1 EOF else rm -rf conftest* echo "$ac_t""no" 1>&6 cat >> confdefs.h <<\EOF #define USE_OLD_DLSYM 1 EOF oldmethod="yes" fi rm -f conftest* fi rm -f conftest* if test "${enable_socksdns}" = "yes"; then cat >> confdefs.h <<\EOF #define USE_SOCKS_DNS 1 EOF fi if test "x${enable_envconf}" = "x"; then cat >> confdefs.h <<\EOF #define ALLOW_ENV_CONFIG 1 EOF fi if test "${enable_oldmethod}" = "yes"; then cat >> confdefs.h <<\EOF #define USE_OLD_DLSYM 1 EOF oldmethod="yes" fi if test "x${enable_debug}" = "x"; then cat >> confdefs.h <<\EOF #define ALLOW_MSG_OUTPUT 1 EOF fi if test "x${enable_hostnames}" = "x"; then cat >> confdefs.h <<\EOF #define HOSTNAMES 1 EOF fi if test "${enable_socksdns}" = "yes" -a \ "x${enable_hostnames}" = "x" ; then { echo "configure: error: "--enable-socksdns is not valid without --disable-hostnames"" 1>&2; exit 1; } fi if test "${oldmethod}" = "yes"; then # Extract the first word of "find", so it can be a program name with args. set dummy find; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1998: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FIND'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$FIND"; then ac_cv_prog_FIND="$FIND" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_FIND="find" break fi done IFS="$ac_save_ifs" fi fi FIND="$ac_cv_prog_FIND" if test -n "$FIND"; then echo "$ac_t""$FIND" 1>&6 else echo "$ac_t""no" 1>&6 fi if test "${FIND}" = ""; then { echo "configure: error: 'find not found in path'" 1>&2; exit 1; } fi # Extract the first word of "tail", so it can be a program name with args. set dummy tail; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:2031: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_TAIL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$TAIL"; then ac_cv_prog_TAIL="$TAIL" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_TAIL="tail" break fi done IFS="$ac_save_ifs" fi fi TAIL="$ac_cv_prog_TAIL" if test -n "$TAIL"; then echo "$ac_t""$TAIL" 1>&6 else echo "$ac_t""no" 1>&6 fi if test "${TAIL}" = ""; then { echo "configure: error: 'tail not found in path'" 1>&2; exit 1; } fi echo $ac_n "checking "location of lib${CONNECTLIB}.so"""... $ac_c" 1>&6 echo "configure:2062: checking "location of lib${CONNECTLIB}.so"" >&5 LIBCONNECT= for DIR in '/lib' '/usr/lib'; do if test "${LIBCONNECT}" = ""; then LIBCONNECT=`$FIND $DIR -name "lib${CONNECTLIB}.so.?" 2>/dev/null | $TAIL -1` fi done cat >> confdefs.h <&2; exit 1; } fi echo "$ac_t""$LIBCONNECT" 1>&6 echo $ac_n "checking "location of libc.so"""... $ac_c" 1>&6 echo "configure:2081: checking "location of libc.so"" >&5 LIBC= for DIR in '/lib' '/usr/lib'; do if test "${LIBC}" = ""; then LIBC=`$FIND $DIR -name "libc.so.?" 2>/dev/null | $TAIL -1` fi done cat >> confdefs.h <&2; exit 1; } fi echo "$ac_t""$LIBC" 1>&6 fi echo $ac_n "checking for correct select prototype""... $ac_c" 1>&6 echo "configure:2101: checking for correct select prototype" >&5 PROTO= for testproto in 'int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout' do if test "${PROTO}" = ""; then cat > conftest.$ac_ext < #include #include int select($testproto); int main() { ; return 0; } EOF if { (eval echo configure:2119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* PROTO="$testproto"; else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi done if test "${PROTO}" = ""; then { echo "configure: error: "no match found!"" 1>&2; exit 1; } fi echo "$ac_t""select(${PROTO})" 1>&6 cat >> confdefs.h <&6 echo "configure:2139: checking for correct connect prototype" >&5 PROTO= PROTO1='int __fd, const struct sockaddr * __addr, int len' PROTO2='int __fd, const struct sockaddr_in * __addr, socklen_t __len' PROTO3='int __fd, struct sockaddr * __addr, int __len' PROTO4='int __fd, const struct sockaddr * __addr, socklen_t __len' for testproto in "${PROTO1}" \ "${PROTO2}" \ "${PROTO3}" \ "${PROTO4}" do if test "${PROTO}" = ""; then cat > conftest.$ac_ext < int connect($testproto); int main() { ; return 0; } EOF if { (eval echo configure:2162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* PROTO="$testproto"; else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi done if test "${PROTO}" = ""; then { echo "configure: error: "no match found!"" 1>&2; exit 1; } fi echo "$ac_t""connect(${PROTO})" 1>&6 cat >> confdefs.h <> confdefs.h <&6 echo "configure:2193: checking for correct close prototype" >&5 PROTO= PROTO1='int fd' for testproto in "${PROTO1}" do if test "${PROTO}" = ""; then cat > conftest.$ac_ext < int close($testproto); int main() { ; return 0; } EOF if { (eval echo configure:2210: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* PROTO="$testproto"; else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi done if test "${PROTO}" = ""; then { echo "configure: error: "no match found!"" 1>&2; exit 1; } fi echo "$ac_t""close(${PROTO})" 1>&6 cat >> confdefs.h <&6 echo "configure:2230: checking for correct poll prototype" >&5 PROTO= for testproto in 'struct pollfd *ufds, unsigned long nfds, int timeout' do if test "${PROTO}" = ""; then cat > conftest.$ac_ext < int poll($testproto); int main() { ; return 0; } EOF if { (eval echo configure:2246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* PROTO="$testproto"; else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi done if test "${PROTO}" = ""; then { echo "configure: error: "no match found!"" 1>&2; exit 1; } fi echo "$ac_t""poll(${PROTO})" 1>&6 cat >> confdefs.h < confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g s%@CC@%$CC%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@LN_S@%$LN_S%g s%@CPP@%$CPP%g s%@FIND@%$FIND%g s%@TAIL@%$TAIL%g s%@SPECIALLIBS@%$SPECIALLIBS%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 tsocks-1.8beta5/configure.in0000644000000000000000000002255511642034445013024 0ustar dnl Process this file with autoconf to produce a configure script. AC_INIT(saveme.c) AC_CONFIG_HEADER(config.h) dnl Our default prefix is /usr/ since most people will be using tsocks dnl on Linux systems and that /usr/local/ stuff annoys them AC_PREFIX_DEFAULT(/usr) dnl if libdir hasn't been set by the user default it to /lib since dnl tsocks needs to be on the root partition if put in the dnl /etc/ld.so.preload file test "$libdir" = "\${exec_prefix}/lib" && libdir="/lib" dnl Arguments we allow AC_ARG_ENABLE(socksdns, [ --enable-socksdns force dns lookups to use tcp ]) AC_ARG_ENABLE(debug, [ --disable-debug disable ALL error messages from tsocks ]) AC_ARG_ENABLE(oldmethod, [ --enable-oldmethod use the old method to override connect ]) AC_ARG_ENABLE(hostnames, [ --disable-hostnames disable hostname lookups for socks servers ]) AC_ARG_ENABLE(envconf, [ --disable-envconf do not allow TSOCKS_CONF_FILE to specify configuration file ]) AC_ARG_WITH(conf, [ --with-conf= location of configuration file (/etc/tsocks.conf default)],[ if test "${withval}" = "yes" ; then AC_MSG_ERROR("--with-conf requires the location of the configuration file as an argument") else AC_DEFINE_UNQUOTED(CONF_FILE, "${withval}") fi ], [ AC_DEFINE_UNQUOTED(CONF_FILE, "/etc/tsocks.conf") ]) dnl ----------------------------------- dnl Get hostname and other information. dnl ----------------------------------- AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S dnl Check if the C compiler accepts -Wall AC_MSG_CHECKING("if the C compiler accepts -Wall") OLDCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall" AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[ CFLAGS="$OLDCFLAGS" AC_MSG_RESULT(no)]) dnl Checks for standard header files. AC_HEADER_STDC dnl Check for the dynamic loader function header AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR("dlfcn.h not found")) dnl Check for the socket header AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR("sys/socket.h not found")) dnl Check for the arpa/inet.h header (inet_ntoa and inet_addr) AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR("arpa/inet.h not found")) dnl Check for the fcntl header AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR("fcntl.h not found")) dnl Check for the poll header AC_CHECK_HEADER(sys/poll.h,,AC_MSG_ERROR("sys/poll.h not found")) dnl Other headers we're interested in AC_CHECK_HEADERS(unistd.h) dnl Checks for library functions. AC_CHECK_FUNCS(strcspn strdup strerror strspn strtol,,[ AC_MSG_ERROR("Required function not found")]) dnl First find the library that contains connect() (obviously dnl the most important library for us). Once we've found it dnl we chuck it on the end of LIBS, that lib may end up there dnl more than once (since we do our search with an empty libs dnl list) but that isn't a problem OLDLIBS="${LIBS}" LIBS= CONNECTLIB= for LIB in c socket; do AC_CHECK_LIB("${LIB}",connect,[ CONNECTLIB="${LIB}" break ],) done LIBS="${OLDLIBS} -l${CONNECTLIB}" if test "${CONNECTLIB}" = ""; then AC_MSG_ERROR('Could not find library containing connect()') fi dnl Check for socket AC_CHECK_FUNC(socket,, [ AC_CHECK_LIB(socket, socket,,AC_MSG_ERROR("socket function not found"))]) dnl Check for a function to convert an ascii ip address dnl to a sin_addr. AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON), [ AC_CHECK_FUNC(inet_addr, AC_DEFINE(HAVE_INET_ADDR), [ AC_CHECK_LIB(nsl, inet_addr, [ AC_DEFINE(HAVE_INET_ADDR) LIBS="${LIBS} -lnsl" ], [ AC_MSG_ERROR("Neither inet_aton or inet_addr present")])])]) dnl Look for gethostbyname (needed by tsocks and inspectsocks) AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME), [ AC_CHECK_LIB(xnet, gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME), [ AC_MSG_ERROR(["gethostbyname not found, name lookups in " \ "tsocks and inspectsocks disabled"])])]) dnl The simple programs (saveme and inspectsocks) have no further dnl requirements, so save the libs needed here and use them in the dnl Makefile SIMPLELIBS=${LIBS} LIBS= dnl Checks for libraries. dnl Replace `main' with a function in -ldl: AC_CHECK_LIB(dl, dlsym,,AC_MSG_ERROR("libdl is required")) dnl If we're using gcc here define _GNU_SOURCE AC_MSG_CHECKING("for RTLD_NEXT from dlfcn.h") AC_EGREP_CPP(yes, [ #include #ifdef RTLD_NEXT yes #endif ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_CHECKING("for RTLD_NEXT from dlfcn.h with _GNU_SOURCE") AC_EGREP_CPP(yes, [ #define _GNU_SOURCE #include #ifdef RTLD_NEXT yes #endif ], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_GNU_SOURCE) ], [ AC_MSG_RESULT(no) AC_DEFINE(USE_OLD_DLSYM) oldmethod="yes" ]) ]) if test "${enable_socksdns}" = "yes"; then AC_DEFINE(USE_SOCKS_DNS) fi if test "x${enable_envconf}" = "x"; then AC_DEFINE(ALLOW_ENV_CONFIG) fi if test "${enable_oldmethod}" = "yes"; then AC_DEFINE(USE_OLD_DLSYM) oldmethod="yes" fi if test "x${enable_debug}" = "x"; then AC_DEFINE(ALLOW_MSG_OUTPUT) fi if test "x${enable_hostnames}" = "x"; then AC_DEFINE(HOSTNAMES) fi if test "${enable_socksdns}" = "yes" -a \ "x${enable_hostnames}" = "x" ; then AC_MSG_ERROR("--enable-socksdns is not valid without --disable-hostnames") fi dnl If we have to use the old method of overriding connect (i.e no dnl RTLD_NEXT) we need to know the location of the library that dnl contains connect(), select(), poll() and close() if test "${oldmethod}" = "yes"; then dnl We need to find the path to the library, to do dnl this we use find on the usual suspects, i.e /lib and dnl /usr/lib dnl Check that find is available, it should be somehere dnl in the path AC_CHECK_PROG(FIND, find, find) if test "${FIND}" = ""; then AC_MSG_ERROR('find not found in path') fi dnl Find tail, it should always be somewhere in the path dnl but for safety's sake AC_CHECK_PROG(TAIL, tail, tail) if test "${TAIL}" = ""; then AC_MSG_ERROR('tail not found in path') fi dnl Now find the library we need AC_MSG_CHECKING("location of lib${CONNECTLIB}.so") LIBCONNECT= for DIR in '/lib' '/usr/lib'; do if test "${LIBCONNECT}" = ""; then LIBCONNECT=`$FIND $DIR -name "lib${CONNECTLIB}.so.?" 2>/dev/null | $TAIL -1` fi done AC_DEFINE_UNQUOTED(LIBCONNECT, "${LIBCONNECT}") if test "${LIBCONNECT}" = ""; then AC_MSG_ERROR("not found!") fi AC_MSG_RESULT($LIBCONNECT) dnl close() should be in libc, find it AC_MSG_CHECKING("location of libc.so") LIBC= for DIR in '/lib' '/usr/lib'; do if test "${LIBC}" = ""; then LIBC=`$FIND $DIR -name "libc.so.?" 2>/dev/null | $TAIL -1` fi done AC_DEFINE_UNQUOTED(LIBC, "${LIBC}") if test "${LIBC}" = ""; then AC_MSG_ERROR("not found!") fi AC_MSG_RESULT($LIBC) fi dnl Find the correct select prototype on this machine AC_MSG_CHECKING(for correct select prototype) PROTO= for testproto in 'int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout' do if test "${PROTO}" = ""; then AC_TRY_COMPILE([ #include #include #include int select($testproto); ],,[PROTO="$testproto";],) fi done if test "${PROTO}" = ""; then AC_MSG_ERROR("no match found!") fi AC_MSG_RESULT([select(${PROTO})]) AC_DEFINE_UNQUOTED(SELECT_SIGNATURE, [${PROTO}]) dnl Find the correct connect prototype on this machine AC_MSG_CHECKING(for correct connect prototype) PROTO= PROTO1='int __fd, const struct sockaddr * __addr, int len' PROTO2='int __fd, const struct sockaddr_in * __addr, socklen_t __len' PROTO3='int __fd, struct sockaddr * __addr, int __len' PROTO4='int __fd, const struct sockaddr * __addr, socklen_t __len' for testproto in "${PROTO1}" \ "${PROTO2}" \ "${PROTO3}" \ "${PROTO4}" do if test "${PROTO}" = ""; then AC_TRY_COMPILE([ #include int connect($testproto); ],,[PROTO="$testproto";],) fi done if test "${PROTO}" = ""; then AC_MSG_ERROR("no match found!") fi AC_MSG_RESULT([connect(${PROTO})]) AC_DEFINE_UNQUOTED(CONNECT_SIGNATURE, [${PROTO}]) dnl Pick which of the sockaddr type arguments we need for dnl connect(), we need to cast one of ours to it later SOCKETARG="struct sockaddr *" case "${PROTO}" in *sockaddr_in*) SOCKETARG="struct sockaddr_in *" ;; esac AC_DEFINE_UNQUOTED(CONNECT_SOCKARG, [${SOCKETARG}]) dnl Find the correct close prototype on this machine AC_MSG_CHECKING(for correct close prototype) PROTO= PROTO1='int fd' for testproto in "${PROTO1}" do if test "${PROTO}" = ""; then AC_TRY_COMPILE([ #include int close($testproto); ],,[PROTO="$testproto";],) fi done if test "${PROTO}" = ""; then AC_MSG_ERROR("no match found!") fi AC_MSG_RESULT([close(${PROTO})]) AC_DEFINE_UNQUOTED(CLOSE_SIGNATURE, [${PROTO}]) dnl Find the correct poll prototype on this machine AC_MSG_CHECKING(for correct poll prototype) PROTO= for testproto in 'struct pollfd *ufds, unsigned long nfds, int timeout' do if test "${PROTO}" = ""; then AC_TRY_COMPILE([ #include int poll($testproto); ],,[PROTO="$testproto";],) fi done if test "${PROTO}" = ""; then AC_MSG_ERROR("no match found!") fi AC_MSG_RESULT([poll(${PROTO})]) AC_DEFINE_UNQUOTED(POLL_SIGNATURE, [${PROTO}]) dnl Output the special librarys (libdl etc needed for tsocks) SPECIALLIBS=${LIBS} AC_SUBST(SPECIALLIBS) LIBS=${SIMPLELIBS} AC_OUTPUT(Makefile) tsocks-1.8beta5/COPYING0000644000000000000000000004307011620231375011536 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. tsocks-1.8beta5/tsocks.manpages0000644000000000000000000000004011642003217013510 0ustar tsocks.1 tsocks.8 tsocks.conf.5 tsocks-1.8beta5/parser.c0000644000000000000000000004727511642034445012161 0ustar /* parser.c - Parsing routines for tsocks.conf */ #include #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "parser.h" /* Global configuration variables */ #define MAXLINE BUFSIZ /* Max length of conf line */ static struct serverent *currentcontext = NULL; static int handle_line(struct parsedfile *, char *, int); static int check_server(struct serverent *); static int tokenize(char *, int, char *[]); static int handle_path(struct parsedfile *, int, int, char *[]); static int handle_endpath(struct parsedfile *, int, int, char *[]); static int handle_reaches(struct parsedfile *, int, char *); static int handle_server(struct parsedfile *, int, char *); static int handle_type(struct parsedfile *config, int, char *); static int handle_port(struct parsedfile *config, int, char *); static int handle_local(struct parsedfile *, int, char *); static int handle_defuser(struct parsedfile *, int, char *); static int handle_defpass(struct parsedfile *, int, char *); static int make_netent(char *value, struct netent **ent); int read_config (char *filename, struct parsedfile *config) { FILE *conf; char line[MAXLINE]; int rc = 0; int lineno = 1; struct serverent *server; /* Clear out the structure */ memset(config, 0x0, sizeof(*config)); /* Initialization */ currentcontext = &(config->defaultserver); /* If a filename wasn't provided, use the default */ if (filename == NULL) { filename = find_config(line); } show_msg(MSGDEBUG, "using %s as configuration file\n", line); /* Read the configuration file */ if ((conf = fopen(filename, "r")) == NULL) { show_msg(MSGERR, "Could not open socks configuration file " "(%s), assuming all networks local\n", filename); handle_local(config, 0, "0.0.0.0/0.0.0.0"); rc = 1; /* Severe errors reading configuration */ } else { memset(&(config->defaultserver), 0x0, sizeof(config->defaultserver)); while (NULL != fgets(line, MAXLINE, conf)) { /* This line _SHOULD_ end in \n so we */ /* just chop off the \n and hand it on */ if (strlen(line) > 0) line[strlen(line) - 1] = '\0'; handle_line(config, line, lineno); lineno++; } fclose(conf); /* Always add the 127.0.0.1/255.0.0.0 subnet to local */ handle_local(config, 0, "127.0.0.0/255.0.0.0"); /* Check default server */ check_server(&(config->defaultserver)); server = (config->paths); while (server != NULL) { check_server(server); server = server->next; } } return(rc); } /* Check server entries (and establish defaults) */ static int check_server(struct serverent *server) { /* Default to the default SOCKS port */ if (server->port == 0) { server->port = 1080; } /* Default to SOCKS V4 */ if (server->type == 0) { server->type = 4; } return(0); } static int handle_line(struct parsedfile *config, char *line, int lineno) { char *words[10]; static char savedline[MAXLINE]; int nowords = 0, i; /* Save the input string */ strncpy(savedline, line, MAXLINE - 1); savedline[MAXLINE - 1] = (char) 0; /* Tokenize the input string */ nowords = tokenize(line, 10, words); /* Set the spare slots to an empty string to simplify */ /* processing */ for (i = nowords; i < 10; i++) words[i] = ""; if (nowords > 0) { /* Now this can either be a "path" block starter or */ /* ender, otherwise it has to be a pair ( = */ /* ) */ if (!strcmp(words[0], "path")) { handle_path(config, lineno, nowords, words); } else if (!strcmp(words[0], "}")) { handle_endpath(config, lineno, nowords, words); } else { /* Has to be a pair */ if ((nowords != 3) || (strcmp(words[1], "="))) { show_msg(MSGERR, "Malformed configuration pair " "on line %d in configuration " "file, \"%s\"\n", lineno, savedline); } else if (!strcmp(words[0], "reaches")) { handle_reaches(config, lineno, words[2]); } else if (!strcmp(words[0], "server")) { handle_server(config, lineno, words[2]); } else if (!strcmp(words[0], "server_port")) { handle_port(config, lineno, words[2]); } else if (!strcmp(words[0], "server_type")) { handle_type(config, lineno, words[2]); } else if (!strcmp(words[0], "default_user")) { handle_defuser(config, lineno, words[2]); } else if (!strcmp(words[0], "default_pass")) { handle_defpass(config, lineno, words[2]); } else if (!strcmp(words[0], "local")) { handle_local(config, lineno, words[2]); } else { show_msg(MSGERR, "Invalid pair type (%s) specified " "on line %d in configuration file, " "\"%s\"\n", words[0], lineno, savedline); } } } return(0); } /* This routines breaks up input lines into tokens */ /* and places these tokens into the array specified */ /* by tokens */ static int tokenize(char *line, int arrsize, char *tokens[]) { int tokenno = -1; int finished = 0; /* Whitespace is ignored before and after tokens */ while ((tokenno < (arrsize - 1)) && (line = line + strspn(line, " \t")) && (*line != (char) 0) && (!finished)) { tokenno++; tokens[tokenno] = line; line = line + strcspn(line, " \t"); *line = (char) 0; line++; /* We ignore everything after a # */ if (*tokens[tokenno] == '#') { finished = 1; tokenno--; } } return(tokenno + 1); } static int handle_path(struct parsedfile *config, int lineno, int nowords, char *words[]) { struct serverent *newserver; if ((nowords != 2) || (strcmp(words[1], "{"))) { show_msg(MSGERR, "Badly formed path open statement on line %d " "in configuration file (should look like " "\"path {\")\n", lineno); } else if (currentcontext != &(config->defaultserver)) { /* You cannot nest path statements so check that */ /* the current context is defaultserver */ show_msg(MSGERR, "Path statements cannot be nested on line %d " "in configuration file\n", lineno); } else { /* Open up a new serverent, put it on the list */ /* then set the current context */ if (((int) (newserver = (struct serverent *) malloc(sizeof(struct serverent)))) == -1) exit(-1); /* Initialize the structure */ show_msg(MSGDEBUG, "New server structure from line %d in configuration file going " "to 0x%08x\n", lineno, newserver); memset(newserver, 0x0, sizeof(*newserver)); newserver->next = config->paths; newserver->lineno = lineno; config->paths = newserver; currentcontext = newserver; } return(0); } static int handle_endpath(struct parsedfile *config, int lineno, int nowords, char *words[]) { if (nowords != 1) { show_msg(MSGERR, "Badly formed path close statement on line " "%d in configuration file (should look like " "\"}\")\n", lineno); } else { currentcontext = &(config->defaultserver); } /* We could perform some checking on the validty of data in */ /* the completed path here, but thats what verifyconf is */ /* designed to do, no point in weighing down libtsocks */ return(0); } static int handle_reaches(struct parsedfile *config, int lineno, char *value) { int rc; struct netent *ent; rc = make_netent(value, &ent); switch(rc) { case 1: show_msg(MSGERR, "Local network specification (%s) is not validly " "constructed in reach statement on line " "%d in configuration " "file\n", value, lineno); return(0); break; case 2: show_msg(MSGERR, "IP in reach statement " "network specification (%s) is not valid on line " "%d in configuration file\n", value, lineno); return(0); break; case 3: show_msg(MSGERR, "SUBNET in reach statement " "network specification (%s) is not valid on " "line %d in configuration file\n", value, lineno); return(0); break; case 4: show_msg(MSGERR, "IP (%s) & ", inet_ntoa(ent->localip)); show_msg(MSGERR, "SUBNET (%s) != IP on line %d in " "configuration file, ignored\n", inet_ntoa(ent->localnet), lineno); return(0); break; case 5: show_msg(MSGERR, "Start port in reach statement " "network specification (%s) is not valid on line " "%d in configuration file\n", value, lineno); return(0); break; case 6: show_msg(MSGERR, "End port in reach statement " "network specification (%s) is not valid on line " "%d in configuration file\n", value, lineno); return(0); break; case 7: show_msg(MSGERR, "End port in reach statement " "network specification (%s) is less than the start " "port on line %d in configuration file\n", value, lineno); return(0); break; } /* The entry is valid so add it to linked list */ ent -> next = currentcontext -> reachnets; currentcontext -> reachnets = ent; return(0); } static int handle_server(struct parsedfile *config, int lineno, char *value) { char *ip; ip = strsplit(NULL, &value, " "); /* We don't verify this ip/hostname at this stage, */ /* its resolved immediately before use in tsocks.c */ if (currentcontext->address == NULL) currentcontext->address = strdup(ip); else { if (currentcontext == &(config->defaultserver)) show_msg(MSGERR, "Only one default SOCKS server " "may be specified at line %d in " "configuration file\n", lineno); else show_msg(MSGERR, "Only one SOCKS server may be specified " "per path on line %d in configuration " "file. (Path begins on line %d)\n", lineno, currentcontext->lineno); } return(0); } static int handle_port(struct parsedfile *config, int lineno, char *value) { if (currentcontext->port != 0) { if (currentcontext == &(config->defaultserver)) show_msg(MSGERR, "Server port may only be specified " "once for default server, at line %d " "in configuration file\n", lineno); else show_msg(MSGERR, "Server port may only be specified " "once per path on line %d in configuration " "file. (Path begins on line %d)\n", lineno, currentcontext->lineno); } else { errno = 0; currentcontext->port = (unsigned short int) (strtol(value, (char **)NULL, 10)); if ((errno != 0) || (currentcontext->port == 0)) { show_msg(MSGERR, "Invalid server port number " "specified in configuration file " "(%s) on line %d\n", value, lineno); currentcontext->port = 0; } } return(0); } static int handle_defuser(struct parsedfile *config, int lineno, char *value) { if (currentcontext->defuser != NULL) { if (currentcontext == &(config->defaultserver)) show_msg(MSGERR, "Default username may only be specified " "once for default server, at line %d " "in configuration file\n", lineno); else show_msg(MSGERR, "Default username may only be specified " "once per path on line %d in configuration " "file. (Path begins on line %d)\n", lineno, currentcontext->lineno); } else { currentcontext->defuser = strdup(value); } return(0); } static int handle_defpass(struct parsedfile *config, int lineno, char *value) { if (currentcontext->defpass != NULL) { if (currentcontext == &(config->defaultserver)) show_msg(MSGERR, "Default password may only be specified " "once for default server, at line %d " "in configuration file\n", lineno); else show_msg(MSGERR, "Default password may only be specified " "once per path on line %d in configuration " "file. (Path begins on line %d)\n", lineno, currentcontext->lineno); } else { currentcontext->defpass = strdup(value); } return(0); } static int handle_type(struct parsedfile *config, int lineno, char *value) { if (currentcontext->type != 0) { if (currentcontext == &(config->defaultserver)) show_msg(MSGERR, "Server type may only be specified " "once for default server, at line %d " "in configuration file\n", lineno); else show_msg(MSGERR, "Server type may only be specified " "once per path on line %d in configuration " "file. (Path begins on line %d)\n", lineno, currentcontext->lineno); } else { errno = 0; currentcontext->type = (int) strtol(value, (char **)NULL, 10); if ((errno != 0) || (currentcontext->type == 0) || ((currentcontext->type != 4) && (currentcontext->type != 5))) { show_msg(MSGERR, "Invalid server type (%s) " "specified in configuration file " "on line %d, only 4 or 5 may be " "specified\n", value, lineno); currentcontext->type = 0; } } return(0); } static int handle_local(struct parsedfile *config, int lineno, char *value) { int rc; struct netent *ent; if (currentcontext != &(config->defaultserver)) { show_msg(MSGERR, "Local networks cannot be specified in path " "block at like %d in configuration file. " "(Path block started at line %d)\n", lineno, currentcontext->lineno); return(0); } rc = make_netent(value, &ent); switch(rc) { case 1: show_msg(MSGERR, "Local network specification (%s) is not validly " "constructed on line %d in configuration " "file\n", value, lineno); return(0); break; case 2: show_msg(MSGERR, "IP for local " "network specification (%s) is not valid on line " "%d in configuration file\n", value, lineno); return(0); break; case 3: show_msg(MSGERR, "SUBNET for " "local network specification (%s) is not valid on " "line %d in configuration file\n", value, lineno); return(0); break; case 4: show_msg(MSGERR, "IP (%s) & ", inet_ntoa(ent->localip)); show_msg(MSGERR, "SUBNET (%s) != IP on line %d in " "configuration file, ignored\n", inet_ntoa(ent->localnet), lineno); return(0); case 5: case 6: case 7: show_msg(MSGERR, "Port specification is invalid and " "not allowed in local network specification " "(%s) on line %d in configuration file\n", value, lineno); return(0); break; } if (ent->startport || ent->endport) { show_msg(MSGERR, "Port specification is " "not allowed in local network specification " "(%s) on line %d in configuration file\n", value, lineno); return(0); } /* The entry is valid so add it to linked list */ ent -> next = config->localnets; (config->localnets) = ent; return(0); } /* Construct a netent given a string like */ /* "198.126.0.1[:portno[-portno]]/255.255.255.0" */ int make_netent(char *value, struct netent **ent) { char *ip; char *subnet; char *startport = NULL; char *endport = NULL; char *badchar; char separator; static char buf[200]; char *split; /* Get a copy of the string so we can modify it */ strncpy(buf, value, sizeof(buf) - 1); buf[sizeof(buf) - 1] = (char) 0; split = buf; /* Now rip it up */ ip = strsplit(&separator, &split, "/:"); if (separator == ':') { /* We have a start port */ startport = strsplit(&separator, &split, "-/"); if (separator == '-') /* We have an end port */ endport = strsplit(&separator, &split, "/"); } subnet = strsplit(NULL, &split, " \n"); if ((ip == NULL) || (subnet == NULL)) { /* Network specification not validly constructed */ return(1); } /* Allocate the new entry */ if ((*ent = (struct netent *) malloc(sizeof(struct netent))) == NULL) { /* If we couldn't malloc some storage, leave */ exit(1); } show_msg(MSGDEBUG, "New network entry for %s going to 0x%08x\n", ip, *ent); if (!startport) (*ent)->startport = 0; if (!endport) (*ent)->endport = 0; #ifdef HAVE_INET_ADDR if (((*ent)->localip.s_addr = inet_addr(ip)) == -1) { #elif defined(HAVE_INET_ATON) if (!(inet_aton(ip, &((*ent)->localip)))) { #endif /* Badly constructed IP */ free(*ent); return(2); } #ifdef HAVE_INET_ADDR else if (((*ent)->localnet.s_addr = inet_addr(subnet)) == -1) { #elif defined(HAVE_INET_ATON) else if (!(inet_aton(subnet, &((*ent)->localnet)))) { #endif /* Badly constructed subnet */ free(*ent); return(3); } else if (((*ent)->localip.s_addr & (*ent)->localnet.s_addr) != (*ent)->localip.s_addr) { /* Subnet and Ip != Ip */ free(*ent); return(4); } else if (startport && (!((*ent)->startport = strtol(startport, &badchar, 10)) || (*badchar != 0) || ((*ent)->startport > 65535))) { /* Bad start port */ free(*ent); return(5); } else if (endport && (!((*ent)->endport = strtol(endport, &badchar, 10)) || (*badchar != 0) || ((*ent)->endport > 65535))) { /* Bad end port */ free(*ent); return(6); } else if (((*ent)->startport > (*ent)->endport) && !(startport && !endport)) { /* End port is less than start port */ free(*ent); return(7); } if (startport && !endport) (*ent)->endport = (*ent)->startport; return(0); } int is_local(struct parsedfile *config, struct in_addr *testip) { struct netent *ent; for (ent = (config->localnets); ent != NULL; ent = ent -> next) { if ((testip->s_addr & ent->localnet.s_addr) == (ent->localip.s_addr & ent->localnet.s_addr)) { return(0); } } return(1); } /* Find the appropriate server to reach an ip */ int pick_server(struct parsedfile *config, struct serverent **ent, struct in_addr *ip, unsigned int port) { struct netent *net; char ipbuf[64]; show_msg(MSGDEBUG, "Picking appropriate server for %s\n", inet_ntoa(*ip)); *ent = (config->paths); while (*ent != NULL) { /* Go through all the servers looking for one */ /* with a path to this network */ show_msg(MSGDEBUG, "Checking SOCKS server %s\n", ((*ent)->address ? (*ent)->address : "(No Address)")); net = (*ent)->reachnets; while (net != NULL) { strcpy(ipbuf, inet_ntoa(net->localip)); show_msg(MSGDEBUG, "Server can reach %s/%s\n", ipbuf, inet_ntoa(net->localnet)); if (((ip->s_addr & net->localnet.s_addr) == (net->localip.s_addr & net->localnet.s_addr)) && (!net->startport || ((net->startport <= port) && (net->endport >= port)))) { show_msg(MSGDEBUG, "This server can reach target\n"); /* Found the net, return */ return(0); } net = net->next; } (*ent) = (*ent)->next; } *ent = &(config->defaultserver); return(0); } /* This function is very much like strsep, it looks in a string for */ /* a character from a list of characters, when it finds one it */ /* replaces it with a \0 and returns the start of the string */ /* (basically spitting out tokens with arbitrary separators). If no */ /* match is found the remainder of the string is returned and */ /* the start pointer is set to be NULL. The difference between */ /* standard strsep and this function is that this one will */ /* set *separator to the character separator found if it isn't null */ char *strsplit(char *separator, char **text, const char *search) { int len; char *ret; ret = *text; if (*text == NULL) { if (separator) *separator = '\0'; return(NULL); } else { len = strcspn(*text, search); if (len == strlen(*text)) { if (separator) *separator = '\0'; *text = NULL; } else { *text = *text + len; if (separator) *separator = **text; **text = '\0'; *text = *text + 1; } } return(ret); } tsocks-1.8beta5/tsocks.c0000644000000000000000000011622111642034445012157 0ustar /* TSOCKS - Wrapper library for transparent SOCKS Copyright (C) 2000 Shaun Clowes This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* PreProcessor Defines */ #include #ifdef USE_GNU_SOURCE #define _GNU_SOURCE #endif /* Global configuration variables */ char *progname = "libtsocks"; /* Name used in err msgs */ /* Header Files */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef USE_SOCKS_DNS #include #endif #include #include /* Global Declarations */ #ifdef USE_SOCKS_DNS static int (*realresinit)(void); #endif static int (*realconnect)(CONNECT_SIGNATURE); static int (*realselect)(SELECT_SIGNATURE); static int (*realpoll)(POLL_SIGNATURE); static int (*realclose)(CLOSE_SIGNATURE); static struct parsedfile *config; static struct connreq *requests = NULL; static int suid = 0; static char *conffile = NULL; /* Exported Function Prototypes */ void _init(void); int connect(CONNECT_SIGNATURE); int select(SELECT_SIGNATURE); int poll(POLL_SIGNATURE); int close(CLOSE_SIGNATURE); #ifdef USE_SOCKS_DNS int res_init(void); #endif /* Private Function Prototypes */ static int get_config(); static int get_environment(); static int connect_server(struct connreq *conn); static int send_socks_request(struct connreq *conn); static struct connreq *new_socks_request(int sockid, struct sockaddr_in *connaddr, struct sockaddr_in *serveraddr, struct serverent *path); static void kill_socks_request(struct connreq *conn); static int handle_request(struct connreq *conn); static struct connreq *find_socks_request(int sockid, int includefailed); static int connect_server(struct connreq *conn); static int send_socks_request(struct connreq *conn); static int send_socksv4_request(struct connreq *conn); static int send_socksv5_method(struct connreq *conn); static int send_socksv5_connect(struct connreq *conn); static int send_buffer(struct connreq *conn); static int recv_buffer(struct connreq *conn); static int read_socksv5_method(struct connreq *conn); static int read_socksv4_req(struct connreq *conn); static int read_socksv5_connect(struct connreq *conn); static int read_socksv5_auth(struct connreq *conn); void _init(void) { #ifdef USE_OLD_DLSYM void *lib; #endif /* We could do all our initialization here, but to be honest */ /* most programs that are run won't use our services, so */ /* we do our general initialization on first call */ /* Determine the logging level */ suid = (getuid() != geteuid()); #ifndef USE_OLD_DLSYM realconnect = dlsym(RTLD_NEXT, "connect"); realselect = dlsym(RTLD_NEXT, "select"); realpoll = dlsym(RTLD_NEXT, "poll"); realclose = dlsym(RTLD_NEXT, "close"); #ifdef USE_SOCKS_DNS realresinit = dlsym(RTLD_NEXT, "res_init"); #endif #else lib = dlopen(LIBCONNECT, RTLD_LAZY); realconnect = dlsym(lib, "connect"); realselect = dlsym(lib, "select"); realpoll = dlsym(lib, "poll"); #ifdef USE_SOCKS_DNS realresinit = dlsym(lib, "res_init"); #endif dlclose(lib); lib = dlopen(LIBC, RTLD_LAZY); realclose = dlsym(lib, "close"); dlclose(lib); #endif } static int get_environment() { static int done = 0; int loglevel = MSGERR; char *logfile = NULL; char *env; if (done) return(0); /* Determine the logging level */ #ifndef ALLOW_MSG_OUTPUT set_log_options(-1, stderr, 0); #else if ((env = getenv("TSOCKS_DEBUG"))) loglevel = atoi(env); if (((env = getenv("TSOCKS_DEBUG_FILE"))) && !suid) logfile = env; set_log_options(loglevel, logfile, 1); #endif done = 1; return(0); } static int get_config () { static int done = 0; if (done) return(0); /* Determine the location of the config file */ #ifdef ALLOW_ENV_CONFIG if (!suid) conffile = getenv("TSOCKS_CONF_FILE"); #endif /* Read in the config file */ config = malloc(sizeof(*config)); if (!config) return(0); read_config(conffile, config); if (config->paths) show_msg(MSGDEBUG, "First lineno for first path is %d\n", config->paths->lineno); done = 1; return(0); } int connect(CONNECT_SIGNATURE) { struct sockaddr_in *connaddr; struct sockaddr_in peer_address; struct sockaddr_in server_address; int gotvalidserver = 0, rc, namelen = sizeof(peer_address); int sock_type = -1; int sock_type_len = sizeof(sock_type); unsigned int res = -1; struct serverent *path; struct connreq *newconn; get_environment(); /* If the real connect doesn't exist, we're stuffed */ if (realconnect == NULL) { show_msg(MSGERR, "Unresolved symbol: connect\n"); return(-1); } show_msg(MSGDEBUG, "Got connection request\n"); connaddr = (struct sockaddr_in *) __addr; /* Get the type of the socket */ getsockopt(__fd, SOL_SOCKET, SO_TYPE, (void *) &sock_type, &sock_type_len); /* If this isn't an INET socket for a TCP stream we can't */ /* handle it, just call the real connect now */ if ((connaddr->sin_family != AF_INET) || (sock_type != SOCK_STREAM)) { show_msg(MSGDEBUG, "Connection isn't a TCP stream ignoring\n"); return(realconnect(__fd, __addr, __len)); } /* If we haven't initialized yet, do it now */ get_config(); /* Are we already handling this connect? */ if ((newconn = find_socks_request(__fd, 1))) { if (memcmp(&newconn->connaddr, connaddr, sizeof(*connaddr))) { /* Ok, they're calling connect on a socket that is in our * queue but this connect() isn't to the same destination, * they're obviously not trying to check the status of * they're non blocking connect, they must have close()d * the other socket and created a new one which happens * to have the same fd as a request we haven't had the chance * to delete yet, so we delete it here. */ show_msg(MSGDEBUG, "Call to connect received on old " "tsocks request for socket %d but to " "new destination, deleting old request\n", newconn->sockid); kill_socks_request(newconn); } else { /* Ok, this call to connect() is to check the status of * a current non blocking connect(). */ if (newconn->state == FAILED) { show_msg(MSGDEBUG, "Call to connect received on failed " "request %d, returning %d\n", newconn->sockid, newconn->err); errno = newconn->err; rc = -1; } else if (newconn->state == DONE) { show_msg(MSGERR, "Call to connect received on completed " "request %d\n", newconn->sockid, newconn->err); rc = 0; } else { show_msg(MSGDEBUG, "Call to connect received on current request %d\n", newconn->sockid); rc = handle_request(newconn); errno = rc; } if ((newconn->state == FAILED) || (newconn->state == DONE)) kill_socks_request(newconn); return((rc ? -1 : 0)); } } /* If the socket is already connected, just call connect */ /* and get its standard reply */ if (!getpeername(__fd, (struct sockaddr *) &peer_address, &namelen)) { show_msg(MSGDEBUG, "Socket is already connected, defering to " "real connect\n"); return(realconnect(__fd, __addr, __len)); } show_msg(MSGDEBUG, "Got connection request for socket %d to " "%s\n", __fd, inet_ntoa(connaddr->sin_addr)); /* If the address is local call realconnect */ if (!(is_local(config, &(connaddr->sin_addr)))) { show_msg(MSGDEBUG, "Connection for socket %d is local\n", __fd); return(realconnect(__fd, __addr, __len)); } /* Ok, so its not local, we need a path to the net */ pick_server(config, &path, &(connaddr->sin_addr), ntohs(connaddr->sin_port)); show_msg(MSGDEBUG, "Picked server %s for connection\n", (path->address ? path->address : "(Not Provided)")); if (path->address == NULL) { if (path == &(config->defaultserver)) { show_msg(MSGERR, "Connection needs to be made " "via default server but " "the default server has not " "been specified. Falling back to direct connection.\n"); return(realconnect(__fd, __addr, __len)); } else show_msg(MSGERR, "Connection needs to be made " "via path specified at line " "%d in configuration file but " "the server has not been " "specified for this path\n", path->lineno); } else if ((res = resolve_ip(path->address, 0, HOSTNAMES)) == -1) { show_msg(MSGERR, "The SOCKS server (%s) listed in the configuration " "file which needs to be used for this connection " "is invalid\n", path->address); } else { /* Construct the addr for the socks server */ server_address.sin_family = AF_INET; /* host byte order */ server_address.sin_addr.s_addr = res; server_address.sin_port = htons(path->port); bzero(&(server_address.sin_zero), 8); /* Complain if this server isn't on a localnet */ if (is_local(config, &server_address.sin_addr)) { show_msg(MSGERR, "SOCKS server %s (%s) is not on a local subnet!\n", path->address, inet_ntoa(server_address.sin_addr)); } else gotvalidserver = 1; } /* If we haven't found a valid server we return connection refused */ if (!gotvalidserver || !(newconn = new_socks_request(__fd, connaddr, &server_address, path))) { errno = ECONNREFUSED; return(-1); } else { /* Now we call the main function to handle the connect. */ rc = handle_request(newconn); /* If the request completed immediately it mustn't have been * a non blocking socket, in this case we don't need to know * about this socket anymore. */ if ((newconn->state == FAILED) || (newconn->state == DONE)) kill_socks_request(newconn); errno = rc; return((rc ? -1 : 0)); } } int select(SELECT_SIGNATURE) { int nevents = 0; int rc = 0; int setevents = 0; int monitoring = 0; struct connreq *conn, *nextconn; fd_set mywritefds, myreadfds, myexceptfds; /* If we're not currently managing any requests we can just * leave here */ if (!requests) return(realselect(n, readfds, writefds, exceptfds, timeout)); get_environment(); show_msg(MSGDEBUG, "Intercepted call to select with %d fds, " "0x%08x 0x%08x 0x%08x, timeout %08x\n", n, readfds, writefds, exceptfds, timeout); for (conn = requests; conn != NULL; conn = conn->next) { if ((conn->state == FAILED) || (conn->state == DONE)) continue; conn->selectevents = 0; show_msg(MSGDEBUG, "Checking requests for socks enabled socket %d\n", conn->sockid); conn->selectevents |= (writefds ? (FD_ISSET(conn->sockid, writefds) ? WRITE : 0) : 0); conn->selectevents |= (readfds ? (FD_ISSET(conn->sockid, readfds) ? READ : 0) : 0); conn->selectevents |= (exceptfds ? (FD_ISSET(conn->sockid, exceptfds) ? EXCEPT : 0) : 0); if (conn->selectevents) { show_msg(MSGDEBUG, "Socket %d was set for events\n", conn->sockid); monitoring = 1; } } if (!monitoring) return(realselect(n, readfds, writefds, exceptfds, timeout)); /* This is our select loop. In it we repeatedly call select(). We * pass select the same fdsets as provided by the caller except we * modify the fdsets for the sockets we're managing to get events * we're interested in (while negotiating with the socks server). When * events we're interested in happen we go off and process the result * ourselves, without returning the events to the caller. The loop * ends when an event which isn't one we need to handle occurs or * the select times out */ do { /* Copy the clients fd events, we'll change them as we wish */ if (readfds) memcpy(&myreadfds, readfds, sizeof(myreadfds)); else FD_ZERO(&myreadfds); if (writefds) memcpy(&mywritefds, writefds, sizeof(mywritefds)); else FD_ZERO(&mywritefds); if (exceptfds) memcpy(&myexceptfds, exceptfds, sizeof(myexceptfds)); else FD_ZERO(&myexceptfds); /* Now enable our sockets for the events WE want to hear about */ for (conn = requests; conn != NULL; conn = conn->next) { if ((conn->state == FAILED) || (conn->state == DONE) || (conn->selectevents == 0)) continue; /* We always want to know about socket exceptions */ FD_SET(conn->sockid, &myexceptfds); /* If we're waiting for a connect or to be able to send * on a socket we want to get write events */ if ((conn->state == SENDING) || (conn->state == CONNECTING)) FD_SET(conn->sockid,&mywritefds); else FD_CLR(conn->sockid,&mywritefds); /* If we're waiting to receive data we want to get * read events */ if (conn->state == RECEIVING) FD_SET(conn->sockid,&myreadfds); else FD_CLR(conn->sockid,&myreadfds); } nevents = realselect(n, &myreadfds, &mywritefds, &myexceptfds, timeout); /* If there were no events we must have timed out or had an error */ if (nevents <= 0) break; /* Loop through all the sockets we're monitoring and see if * any of them have had events */ for (conn = requests; conn != NULL; conn = nextconn) { nextconn = conn->next; if ((conn->state == FAILED) || (conn->state == DONE)) continue; show_msg(MSGDEBUG, "Checking socket %d for events\n", conn->sockid); /* Clear all the events on the socket (if any), we'll reset * any that are necessary later. */ setevents = 0; if (FD_ISSET(conn->sockid, &mywritefds)) { nevents--; setevents |= WRITE; show_msg(MSGDEBUG, "Socket had write event\n"); FD_CLR(conn->sockid, &mywritefds); } if (FD_ISSET(conn->sockid, &myreadfds)) { nevents--; setevents |= READ; show_msg(MSGDEBUG, "Socket had write event\n"); FD_CLR(conn->sockid, &myreadfds); } if (FD_ISSET(conn->sockid, &myexceptfds)) { nevents--; setevents |= EXCEPT; show_msg(MSGDEBUG, "Socket had except event\n"); FD_CLR(conn->sockid, &myexceptfds); } if (!setevents) { show_msg(MSGDEBUG, "No events on socket %d\n", conn->sockid); continue; } if (setevents & EXCEPT) { conn->state = FAILED; } else { rc = handle_request(conn); } /* If the connection hasn't failed or completed there is nothing * to report to the client */ if ((conn->state != FAILED) && (conn->state != DONE)) continue; /* Ok, the connection is completed, for good or for bad. We now * hand back the relevant events to the caller. We don't delete the * connection though since the caller should call connect() to * check the status, we delete it then */ if (conn->state == FAILED) { /* Damn, the connection failed. Whatever the events the socket * was selected for we flag */ if (conn->selectevents & EXCEPT) { FD_SET(conn->sockid, &myexceptfds); nevents++; } if (conn->selectevents & READ) { FD_SET(conn->sockid, &myreadfds); nevents++; } if (conn->selectevents & WRITE) { FD_SET(conn->sockid, &mywritefds); nevents++; } /* We should use setsockopt to set the SO_ERROR errno for this * socket, but this isn't allowed for some silly reason which * leaves us a bit hamstrung. * We don't delete the request so that hopefully we can * return the error on the socket if they call connect() on it */ } else { /* The connection is done, if the client selected for * writing we can go ahead and signal that now (since the socket must * be ready for writing), otherwise we'll just let the select loop * come around again (since we can't flag it for read, we don't know * if there is any data to be read and can't be bothered checking) */ if (conn->selectevents & WRITE) { FD_SET(conn->sockid, &mywritefds); nevents++; } } } } while (nevents == 0); show_msg(MSGDEBUG, "Finished intercepting select(), %d events\n", nevents); /* Now copy our event blocks back to the client blocks */ if (readfds) memcpy(readfds, &myreadfds, sizeof(myreadfds)); if (writefds) memcpy(writefds, &mywritefds, sizeof(mywritefds)); if (exceptfds) memcpy(exceptfds, &myexceptfds, sizeof(myexceptfds)); return(nevents); } int poll(POLL_SIGNATURE) { int nevents = 0; int rc = 0, i; int setevents = 0; int monitoring = 0; struct connreq *conn, *nextconn; /* If we're not currently managing any requests we can just * leave here */ if (!requests) return(realpoll(ufds, nfds, timeout)); get_environment(); show_msg(MSGDEBUG, "Intercepted call to poll with %d fds, " "0x%08x timeout %d\n", nfds, ufds, timeout); for (conn = requests; conn != NULL; conn = conn->next) conn->selectevents = 0; /* Record what events on our sockets the caller was interested * in */ for (i = 0; i < nfds; i++) { if (!(conn = find_socks_request(ufds[i].fd, 0))) continue; show_msg(MSGDEBUG, "Have event checks for socks enabled socket %d\n", conn->sockid); conn->selectevents = ufds[i].events; monitoring = 1; } if (!monitoring) return(realpoll(ufds, nfds, timeout)); /* This is our poll loop. In it we repeatedly call poll(). We * pass select the same event list as provided by the caller except we * modify the events for the sockets we're managing to get events * we're interested in (while negotiating with the socks server). When * events we're interested in happen we go off and process the result * ourselves, without returning the events to the caller. The loop * ends when an event which isn't one we need to handle occurs or * the poll times out */ do { /* Enable our sockets for the events WE want to hear about */ for (i = 0; i < nfds; i++) { if (!(conn = find_socks_request(ufds[i].fd, 0))) continue; /* We always want to know about socket exceptions but they're * always returned (i.e they don't need to be in the list of * wanted events to be returned by the kernel */ ufds[i].events = 0; /* If we're waiting for a connect or to be able to send * on a socket we want to get write events */ if ((conn->state == SENDING) || (conn->state == CONNECTING)) ufds[i].events |= POLLOUT; /* If we're waiting to receive data we want to get * read events */ if (conn->state == RECEIVING) ufds[i].events |= POLLIN; } nevents = realpoll(ufds, nfds, timeout); /* If there were no events we must have timed out or had an error */ if (nevents <= 0) break; /* Loop through all the sockets we're monitoring and see if * any of them have had events */ for (conn = requests; conn != NULL; conn = nextconn) { nextconn = conn->next; if ((conn->state == FAILED) || (conn->state == DONE)) continue; /* Find the socket in the poll list */ for (i = 0; ((i < nfds) && (ufds[i].fd != conn->sockid)); i++) /* Empty Loop */; if (i == nfds) continue; show_msg(MSGDEBUG, "Checking socket %d for events\n", conn->sockid); if (!ufds[i].revents) { show_msg(MSGDEBUG, "No events on socket\n"); continue; } /* Clear any read or write events on the socket, we'll reset * any that are necessary later. */ setevents = ufds[i].revents; if (setevents & POLLIN) { show_msg(MSGDEBUG, "Socket had read event\n"); ufds[i].revents &= ~POLLIN; nevents--; } if (setevents & POLLOUT) { show_msg(MSGDEBUG, "Socket had write event\n"); ufds[i].revents &= ~POLLOUT; nevents--; } if (setevents & (POLLERR | POLLNVAL | POLLHUP)) show_msg(MSGDEBUG, "Socket had error event\n"); /* Now handle this event */ if (setevents & (POLLERR | POLLNVAL | POLLHUP)) { conn->state = FAILED; } else { rc = handle_request(conn); } /* If the connection hasn't failed or completed there is nothing * to report to the client */ if ((conn->state != FAILED) && (conn->state != DONE)) continue; /* Ok, the connection is completed, for good or for bad. We now * hand back the relevant events to the caller. We don't delete the * connection though since the caller should call connect() to * check the status, we delete it then */ if (conn->state == FAILED) { /* Damn, the connection failed. Just copy back the error events * from the poll call, error events are always valid even if not * requested by the client */ /* We should use setsockopt to set the SO_ERROR errno for this * socket, but this isn't allowed for some silly reason which * leaves us a bit hamstrung. * We don't delete the request so that hopefully we can * return the error on the socket if they call connect() on it */ } else { /* The connection is done, if the client polled for * writing we can go ahead and signal that now (since the socket must * be ready for writing), otherwise we'll just let the select loop * come around again (since we can't flag it for read, we don't know * if there is any data to be read and can't be bothered checking) */ if (conn->selectevents & WRITE) { setevents |= POLLOUT; nevents++; } } } } while (nevents == 0); show_msg(MSGDEBUG, "Finished intercepting poll(), %d events\n", nevents); /* Now restore the events polled in each of the blocks */ for (i = 0; i < nfds; i++) { if (!(conn = find_socks_request(ufds[i].fd, 1))) continue; ufds[i].events = conn->selectevents; } return(nevents); } int close(CLOSE_SIGNATURE) { int rc; struct connreq *conn; if (realclose == NULL) { show_msg(MSGERR, "Unresolved symbol: close\n"); return(-1); } show_msg(MSGDEBUG, "Call to close(%d)\n", fd); rc = realclose(fd); /* If we have this fd in our request handling list we * remove it now */ if ((conn = find_socks_request(fd, 1))) { show_msg(MSGDEBUG, "Call to close() received on file descriptor " "%d which is a connection request of status %d\n", conn->sockid, conn->state); kill_socks_request(conn); } return(rc); } static struct connreq *new_socks_request(int sockid, struct sockaddr_in *connaddr, struct sockaddr_in *serveraddr, struct serverent *path) { struct connreq *newconn; if ((newconn = malloc(sizeof(*newconn))) == NULL) { /* Could not malloc, we're stuffed */ show_msg(MSGERR, "Could not allocate memory for new socks request\n"); return(NULL); } /* Add this connection to be proxied to the list */ memset(newconn, 0x0, sizeof(*newconn)); newconn->sockid = sockid; newconn->state = UNSTARTED; newconn->path = path; memcpy(&(newconn->connaddr), connaddr, sizeof(newconn->connaddr)); memcpy(&(newconn->serveraddr), serveraddr, sizeof(newconn->serveraddr)); newconn->next = requests; requests = newconn; return(newconn); } static void kill_socks_request(struct connreq *conn) { struct connreq *connnode; if (requests == conn) requests = conn->next; else { for (connnode = requests; connnode != NULL; connnode = connnode->next) { if (connnode->next == conn) { connnode->next = conn->next; break; } } } free(conn); } static struct connreq *find_socks_request(int sockid, int includefinished) { struct connreq *connnode; for (connnode = requests; connnode != NULL; connnode = connnode->next) { if (connnode->sockid == sockid) { if (((connnode->state == FAILED) || (connnode->state == DONE)) && !includefinished) break; else return(connnode); } } return(NULL); } static int handle_request(struct connreq *conn) { int rc = 0; int i = 0; show_msg(MSGDEBUG, "Beginning handle loop for socket %d\n", conn->sockid); while ((rc == 0) && (conn->state != FAILED) && (conn->state != DONE) && (i++ < 20)) { show_msg(MSGDEBUG, "In request handle loop for socket %d, " "current state of request is %d\n", conn->sockid, conn->state); switch(conn->state) { case UNSTARTED: case CONNECTING: rc = connect_server(conn); break; case CONNECTED: rc = send_socks_request(conn); break; case SENDING: rc = send_buffer(conn); break; case RECEIVING: rc = recv_buffer(conn); break; case SENTV4REQ: show_msg(MSGDEBUG, "Receiving reply to SOCKS V4 connect request\n"); conn->datalen = sizeof(struct sockrep); conn->datadone = 0; conn->state = RECEIVING; conn->nextstate = GOTV4REQ; break; case GOTV4REQ: rc = read_socksv4_req(conn); break; case SENTV5METHOD: show_msg(MSGDEBUG, "Receiving reply to SOCKS V5 method negotiation\n"); conn->datalen = 2; conn->datadone = 0; conn->state = RECEIVING; conn->nextstate = GOTV5METHOD; break; case GOTV5METHOD: rc = read_socksv5_method(conn); break; case SENTV5AUTH: show_msg(MSGDEBUG, "Receiving reply to SOCKS V5 authentication negotiation\n"); conn->datalen = 2; conn->datadone = 0; conn->state = RECEIVING; conn->nextstate = GOTV5AUTH; break; case GOTV5AUTH: rc = read_socksv5_auth(conn); break; case SENTV5CONNECT: show_msg(MSGDEBUG, "Receiving reply to SOCKS V5 connect request\n"); conn->datalen = 10; conn->datadone = 0; conn->state = RECEIVING; conn->nextstate = GOTV5CONNECT; break; case GOTV5CONNECT: rc = read_socksv5_connect(conn); break; } conn->err = errno; } if (i == 20) show_msg(MSGERR, "Ooops, state loop while handling request %d\n", conn->sockid); show_msg(MSGDEBUG, "Handle loop completed for socket %d in state %d, " "returning %d\n", conn->sockid, conn->state, rc); return(rc); } static int connect_server(struct connreq *conn) { int rc; /* Connect this socket to the socks server */ show_msg(MSGDEBUG, "Connecting to %s port %d\n", inet_ntoa(conn->serveraddr.sin_addr), ntohs(conn->serveraddr.sin_port)); rc = realconnect(conn->sockid, (CONNECT_SOCKARG) &(conn->serveraddr), sizeof(conn->serveraddr)); show_msg(MSGDEBUG, "Connect returned %d, errno is %d\n", rc, errno); if (rc) { if (errno != EINPROGRESS) { show_msg(MSGERR, "Error %d attempting to connect to SOCKS " "server (%s)\n", errno, strerror(errno)); conn->state = FAILED; } else { show_msg(MSGDEBUG, "Connection in progress\n"); conn->state = CONNECTING; } } else { show_msg(MSGDEBUG, "Socket %d connected to SOCKS server\n", conn->sockid); conn->state = CONNECTED; } return((rc ? errno : 0)); } static int send_socks_request(struct connreq *conn) { int rc = 0; if (conn->path->type == 4) rc = send_socksv4_request(conn); else rc = send_socksv5_method(conn); return(rc); } static int send_socksv4_request(struct connreq *conn) { struct passwd *user; struct sockreq *thisreq; /* Determine the current username */ user = getpwuid(getuid()); thisreq = (struct sockreq *) conn->buffer; /* Check the buffer has enough space for the request */ /* and the user name */ conn->datalen = sizeof(struct sockreq) + (user == NULL ? 0 : strlen(user->pw_name)) + 1; if (sizeof(conn->buffer) < conn->datalen) { show_msg(MSGERR, "The SOCKS username is too long"); conn->state = FAILED; return(ECONNREFUSED); } /* Create the request */ thisreq->version = 4; thisreq->command = 1; thisreq->dstport = conn->connaddr.sin_port; thisreq->dstip = conn->connaddr.sin_addr.s_addr; /* Copy the username */ strcpy((char *) thisreq + sizeof(struct sockreq), (user == NULL ? "" : user->pw_name)); conn->datadone = 0; conn->state = SENDING; conn->nextstate = SENTV4REQ; return(0); } static int send_socksv5_method(struct connreq *conn) { char verstring[] = { 0x05, /* Version 5 SOCKS */ 0x02, /* No. Methods */ 0x00, /* Null Auth */ 0x02 }; /* User/Pass Auth */ show_msg(MSGDEBUG, "Constructing V5 method negotiation\n"); conn->state = SENDING; conn->nextstate = SENTV5METHOD; memcpy(conn->buffer, verstring, sizeof(verstring)); conn->datalen = sizeof(verstring); conn->datadone = 0; return(0); } static int send_socksv5_connect(struct connreq *conn) { char constring[] = { 0x05, /* Version 5 SOCKS */ 0x01, /* Connect request */ 0x00, /* Reserved */ 0x01 }; /* IP Version 4 */ show_msg(MSGDEBUG, "Constructing V5 connect request\n"); conn->datadone = 0; conn->state = SENDING; conn->nextstate = SENTV5CONNECT; memcpy(conn->buffer, constring, sizeof(constring)); conn->datalen = sizeof(constring); memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_addr.s_addr), sizeof(conn->connaddr.sin_addr.s_addr)); conn->datalen += sizeof(conn->connaddr.sin_addr.s_addr); memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_port), sizeof(conn->connaddr.sin_port)); conn->datalen += sizeof(conn->connaddr.sin_port); return(0); } static int send_buffer(struct connreq *conn) { int rc = 0; show_msg(MSGDEBUG, "Writing to server (sending %d bytes)\n", conn->datalen); while ((rc == 0) && (conn->datadone != conn->datalen)) { rc = send(conn->sockid, conn->buffer + conn->datadone, conn->datalen - conn->datadone, 0); if (rc > 0) { conn->datadone += rc; rc = 0; } else { if (errno != EWOULDBLOCK) show_msg(MSGDEBUG, "Write failed, %s\n", strerror(errno)); rc = errno; } } if (conn->datadone == conn->datalen) conn->state = conn->nextstate; show_msg(MSGDEBUG, "Sent %d bytes of %d bytes in buffer, return code is %d\n", conn->datadone, conn->datalen, rc); return(rc); } static int recv_buffer(struct connreq *conn) { int rc = 0; show_msg(MSGDEBUG, "Reading from server (expecting %d bytes)\n", conn->datalen); while ((rc == 0) && (conn->datadone != conn->datalen)) { rc = recv(conn->sockid, conn->buffer + conn->datadone, conn->datalen - conn->datadone, 0); if (rc > 0) { conn->datadone += rc; rc = 0; } else { if (errno != EWOULDBLOCK) show_msg(MSGDEBUG, "Read failed, %s\n", strerror(errno)); rc = errno; } } if (conn->datadone == conn->datalen) conn->state = conn->nextstate; show_msg(MSGDEBUG, "Received %d bytes of %d bytes expected, return code is %d\n", conn->datadone, conn->datalen, rc); return(rc); } static int read_socksv5_method(struct connreq *conn) { struct passwd *nixuser; char *uname, *upass; /* See if we offered an acceptable method */ if (conn->buffer[1] == '\xff') { show_msg(MSGERR, "SOCKS V5 server refused authentication methods\n"); conn->state = FAILED; return(ECONNREFUSED); } /* If the socks server chose username/password authentication */ /* (method 2) then do that */ if ((unsigned short int) conn->buffer[1] == 2) { show_msg(MSGDEBUG, "SOCKS V5 server chose username/password authentication\n"); /* Determine the current *nix username */ nixuser = getpwuid(getuid()); if (((uname = conn->path->defuser) == NULL) && ((uname = getenv("TSOCKS_USERNAME")) == NULL) && ((uname = (nixuser == NULL ? NULL : nixuser->pw_name)) == NULL)) { show_msg(MSGERR, "Could not get SOCKS username from " "local passwd file, tsocks.conf " "or $TSOCKS_USERNAME to authenticate " "with"); conn->state = FAILED; return(ECONNREFUSED); } if (((upass = getenv("TSOCKS_PASSWORD")) == NULL) && ((upass = conn->path->defpass) == NULL)) { show_msg(MSGERR, "Need a password in tsocks.conf or " "$TSOCKS_PASSWORD to authenticate with"); conn->state = FAILED; return(ECONNREFUSED); } /* Check that the username / pass specified will */ /* fit into the buffer */ if ((3 + strlen(uname) + strlen(upass)) >= sizeof(conn->buffer)) { show_msg(MSGERR, "The supplied socks username or " "password is too long"); conn->state = FAILED; return(ECONNREFUSED); } conn->datalen = 0; conn->buffer[conn->datalen] = '\x01'; conn->datalen++; conn->buffer[conn->datalen] = (int8_t) strlen(uname); conn->datalen++; memcpy(&(conn->buffer[conn->datalen]), uname, strlen(uname)); conn->datalen = conn->datalen + strlen(uname); conn->buffer[conn->datalen] = (int8_t) strlen(upass); conn->datalen++; memcpy(&(conn->buffer[conn->datalen]), upass, strlen(upass)); conn->datalen = conn->datalen + strlen(upass); conn->state = SENDING; conn->nextstate = SENTV5AUTH; conn->datadone = 0; } else return(send_socksv5_connect(conn)); return(0); } static int read_socksv5_auth(struct connreq *conn) { if (conn->buffer[1] != '\x00') { show_msg(MSGERR, "SOCKS authentication failed, check username and password\n"); conn->state = FAILED; return(ECONNREFUSED); } /* Ok, we authenticated ok, send the connection request */ return(send_socksv5_connect(conn)); } static int read_socksv5_connect(struct connreq *conn) { /* See if the connection succeeded */ if (conn->buffer[1] != '\x00') { show_msg(MSGERR, "SOCKS V5 connect failed: "); conn->state = FAILED; switch ((int8_t) conn->buffer[1]) { case 1: show_msg(MSGERR, "General SOCKS server failure\n"); return(ECONNABORTED); case 2: show_msg(MSGERR, "Connection denied by rule\n"); return(ECONNABORTED); case 3: show_msg(MSGERR, "Network unreachable\n"); return(ENETUNREACH); case 4: show_msg(MSGERR, "Host unreachable\n"); return(EHOSTUNREACH); case 5: show_msg(MSGERR, "Connection refused\n"); return(ECONNREFUSED); case 6: show_msg(MSGERR, "TTL Expired\n"); return(ETIMEDOUT); case 7: show_msg(MSGERR, "Command not supported\n"); return(ECONNABORTED); case 8: show_msg(MSGERR, "Address type not supported\n"); return(ECONNABORTED); default: show_msg(MSGERR, "Unknown error\n"); return(ECONNABORTED); } } conn->state = DONE; return(0); } static int read_socksv4_req(struct connreq *conn) { struct sockrep *thisrep; thisrep = (struct sockrep *) conn->buffer; if (thisrep->result != 90) { show_msg(MSGERR, "SOCKS V4 connect rejected:\n"); conn->state = FAILED; switch(thisrep->result) { case 91: show_msg(MSGERR, "SOCKS server refused connection\n"); return(ECONNREFUSED); case 92: show_msg(MSGERR, "SOCKS server refused connection " "because of failed connect to identd " "on this machine\n"); return(ECONNREFUSED); case 93: show_msg(MSGERR, "SOCKS server refused connection " "because identd and this library " "reported different user-ids\n"); return(ECONNREFUSED); default: show_msg(MSGERR, "Unknown reason\n"); return(ECONNREFUSED); } } conn->state = DONE; return(0); } #ifdef USE_SOCKS_DNS int res_init(void) { int rc; if (realresinit == NULL) { show_msg(MSGERR, "Unresolved symbol: res_init\n"); return(-1); } /* Call normal res_init */ rc = realresinit(); /* Force using TCP protocol for DNS queries */ _res.options |= RES_USEVC; return(rc); } #endif #if 0 /* Get the flags of the socket, (incase its non blocking */ if ((sockflags = fcntl(sockid, F_GETFL)) == -1) { sockflags = 0; } /* If the flags show the socket as blocking, set it to */ /* blocking for our connection to the socks server */ if ((sockflags & O_NONBLOCK) != 0) { fcntl(sockid, F_SETFL, sockflags & (~(O_NONBLOCK))); } #endif #if 0 /* If the socket was in non blocking mode, restore that */ if ((sockflags & O_NONBLOCK) != 0) { fcntl(sockid, F_SETFL, sockflags); } #endif tsocks-1.8beta5/Makefile.in0000644000000000000000000000441611620231375012551 0ustar # Makefile used by configure to create real Makefile CC=@CC@ prefix=@prefix@ exec_prefix = @exec_prefix@ libexecdir = @libexecdir@ sysconfdir = @sysconfdir@ libdir = @libdir@ bindir = @bindir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ SHELL = /bin/sh MKINSTALLDIRS = ${SHELL} mkinstalldirs SHCC = ${CC} -fPIC INSPECT = inspectsocks SAVE = saveme LIB_NAME = libtsocks COMMON = common PARSER = parser VALIDATECONF = validateconf SCRIPT = tsocks SHLIB_MAJOR = 1 SHLIB_MINOR = 8 SHLIB = ${LIB_NAME}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ CFLAGS = @CFLAGS@ INCLUDES = -I. LIBS = @LIBS@ SPECIALLIBS = @SPECIALLIBS@ SHOBJS = ${OBJS:.o=.so} OBJS= tsocks.o TARGETS= ${SHLIB} ${UTIL_LIB} ${SAVE} ${INSPECT} ${VALIDATECONF} all: ${TARGETS} ${VALIDATECONF}: ${VALIDATECONF}.c ${COMMON}.o ${PARSER}.o ${SHCC} ${CFLAGS} ${INCLUDES} -o ${VALIDATECONF} ${VALIDATECONF}.c ${COMMON}.o ${PARSER}.o ${LIBS} ${INSPECT}: ${INSPECT}.c ${COMMON}.o ${SHCC} ${CFLAGS} ${INCLUDES} -o ${INSPECT} ${INSPECT}.c ${COMMON}.o ${LIBS} ${SAVE}: ${SAVE}.c ${SHCC} ${CFLAGS} ${INCLUDES} -static -o ${SAVE} ${SAVE}.c ${SHLIB}: ${OBJS} ${COMMON}.o ${PARSER}.o ${SHCC} ${CFLAGS} ${INCLUDES} -nostdlib -shared -o ${SHLIB} ${OBJS} ${COMMON}.o ${PARSER}.o ${DYNLIB_FLAGS} ${SPECIALLIBS} ${LIBS} ln -sf ${SHLIB} ${LIB_NAME}.so %.so: %.c ${SHCC} ${CFLAGS} ${INCLUDES} -c ${CC_SWITCHES} $< -o $@ %.o: %.c ${SHCC} ${CFLAGS} ${INCLUDES} -c ${CC_SWITCHES} $< -o $@ install: ${TARGETS} installscript installlib installman installscript: ${MKINSTALLDIRS} "${DESTDIR}${bindir}" ${INSTALL} ${SCRIPT} ${DESTDIR}${bindir} installlib: ${MKINSTALLDIRS} "${DESTDIR}${libdir}" ${INSTALL} ${SHLIB} ${DESTDIR}${libdir} ln -sf ${SHLIB} ${DESTDIR}${libdir}/${LIB_NAME}.so.${SHLIB_MAJOR} ln -sf ${LIB_NAME}.so.${SHLIB_MAJOR} ${DESTDIR}${libdir}/${LIB_NAME}.so installman: ${MKINSTALLDIRS} "${DESTDIR}${mandir}/man1" ${INSTALL_DATA} tsocks.1 ${DESTDIR}${mandir}/man1/ ${MKINSTALLDIRS} "${DESTDIR}${mandir}/man8" ${INSTALL_DATA} tsocks.8 ${DESTDIR}${mandir}/man8/ ${MKINSTALLDIRS} "${DESTDIR}${mandir}/man5" ${INSTALL_DATA} tsocks.conf.5 ${DESTDIR}${mandir}/man5/ clean: -rm -f *.so *.so.* *.o *~ ${TARGETS} distclean: clean -rm -f config.cache config.log config.h Makefile tsocks-1.8beta5/TODO0000644000000000000000000000024211642003217011161 0ustar - Update FAQ to include information about the install location of the tsocks library - Install the saveme and validateconf binaries, presumably with new names tsocks-1.8beta5/install-sh0000755000000000000000000001124411620231375012505 0ustar #! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" tranformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 tsocks-1.8beta5/FAQ0000644000000000000000000000377111642003217011035 0ustar Q: tsocks doesn't seem to be working for SSH, why? A: tsocks can be used a number of ways, the most common being the LD_PRELOAD environment variable. When set (often through the 'tsocks' script) this requests that the system dynamic loader load tsocks into each process before execution of the process begins. This allows tsocks to redirect calls to standard networking functions to force them to be socksified. Unfortunately LD_PRELOAD simply doesn't work for setuid programs when the user running the program is not the same as the owner of the executable. This is because being able to load code into a privileged executable would be a major security flaw. To fix this problem you may wish to removed the setuid bit from SSH (this will force it not to use privileged TCP ports, disable some forms of RSA authentication to older servers and may have other effects). Alternatively you might wish to force tsocks to be loaded into all processes using the /etc/ld.so.preload file, for more information please see the tsocks man page. Q: tsocks doesn't seem to be working for ftp, why? A: tsocks can only socksify outgoing connection requests from applications, in ftp there are normally two channels, one is made from the client to the server (called the control channel) and another from the server back to the client (called the data channel). If a SOCKS server is between the client and the server the server will incorrectly try to connect back to the SOCKS server rather than the client. Thus the data channel connection will be fail (not that it would likely succeed even if it did try to connect back to the correct client, given the SOCKS server is probably firewalling the network off). The simplest solution to this problem is to use passive mode ftp, in this form of ftp all connections are made from the client to server, even the data channel. Most ftp clients and servers support passive mode, check your documentation (as a tip the Linux command line ftp client uses passive mode when invoced with the -p option) tsocks-1.8beta5/acconfig.h0000644000000000000000000000404111642034445012423 0ustar /* accconfig.h -- `autoheader' will generate config.h.in for tsocks . */ /* Allow tsocks to generate messages to stderr when errors are encountered, this is really important and should only be disabled if you're REALLY sure. It can also be turned off at run time, see the man page for details */ #undef ALLOW_MSG_OUTPUT /* Allow TSOCKS_CONF_FILE in environment to specify config file location */ #undef ALLOW_ENV_CONFIG /* Use _GNU_SOURCE to define RTLD_NEXT, mostly for RH7 systems */ #undef USE_GNU_SOURCE /* dlopen() the old libc to get connect() instead of RTLD_NEXT, hopefully shouldn't be needed */ #undef USE_OLD_DLSYM /* path to library containing connect(), needed if USE_OLD_DLSYM is enabled */ #undef LIBCONNECT /* path to libc, needed if USE_OLD_DLSYM is enabled */ #undef LIBC /* Configure the system resolver to use TCP queries on startup, this allows socksified DNS */ #undef USE_SOCKS_DNS /* Prototype and function header for connect function */ #undef CONNECT_SIGNATURE /* The type of socket structure pointer to use to call the * real connect */ #undef CONNECT_SOCKARG /* Prototype and function header for select function */ #undef SELECT_SIGNATURE /* Prototype and function header for poll function */ #undef POLL_SIGNATURE /* Prototype and function header for close function */ #undef CLOSE_SIGNATURE /* Work out which function we have for conversion from string IPs to numerical ones */ #undef HAVE_INET_ADDR #undef HAVE_INET_ATON /* We use strsep which isn't on all machines, but we provide our own definition of it for those which don't have it, this causes us to define our version */ #undef DEFINE_STRSEP /* Allow the use of DNS names in the socks configuration file for socks servers. This doesn't work if socksified DNS is enabled for obvious reasons, it also introduces overhead, but people seem to want it */ #define HOSTNAMES 0 /* We need the gethostbyname() function to do dns lookups in tsocks or in inspectsocks */ #undef HAVE_GETHOSTBYNAME /* Location of configuration file (typically /etc/tsocks.conf) */ #undef CONF_FILE tsocks-1.8beta5/validateconf.c0000644000000000000000000001605411620231375013310 0ustar /* VALIDATECONF - Part of the tsocks package This utility can be used to validate the tsocks.conf configuration file Copyright (C) 2000 Shaun Clowes This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Global configuration variables */ char *progname = "validateconf"; /* Name for error msgs */ /* Header Files */ #include #include #include #include #include #include #include #include #include #include #include #include void show_server(struct parsedfile *, struct serverent *, int); void show_conf(struct parsedfile *config); void test_host(struct parsedfile *config, char *); int main(int argc, char *argv[]) { char *usage = "Usage: [-f conf file] [-t hostname/ip[:port]]"; char *filename = NULL; char *testhost = NULL; struct parsedfile config; int i; if ((argc > 5) || (((argc - 1) % 2) != 0)) { show_msg(MSGERR, "Invalid number of arguments\n"); show_msg(MSGERR, "%s\n", usage); exit(1); } for (i = 1; i < argc; i = i + 2) { if (!strcmp(argv[i], "-f")) { filename = argv[(i + 1)]; } else if (!strcmp(argv[i], "-t")) { testhost = argv[(i + 1)]; } else { show_msg(MSGERR, "Unknown option %s\n", argv[i]); show_msg(MSGERR, "%s\n", usage); exit(1); } } if (!filename) filename = strdup(CONF_FILE); printf("Reading configuration file %s...\n", filename); if (read_config(filename, &config) == 0) printf("... Read complete\n\n"); else exit(1); /* If they specified a test host, test it, otherwise */ /* dump the configuration */ if (!testhost) show_conf(&config); else test_host(&config, testhost); return(0); } void test_host(struct parsedfile *config, char *host) { struct in_addr hostaddr; struct serverent *path; char *hostname, *port; char separator; unsigned long portno = 0; /* See if a port has been specified */ hostname = strsplit(&separator, &host, ": \t\n"); if (separator == ':') { port = strsplit(NULL, &host, " \t\n"); if (port) portno = strtol(port, NULL, 0); } /* First resolve the host to an ip */ if ((hostaddr.s_addr = resolve_ip(hostname, 0, 1)) == -1) { fprintf(stderr, "Error: Cannot resolve %s\n", host); return; } else { printf("Finding path for %s...\n", inet_ntoa(hostaddr)); if (!(is_local(config, &(hostaddr)))) { printf("Path is local\n"); } else { pick_server(config, &path, &hostaddr, portno); if (path == &(config->defaultserver)) { printf("Path is via default server:\n"); show_server(config, path, 1); } else { printf("Host is reached via this path:\n"); show_server(config, path, 0); } } } return; } void show_conf(struct parsedfile *config) { struct netent *net; struct serverent *server; /* Show the local networks */ printf("=== Local networks (no socks server needed) ===\n"); net = (config->localnets); while (net != NULL) { printf("Network: %15s ", inet_ntoa(net->localip)); printf("NetMask: %15s\n", inet_ntoa(net->localnet)); net = net->next; } printf("\n"); /* If we have a default server configuration show it */ printf("=== Default Server Configuration ===\n"); if ((config->defaultserver).address != NULL) { show_server(config, &(config->defaultserver), 1); } else { printf("No default server specified, this is rarely a " "good idea\n"); } printf("\n"); /* Now show paths */ if ((config->paths) != NULL) { server = (config->paths); while (server != NULL) { printf("=== Path (line no %d in configuration file)" " ===\n", server->lineno); show_server(config, server, 0); printf("\n"); server = server->next; } } return; } void show_server(struct parsedfile *config, struct serverent *server, int def) { struct in_addr res; struct netent *net; /* Show address */ if (server->address != NULL) printf("Server: %s (%s)\n", server->address, ((res.s_addr = resolve_ip(server->address, 0, HOSTNAMES)) == -1 ? "Invalid!" : inet_ntoa(res))); else printf("Server: ERROR! None specified\n"); /* Check the server is on a local net */ if ((server->address != NULL) && (res.s_addr != -1) && (is_local(config, &res))) fprintf(stderr, "Error: Server is not on a network " "specified as local\n"); /* Show port */ printf("Port: %d\n", server->port); /* Show SOCKS type */ printf("SOCKS type: %d\n", server->type); /* Show default username and password info */ if (server->type == 5) { /* Show the default user info */ printf("Default user: %s\n", (server->defuser == NULL) ? "Not Specified" : server->defuser); printf("Default pass: %s\n", (server->defpass == NULL) ? "Not Specified" : "******** (Hidden)"); if ((server->defuser == NULL) && (server->defpass != NULL)) fprintf(stderr, "Error: Default user must be specified " "if default pass is specified\n"); } else { if (server->defuser) printf("Default user: %s\n", server->defuser); if (server->defpass) printf("Default pass: %s\n", server->defpass); if ((server->defuser != NULL) || (server->defpass != NULL)) fprintf(stderr, "Error: Default user and password " "may only be specified for version 5 " "servers\n"); } /* If this is the default servers and it has reachnets, thats stupid */ if (def) { if (server->reachnets != NULL) { fprintf(stderr, "Error: The default server has " "specified networks it can reach (reach statements), " "these statements are ignored since the " "default server will be tried for any network " "which is not specified in a reach statement " "for other servers\n"); } } else if (server->reachnets == NULL) { fprintf(stderr, "Error: No reach statements specified for " "server, this server will never be used\n"); } else { printf("This server can be used to reach:\n"); net = server->reachnets; while (net != NULL) { printf("Network: %15s ", inet_ntoa(net->localip)); printf("NetMask: %15s ", inet_ntoa(net->localnet)); if (net->startport) printf("Ports: %5lu - %5lu", net->startport, net->endport); printf("\n"); net = net->next; } } } tsocks-1.8beta5/config.h.in0000644000000000000000000000476011642034445012534 0ustar /* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Allow tsocks to generate messages to stderr when errors are encountered, this is really important and should only be disabled if you're REALLY sure. It can also be turned off at run time, see the man page for details */ #undef ALLOW_MSG_OUTPUT /* Allow TSOCKS_CONF_FILE in environment to specify config file location */ #undef ALLOW_ENV_CONFIG /* Use _GNU_SOURCE to define RTLD_NEXT, mostly for RH7 systems */ #undef USE_GNU_SOURCE /* dlopen() the old libc to get connect() instead of RTLD_NEXT, hopefully shouldn't be needed */ #undef USE_OLD_DLSYM /* path to library containing connect(), needed if USE_OLD_DLSYM is enabled */ #undef LIBCONNECT /* path to libc, needed if USE_OLD_DLSYM is enabled */ #undef LIBC /* Configure the system resolver to use TCP queries on startup, this allows socksified DNS */ #undef USE_SOCKS_DNS /* Prototype and function header for connect function */ #undef CONNECT_SIGNATURE /* The type of socket structure pointer to use to call the * real connect */ #undef CONNECT_SOCKARG /* Prototype and function header for select function */ #undef SELECT_SIGNATURE /* Prototype and function header for poll function */ #undef POLL_SIGNATURE /* Prototype and function header for close function */ #undef CLOSE_SIGNATURE /* Work out which function we have for conversion from string IPs to numerical ones */ #undef HAVE_INET_ADDR #undef HAVE_INET_ATON /* Allow the use of DNS names in the socks configuration file for socks servers. This doesn't work if socksified DNS is enabled for obvious reasons, it also introduces overhead, but people seem to want it */ #define HOSTNAMES 0 /* We need the gethostbyname() function to do dns lookups in tsocks or in inspectsocks */ #undef HAVE_GETHOSTBYNAME /* Location of configuration file (typically /etc/tsocks.conf) */ #undef CONF_FILE /* Define if you have the strcspn function. */ #undef HAVE_STRCSPN /* Define if you have the strdup function. */ #undef HAVE_STRDUP /* Define if you have the strerror function. */ #undef HAVE_STRERROR /* Define if you have the strspn function. */ #undef HAVE_STRSPN /* Define if you have the strtol function. */ #undef HAVE_STRTOL /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Define if you have the dl library (-ldl). */ #undef HAVE_LIBDL /* Define if you have the socket library (-lsocket). */ #undef HAVE_LIBSOCKET tsocks-1.8beta5/tsocks.conf.simple.example0000644000000000000000000000120411620231375015573 0ustar # This is the configuration for libtsocks (transparent socks) # Lines beginning with # and blank lines are ignored # # This sample configuration shows the simplest (and most common) use of # tsocks. This is a basic LAN, this machine can access anything on the # local ethernet (192.168.0.*) but anything else has to use the SOCKS version # 4 server on the firewall. Further details can be found in the man pages, # tsocks(8) and tsocks.conf(5) and a more complex example is presented in # tsocks.conf.complex.example # We can access 192.168.0.* directly local = 192.168.0.0/255.255.255.0 # Otherwise we use the server server = 192.168.0.1 tsocks-1.8beta5/tsocks.10000644000000000000000000000264211620231375012073 0ustar .TH TSOCKS 1 "" "TSOCKS" .SH NAME .BR tsocks \- Shell wrapper to simplify the use of the tsocks(8) library to transparently allow an application to use a SOCKS proxy .SH SYNOPSIS .B tsocks .RB [application\ [application's\ arguments]] .br or .B tsocks .RB [on|off] .br or .B tsocks .SH DESCRIPTION .B tsocks is a wrapper between the tsocks library and the application what you would like to run socksified. .SH OPTIONS .IP \fB[application\ \fB[application's\ arguments]] run the application as specified with the environment (LD_PRELOAD) set such that tsocks(8) will transparently proxy SOCKS connections in that program .IP \fB[on|off] this option adds or removes tsocks(8) from the LD_PRELOAD environment variable. When tsocks(8) is in this variable all executed applications are automatically socksified. If you want to use this function, you HAVE to source the shell script from yours, like this: "source /usr/bin/tsocks" or ". /usr/bin/tsocks" .br Example: .br ". tsocks on" -- add the tsocks lib to LD_PRELOAD .br ". tsocks off" -- remove the tsocks lib from LD_PRELOAD .IP \fB[show|sh] show the current value of the LD_PRELOAD variable .IP \fB create a new shell with LD_PRELOAD including tsocks(8). .PP .SH AUTHOR This script was created by Tamas SZERB for the debian package of tsocks. It (along with this manual page) have since been adapted into the main tsocks project and modified.