PDA

Bekijk de volledige versie : Running PHP system command as admin



pfugl
18-11-2005, 13:21
I am trying to run the following PHP script:


<?php
$retval = 100;
if ( ( !isset( $_SERVER[PHP_AUTH_USER] )) || (!isset ($_SERVER[PHP_AUTH_PW]))
|| ( $_SERVER[PHP_AUTH_USER] != 'admin' ) || ( $_SERVER[PHP_AUTH_PW] != 'password' ) ) {

header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;

} else {

$last_line = system("/opt/share/www/power/ether-wake -D -i br0 00:11:55:f5:39:7f",$retval);

// Printing additional info
echo '
</pre>
<hr />WOL command has been submitted: ' . $last_line . '
<hr />Return value: ' . $retval;


}
?>

However the SYSTEM command ether-wake fails to run if the THTTPD server is running under user nobody. If it is started under admin user, it works. However for security reasons I do not want to have it running under admin.
Is there a way to run the SYSTEM command under admin user even when thttpd is runining under nobody?