Universal Global Variables for Socksing
![](https://seccdn.libravatar.org/avatar/9043fd5e7e99d6eca398fccf8464742e.jpg?s=120&d=mm&r=g)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 . Hello list, I am setting up to Socks through a firewall. To do this I need to set two environment variables and run a daemon. The daemon will then capture every connect() from any process and route it properly. Problem is, I need to turn this on and off dynamically. When I run my script, the env variables are exported, and thus are only visible in processes started *after* invocation. But I need them to be visible to EXISTING processes as well, and they are not. If I set these on startup, all processes do see them, but not when I turn off the variables. So, no dynamic control. I'm hoping there are uber-variables, or a variable area that *existing* processes would see when one is added. Can someone advise? #! /bin/sh # # Author: Carl Cook # # /usr/_utilities/runBouncer # ### BEGIN INIT INFO # Provides: bouncer # Required-Start: $network # Required-Stop: # Default-Start: 3 5 # Default-Stop: # Description: Tool for Socks proxying. ### END INIT INFO . /etc/rc.status . /etc/rc.config # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Set variables. LOGFILE=/var/log/bouncer.log PIDFILE=/var/run/bouncer.pid LD_PRELOAD=/usr/local/lib/sockscap.so SOCKS_PROXY=127.0.0.1:1080 # The echo return value for success (defined in /etc/rc.config). return=$rc_done case "$1" in start) echo -n "Starting service bouncer" ## Start daemon with startproc(8). If this fails ## the echo return value is set appropriate. /usr/_utilities/bouncer --allow 192.168.0.* --daemon --full-time --logfile $LOGFILE --pidfile $PIDFILE --port 1080 --socks5 export LD_PRELOAD SOCKS_PROXY echo $LD_PRELOAD $SOCKS_PROXY rc_status -v ;; stop) echo -n "Shutting down service bouncer" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. killproc -TERM /usr/_utilities/bouncer && unset LD_PRELOAD export SOCKS_PROXY= rc_status -v ;; restart|reload) $0 stop && $0 start rc_status ;; status) echo -n "Checking for service bouncer: " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. checkproc /usr/_utilities/bouncer rc_status -v ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit 0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8n9x4nQ18+PFcZJsRAvA1AJ4mgGoXbPsKNjF85TriJPrKbxqhfQCeMkef fdQFZDav+nrldWpTr0f9fEU= =4kgr -----END PGP SIGNATURE-----
participants (1)
-
Carl A. Cook