[plug] Restarting ppp from a 'doze box

Leon Brooks leon at brooks.fdns.net
Thu Feb 6 23:18:15 WST 2003


On Thursday 06 February 2003 08:39 pm, Sacha Schlegel wrote:
>> I've got a Windoze box set up behind my firewall for my girlfriend to
>> use, and I want to allow her to start / restart / stop the ppp connection
>> on the firewall box from her machine.

> Now you have to make sure the the webserver can call the program pon.
> I use sudo (some say its not very secure but i did not care).

There is a simpler method: pipes. Caution: may contain typoes, completely 
untested.

mkfifo /var/spool/connectivity
chown root:apache /var/spool/connectivity
chmod 420 /var/spool/connectivity
cat <<BACKSTOP >/usr/local/bin/internet_slave.sh
#!/bin/sh
read </var/spool/connectivity
case X$REPLY in
Xdial)
    /usr/bin/pon myISP
    ;;
Xhangup)
    /usr/bin/poff
    ;;
esac
BACKSTOP
chmod a+x /usr/local/bin/internet_slave.sh
echo 'in:345:respawn:/usr/local/bin/internet_slave.sh' >>/etc/inittab
init q

Now all your PHP needs to do (no sudo needed) is open /var/spool/conectivity, 
write "dial\n" or "hangup\n" and close it. You get a log message if the 
script goes crazy, too (about respawning too fast) and a pause.

Cheers; Leon



More information about the plug mailing list