note 71466 added to function.system
| From: | bespoleznyak | Date: | Thu, 30 Nov 2006 08:43:23 +0000 |
| Subject: | note 71466 added to function.system | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120180@lists.php.net to get a copy of this message | ||
run programm as super-user (*nix):
<?php
function sudoExecute($command)
{
$tmp = array();
preg_match('/^([^ ]+?)( |$)/', trim($command), $tmp);
$command_to_execute = $tmp[1];
$sudo_output =
sudo -l;
preg_match_all('/ (\/[\w\/]+?)(,|$)/', $sudo_output, $tmp);
if (count($tmp) > 1) {
$allowed_commands = $tmp[1];
if (array_search($command_to_execute, $allowed_commands) === false) {
return false;
}
} else {
return false;
}
return system("/usr/local/bin/sudo $command 2>&1");
}
?>
----
Server IP: 195.54.192.44
Probable Submitter: 195.128.50.89
----
Manual Page -- http://www.php.net/manual/en/function.system.php
Edit -- https://master.php.net/note/edit/71466
Del: integrated -- https://master.php.net/note/delete/71466/integrated
Del: useless -- https://master.php.net/note/delete/71466/useless
Del: bad code -- https://master.php.net/note/delete/71466/bad+code
Del: spam -- https://master.php.net/note/delete/71466/spam
Del: non-english -- https://master.php.net/note/delete/71466/non-english
Del: in docs -- https://master.php.net/note/delete/71466/in+docs
Del: other reasons-- https://master.php.net/note/delete/71466
Reject -- https://master.php.net/note/reject/71466
Search -- https://master.php.net/manage/user-notes.php