-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtnat64.in
executable file
·89 lines (84 loc) · 2.14 KB
/
tnat64.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# Wrapper script for use of the tnat64(8) library
#
# There are three forms of usage for this script:
#
# @bindir@/tnat64 program [program arguments...]
#
# This form sets the users LD_PRELOAD environment variable so that tsocks(8)
# will be loaded to socksify the application then executes the specified
# program (with the provided arguments). The following simple example might
# be used to telnet to www.foo.org via a tnat64.conf(5) configured socks server:
#
# @bindir@/tnat64 telnet www.foo.org
#
# The second form allows for tnat64(8) to be switched on and off for a
# session (that is, it adds and removes tnat64 from the LD_PRELOAD environment
# variable). This form must be _sourced_ into the user's existing session
# (and will only work with bourne shell users):
#
# . @bindir@/tnat64 on
# telnet www.foo.org
# . @bindir@/tnat64 off
#
# Or
#
# source @bindir@/tnat64 on
# telnet www.foo.org
# source @bindir@/tnat64 off
#
# The third form creates a new shell with LD_PRELOAD set and is achieved
# simply by running the script with no arguments
#
# @bindir@/tnat64
#
# When finished the user can simply terminate the shell with 'exit'
#
# This script is originally from the debian tsocks package by
# Tamas Szerb <toma@rulez.org>
if [ $# = 0 ] ; then
echo "$0: insufficient arguments"
exit
fi
case "$1" in
on)
if [ -z "$LD_PRELOAD" ]
then
export LD_PRELOAD="@pkglibdir@/libtnat64.so"
else
echo $LD_PRELOAD | grep -q "@pkglibdir@/libtnat64\.so" || \
export LD_PRELOAD="@pkglibdir@/libtnat64.so $LD_PRELOAD"
fi
;;
off)
export LD_PRELOAD=$(echo -n $LD_PRELOAD | sed 's:@pkglibdir@/libtnat64.so \?::')
if [ -z "$LD_PRELOAD" ]
then
unset LD_PRELOAD
fi
;;
show|sh)
echo "LD_PRELOAD=\"$LD_PRELOAD\""
;;
-h|-?)
echo "$0: Please see tnat64(1) or read comment at top of $0"
;;
*)
if [ -z "$LD_PRELOAD" ]
then
export LD_PRELOAD="@pkglibdir@/libtnat64.so"
else
echo $LD_PRELOAD | grep -q "@pkglibdir@/libtnat64\.so" || \
export LD_PRELOAD="@pkglibdir@/libtnat64.so $LD_PRELOAD"
fi
if [ $# = 0 ]
then
${SHELL:-/bin/sh}
fi
if [ $# -gt 0 ]
then
exec "$@"
fi
;;
esac
#EOF