2006-04-17 00:48:41 +02:00
|
|
|
#! /bin/sh
|
2006-04-17 04:46:14 +02:00
|
|
|
|
2012-03-28 00:43:18 +02:00
|
|
|
# This script used to call (the now deprecated) tsocks as a fallback in case
|
|
|
|
# torsocks wasn't installed.
|
|
|
|
# Now, it's just a backwards compatible shim around torsocks with reasonable
|
|
|
|
# behavior if -v/--verbose or -h/--help arguments are passed.
|
|
|
|
#
|
2009-09-09 21:33:32 +02:00
|
|
|
# Copyright (c) 2004, 2006, 2009 Peter Palfrader
|
2006-04-17 00:44:08 +02:00
|
|
|
# Modified by Jacob Appelbaum <jacob@appelbaum.net> April 16th 2006
|
2012-03-28 00:43:18 +02:00
|
|
|
# Stripped of all the tsocks cruft by ugh on February 22nd 2012
|
2006-04-17 04:46:14 +02:00
|
|
|
# May be distributed under the same terms as Tor itself
|
|
|
|
|
2006-04-17 00:44:08 +02:00
|
|
|
|
2012-03-28 00:43:18 +02:00
|
|
|
compat() {
|
|
|
|
echo "torify is now just a wrapper around torsocks(1) for backwards compatibility."
|
|
|
|
}
|
2009-09-09 21:33:32 +02:00
|
|
|
|
2012-03-28 00:43:18 +02:00
|
|
|
usage() {
|
|
|
|
compat
|
2009-04-29 23:35:06 +02:00
|
|
|
echo "Usage: $0 [-hv] <command> [<options>...]"
|
2012-03-28 00:43:18 +02:00
|
|
|
}
|
2009-09-09 21:33:32 +02:00
|
|
|
|
2012-03-28 00:43:18 +02:00
|
|
|
case $# in 0)
|
|
|
|
usage >&2
|
2009-09-09 21:33:32 +02:00
|
|
|
exit 1
|
2012-03-28 00:43:18 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
case $# in 1)
|
|
|
|
case $1 in -h|--help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $1 in -v|--verbose)
|
|
|
|
compat >&2
|
|
|
|
shift
|
|
|
|
esac
|
|
|
|
|
2012-03-28 00:46:47 +02:00
|
|
|
# taken from Debian's Developer's Reference, 6.4
|
|
|
|
pathfind() {
|
|
|
|
OLDIFS="$IFS"
|
|
|
|
IFS=:
|
|
|
|
for p in $PATH; do
|
|
|
|
if [ -x "$p/$*" ]; then
|
|
|
|
IFS="$OLDIFS"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$OLDIFS"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if pathfind torsocks; then
|
|
|
|
exec torsocks "$@"
|
|
|
|
echo "$0: Failed to exec torsocks $@" >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "$0: torsocks not found in your PATH. Perhaps it isn't installed? (tsocks is no longer supported, for security reasons.)" >&2
|
|
|
|
fi
|
|
|
|
|