Tweak the implementation of proposal 109 slightly: allow at most
[tor.git] / contrib / torify.in
blob05645fd07ca352f3780ea5d9287082eb8a41b388
1 #! /bin/sh
3 # Wrapper script for use of the tsocks(8) transparent socksification library
4 # See the tsocks(1) and torify(1) manpages.
6 # Copyright (c) 2004, 2006 Peter Palfrader
7 # Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
8 # May be distributed under the same terms as Tor itself
11 # Define and ensure we have tsocks
12 # XXX: what if we don't have which?
13 TSOCKS="`which tsocks`"
14 if [ ! -x "$TSOCKS" ]
15 then
16 echo "$0: Can't find tsocks in PATH. Perhaps you haven't installed it?" >&2
17 exit 1
20 # Check for any argument list
21 if [ "$#" = 0 ]
22 then
23 echo "Usage: $0 <command> [<options>...]" >&2
24 exit 1
26 if [ "$#" = 1 ] && ( [ "$1" = "-h" ] || [ "$1" = "--help" ] )
27 then
28 echo "Usage: $0 <command> [<options>...]"
29 exit 0
32 # Define our tsocks config file
33 TSOCKS_CONF_FILE="@CONFDIR@/tor-tsocks.conf"
34 export TSOCKS_CONF_FILE
36 # Check that we've got a tsocks config file
37 if [ -r "$TSOCKS_CONF_FILE" ]
38 then
39 exec tsocks "$@"
40 echo "$0: Failed to exec tsocks $@" >&2
41 exit 1
42 else
43 echo "$0: Missing tsocks configuration file \"$TSOCKS_CONF_FILE\"." >&2
44 exit 1