[plug] Restarting ppp from a 'doze box

Sacha Schlegel schlegel at cs.curtin.edu.au
Thu Feb 6 20:39:14 WST 2003


On Thu, 2003-02-06 at 19:55, Anthony Wilson wrote:
> Hey guys,
> 
> 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.
> 
> Anyone got some suggestions as to how I can go about this? (It needs to be a 
> point, click, bash PC with rock kind of solution ;)
> 

Hi I got the following solution:

Main-Webpage (index.php) on the server with php which looks like:

---------------------------------------------------------
<h2>Internet Connection</h2>
<form method="post" action="index.php">
<?
if($shutdown == "shutdown"){
  exec("sudo /usr/bin/poff");
}
elseif ($connect == "connect"){
  exec("/usr/bin/pon myISP");
  echo "Connecting ....... please wait";
}

sleep(1);

echo "Connection to Internet is :";

$prog = "pppd";
$id = exec("pidof $prog");

if($id != ""){
  echo " up (connected). ";
  echo "<input type=\"submit\" name=\"shutdown\" value=\"shutdown\">";
}
else{
  echo " down (not connectd). ";
  echo "<input type=\"submit\" name=\"connect\" value=\"connect\"";
}

  echo "<br><br><input type=\"submit\" name=\"refresh\"
value=\"Refresh\"";

?>

--------------------------------------------------------------

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).

So I did setup sudo. I edited (with the visudo command) the file
/etc/sudoers this way:

---------------------------------------------------------------

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
# Host alias specification

Host_Alias      OFFICE = 192.168.0.21

# User alias specification

User_Alias      WEBSERVER = nobody

# Cmnd alias specification

Cmnd_Alias      DIALIN = /usr/bin/pon '"myISP"'
Cmnd_Alias      OFFLINE = /usr/bin/poff

# User privilege specification

root    ALL=(ALL) ALL
WEBSERVER       OFFICE= NOPASSWD: DIALIN, OFFLINE

Defaults        mailto=root at 192.168.0.21

-----------------------------------------------------

So anybody can connect and disconnect via this web interface. Even I
connect this way now. It does not handle if your ISP is busy, then it
says connected :( ah nevermind.

Sacha


> cheers,
> Anthony
-- 
Sacha Schlegel <schlegel at cs.curtin.edu.au>



More information about the plug mailing list