0
I need to execute a script via php (php5.xx), server running apache2 (Ubuntu 10.04). The script needs to be executed as another user.
I added following lines to /etc/sudoers
file:
Cmnd_Alias SECURE_SVN_UPDATE = /path_to_script/just_svn_update.sh
#www-data ALL=(ALL,!root,!#0) NOPASSWD: SECURE_SVN_UPDATE
www-data ALL=(ALL) NOPASSWD: SECURE_SVN_UPDATE
(I tried both lines)
And in PHP, I call
exec("sudo -u theuser SECURE_SVN_UPDATE")
I get the error
sudo: no tty present and no askpass program specified
I tried setting
Defaults visiblepw
in the sudoers
file, but after that, running the command from PHP gives error:
sudo: 3 incorrect password attempts
.
Can someone please tell me how to fix this OR a method to achieve it without compromising security. (I want apache to be able to execute just that script as another user, nothing else).