[bf1942] Failure to open ports
    ScratchMonkey 
    ScratchMonkey at SewingWitch.com
       
    Thu Jan  2 11:00:35 EST 2003
    
    
  
--On Thursday, January 02, 2003 9:01 AM -0600 "Rust, Robert" 
<RustRobert at stanleygroup.com> wrote:
> How about sharing the php code...that looks interesting..
Use the exec function. In the PHP file, you pass the service (eg. "bf1942") 
and operation (eg. "restart") as HTTP params and use something like this:
<?
$command = "/usr/bin/sudo /sbin/service " . $_GET['service'] . " " . 
$_GET['operation'];
print($command . "<br>");
exec($command, $sudo_command_array, $returnvar);
while (list ($key, $val) = each ($sudo_command_array)) {
        print($val . "<br>");
}
?>
You should first run the script arguments through a filter that limits them 
to alphanumerics, so a malicious user can't get the script to do something 
naughty with shell escapes.
In /etc/sudoers have something like this:
User_Alias      GAMESERVER = apache
GAMESERVER      ALL = (root) NOPASSWD: /sbin/service bf1942 *
This allows the PHP script to run the command to restart the game server.
    
    
More information about the Bf1942
mailing list