rpmsafereduce: +$IGNORE_D,die->carp
[nethome.git] / bin / runsocks
1 #!/bin/sh
2 #
3 # Put the path to the socks shared library in our LD_LIBRARY_PATH so when we
4 # preload the library, ld.so will find it...
5 #
6 if test -n "${SOCKS5_SHLIB_RUNPATH}" ; then
7         SOCKS5_SHLIB_RUNPATH="${SOCKS5_SHLIB_RUNPATH}/"
8 elif test -n "/usr/local/lib"; then
9         SOCKS5_SHLIB_RUNPATH="/usr/local/lib/"
10 else 
11         SOCKS5_SHLIB_RUNPATH="./"
12 fi
13
14 #
15 # Some OS's use PRELOADS=lib while others use _RLD_LIST=lib:DEFAULT.  Hopefully 
16 # this can handle all those cases.  At any rate, this is basically causing the
17 # socks5 shared libary to be used to resolve symbols before other libraries,
18 # hence we get socks's connect before we get libc's connect...
19 #
20 # Also, on SunOS 4*, LD_LIBRARY_PATH has no effect on, so we need to put the path
21 # in front of it.  We make the path overridable with SOCKS5_SHLIB_RUNPATH...
22 #
23 case `uname -rs` in
24 SunOS*4.*)
25         LD_PRELOAD=${SOCKS5_SHLIB_RUNPATH}libsocks5_sh.so
26         export LD_PRELOAD
27         ;;
28 *)
29         if test -z "$LD_LIBRARY_PATH" ; then
30                 LD_LIBRARY_PATH=${SOCKS5_SHLIB_RUNPATH}
31         else
32                 LD_LIBRARY_PATH=${SOCKS5_SHLIB_RUNPATH}:${LD_LIBRARY_PATH}
33                 export LD_LIBRARY_PATH
34         fi
35
36         LD_PRELOAD=libsocks5_sh.so
37         export LD_LIBRARY_PATH
38         ;;
39 esac
40
41 # Run the actual program...
42 #
43 export LD_PRELOAD
44 exec "$@"