Unable to change users on system () in php

My team

echo root_password | sudo -u root -S executable_full_path arguments

The error message I get in the browser is

[sudo] password for www data: Sorry, try again.

From phpinfo (), safe mode is turned off and there are no disabled features. Why is this not working? The same command works fine in the shell (bash). Escapeshellarg and escapeshellcmd do not matter.

EDIT: just executing a command is not enough. The executable program creates a socket in / tmp and it needs to be assigned permissions to it. So, I think I really need to be root for this, is this possible?

+3
source share
3 answers

As suggested by Alvaro, I put my comment as an answer. Matt, this will run this command as root.

@Matt, /etc/sudoers (btw, visudo, ). , , sudo whatever, -, root, , .

root , /etc/sudoers ( visudo):

www-data ALL=(ALL) NOPASSWD: executable_full_path

root.

sudo -u root executable_full_path arguments

( root). , , www- root, sudo, .

+3

root, www-data.

+3

/ets/sudoers gconftool-2:

www-data ALL=NOPASSWD: /usr/bin/gconftool-2
www-data ALL=NOPASSWD: /usr/bin/sudo
www-data ALL=NOPASSWD: ALL
0

All Articles