I have a script that executes several commands in a user's home directory. The files are owned by the user and Apache (the www-data group) only has read privileges to them. The script needs to be executed on demand by PHP via exec(), and performs some deletions / untarring of files, which fail since Apache doesn't have write permissions to the directories.
I've tried editing the sudoers file like this :
www-data ALL=(user) NOPASSWD: /bin/su user -c /home/user/bin/script.sh but it prompts me for the user's password
I've also tried
www-data ALL=(root) NOPASSWD: /usr/bin/sudo su user -c /home/user/bin/script.sh but that prompts for www-data's sudo password
How to I get this to work without a password ?