Forum Moderators: coopster
nobody for obvious reasons. However, I need to be able to run certain system commands from within a PHP script. These commands require being run as root. Is there a way I can force root for these commands, or am I left with no other option than to add a script to the server crontab (for root) which runs constantly?
$result = shell_exec("echo YOUR_ROOT_PASSWORD ¦ sudo COMMAND_TO_RUN_AS_ROOT");
as has been mentioned, there are major security issues with this script, and i don't recommend using it.
For instance (DON'T DO THIS!):
In the groups section set up:
UADMIN: nobody
And in the actions sections set up:
UADMIN: ALL (ALL)
to let nobody do anything root could do (BAD IDEA!).
You might set up the actions like:
UADMIN: /etc/myscripts/root_script
which would allow "nobody" to run that program even though it is root's.
suidperl script... (Related thread: http://www.webmasterworld.com/forum13/3858.htm [webmasterworld.com]) First I was going to simply write a C wrapper and compile it.
...but I have no clue how to get the C program to use variables I pass as arguments, or how to set up a similar structure to that of my suidperl script in this thread [webmasterworld.com], or else I would.#include <unistd.h>
void main () {
execl("/usr/local/bin/perl","foo.pl","/local/web/cgi-bin/foo.pl",NULL);
}
sudo sounds interesting though... might take a closer look.