You are not logged in.

#1 2010-04-11 15:06:22

murfMan
Member
Registered: 2009-10-27
Posts: 161

SOLVED: php shell_exec() run command as root?

is there a way for me to execute a command as root from the php shell_exec() command?  I am trying to create a simple web interface for my phone to preform simple server operations such as restart deamons. 

in my php file im calling
$output = shell_exec('/path/to/my/script.py');

my script will do a /etc/rc.d/insert_daemon restart so it needs to be ran as root

I have tried to add
nobody=ALL :/path/to/my/script.py   
to my sudoers file.  i have also tried using
chmod 4755 script.py
chown root   script.py
on the script.  nothing seems to work for me. 

I realize this is probably a security risk.  anyone have any suggestions?

Last edited by murfMan (2010-04-11 17:09:48)

Offline

#2 2010-04-11 17:09:35

murfMan
Member
Registered: 2009-10-27
Posts: 161

Re: SOLVED: php shell_exec() run command as root?

solved it:

added
http ALL=NOPASSWD :/path/to/script.py
to sudoers

Last edited by murfMan (2010-04-11 17:13:43)

Offline

Board footer

Powered by FluxBB