TorK – anonymity manager for TDE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

114 lines
3.6 KiB

  1. #! /bin/sh
  2. # ***************************************************************************
  3. # * *
  4. # * Copyright (C) 2008-2011 Robert Hogan <robert@roberthogan.net> *
  5. # * *
  6. # * This program is free software; you can redistribute it and/or modify *
  7. # * it under the terms of the GNU General Public License as published by *
  8. # * the Free Software Foundation; either version 2 of the License, or *
  9. # * (at your option) any later version. *
  10. # * *
  11. # * This program is distributed in the hope that it will be useful, *
  12. # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. # * GNU General Public License for more details. *
  15. # * *
  16. # * You should have received a copy of the GNU General Public License *
  17. # * along with this program; if not, write to the *
  18. # * Free Software Foundation, Inc., *
  19. #* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  20. # ***************************************************************************
  21. # * *
  22. # * This is a modified version of a source file from the Tor project. *
  23. # * Original copyright notice from tsocks source file follows: *
  24. # ***************************************************************************
  25. # Wrapper script for use of the tsocks(8) transparent socksification library
  26. # See the tsocks(1) and torify(1) manpages.
  27. # Copyright (c) 2004, 2006 Peter Palfrader
  28. # Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
  29. # Modified by Marcus Griep <marcus@griep.us> June 16 2009
  30. # May be distributed under the same terms as Tor itself
  31. # Define and ensure we have tsocks
  32. # XXX: what if we don't have which?
  33. TORSOCKS="`which torsocks`"
  34. PROG=
  35. VERBOSE=
  36. usage () {
  37. echo "Usage: $0 [-hv] <command> [<options>...]"
  38. }
  39. not_found () {
  40. echo "ERROR: $1 cannot be found in PATH." >&2
  41. exit 1
  42. }
  43. set_id () {
  44. echo "ERROR: $1 is set${2}id. usewithtor will not work on a set${2}id executable." >&2
  45. exit 1
  46. }
  47. # Check for any argument list
  48. if [ "$#" = 0 ]; then
  49. usage >&2
  50. exit 1
  51. fi
  52. while [ "$1" ]; do
  53. case "$1" in
  54. -h|--h*)
  55. usage
  56. exit 0
  57. ;;
  58. -v|--v*)
  59. VERBOSE=YesPlease
  60. shift
  61. ;;
  62. *)
  63. break;
  64. esac
  65. done
  66. if ! which "$1" >/dev/null 2>&1; then
  67. not_found $1
  68. elif [ -u `which "$1"` ]; then
  69. set_id $1 u
  70. elif [ -g `which "$1"` ]; then
  71. set_id $1 g
  72. fi
  73. if [ -x "$TORSOCKS" ]; then
  74. PROG=torsocks
  75. else
  76. echo "$0: Unable to find torsocks in PATH." >&2
  77. echo " Perhaps you haven't installed it?" >&2
  78. exit 1
  79. fi
  80. if [ "$VERBOSE" ]; then
  81. echo "We're armed with the following torsocks: $TORSOCKS"
  82. echo "We're attempting to use $PROG for all tor action."
  83. fi
  84. if [ "$PROG" = "torsocks" ]; then
  85. # Define our torsocks config file
  86. TORSOCKS_CONF_FILE="/etc/torsocks.conf"
  87. export TORSOCKS_CONF_FILE
  88. # Check that we've got a torsocks config file
  89. if [ -r "$TORSOCKS_CONF_FILE" ]; then
  90. exec torsocks "$@"
  91. else
  92. echo "$0: Missing torsocks configuration file \"$TORSOCKS_CONF_FILE\" - torsocks will use defaults sensible for Tor." >&2
  93. exec torsocks "$@"
  94. fi
  95. fi
  96. # We should have hit an exec. If we get here, we didn't exec
  97. echo "$0: failed to exec $PROG $@" >&2
  98. exit 1