home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / torify < prev    next >
Encoding:
Text File  |  2012-11-20  |  1.3 KB  |  62 lines

  1. #! /bin/sh
  2.  
  3. # This script used to call (the now deprecated) tsocks as a fallback in case
  4. # torsocks wasn't installed.
  5. # Now, it's just a backwards compatible shim around torsocks with reasonable
  6. # behavior if -v/--verbose or -h/--help arguments are passed.
  7. #
  8. # Copyright (c) 2004, 2006, 2009 Peter Palfrader
  9. # Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
  10. # Stripped of all the tsocks cruft by ugh on February 22nd 2012
  11. # May be distributed under the same terms as Tor itself
  12.  
  13.  
  14. compat() {
  15.     echo "torify is now just a wrapper around torsocks(1) for backwards compatibility."
  16. }
  17.  
  18. usage() {
  19.     compat
  20.     echo "Usage: $0 [-hv] <command> [<options>...]"
  21. }
  22.  
  23. case $# in 0)
  24.     usage >&2
  25.     exit 1
  26. esac
  27.  
  28. case $# in 1)
  29.     case $1 in -h|--help)
  30.         usage
  31.         exit 0
  32.     esac
  33. esac
  34.  
  35. case $1 in -v|--verbose)
  36.     compat >&2
  37.     shift
  38. esac
  39.  
  40. # taken from Debian's Developer's Reference, 6.4
  41. pathfind() {
  42.        OLDIFS="$IFS"
  43.        IFS=:
  44.        for p in $PATH; do
  45.                if [ -x "$p/$*" ]; then
  46.                        IFS="$OLDIFS"
  47.                        return 0
  48.                fi
  49.        done
  50.        IFS="$OLDIFS"
  51.        return 1
  52. }
  53.  
  54. if pathfind torsocks; then
  55.     exec torsocks "$@"
  56.     echo "$0: Failed to exec torsocks $@" >&2
  57.     exit 1
  58. else
  59.     echo "$0: torsocks not found in your PATH.  Perhaps it isn't installed?  (tsocks is no longer supported, for security reasons.)" >&2
  60. fi
  61.  
  62.