2015-10-09 19:41:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# usage:
|
|
|
|
# /usr/bin/intercept program <args>
|
|
|
|
|
|
|
|
if [ $# = 0 ] ; then
|
|
|
|
echo "$0: insufficient arguments"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
on)
|
|
|
|
if [ -z "$LD_PRELOAD" ]
|
|
|
|
then
|
2015-12-07 11:21:46 +00:00
|
|
|
export LD_PRELOAD="/lib/libzerotierintercept.so"
|
2015-10-09 19:41:16 +00:00
|
|
|
else
|
2015-12-07 11:21:46 +00:00
|
|
|
echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so" || \
|
2015-11-20 09:08:38 +00:00
|
|
|
export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
|
2015-10-09 19:41:16 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
off)
|
2015-12-07 11:21:46 +00:00
|
|
|
export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libzerotierintercept.so \?//'`
|
2015-10-09 19:41:16 +00:00
|
|
|
if [ -z "$LD_PRELOAD" ]
|
|
|
|
then
|
|
|
|
unset LD_PRELOAD
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
show|sh)
|
|
|
|
echo "LD_PRELOAD=\"$LD_PRELOAD\""
|
|
|
|
;;
|
|
|
|
-h|-?)
|
|
|
|
echo ""
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -z "$LD_PRELOAD" ]
|
|
|
|
then
|
2015-12-07 11:21:46 +00:00
|
|
|
export LD_PRELOAD="/lib/libzerotierintercept.so"
|
2015-10-09 19:41:16 +00:00
|
|
|
else
|
2015-12-07 11:21:46 +00:00
|
|
|
echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so" || \
|
|
|
|
export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
|
2015-10-09 19:41:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# = 0 ]
|
|
|
|
then
|
|
|
|
${SHELL:-/bin/sh}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]
|
|
|
|
then
|
|
|
|
exec "$@"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#EOF
|