torify.in 1.1 KB

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