I want to give PHP access to a very specific script using a configuration under /etc/sudoers.d
.
So I did the following:
visudo -f /etc/sudoers.d/99-php
And entered this sudo rule:
www-data ALL = (root) NOPASSWD: /etc/my_script.sh
Inside the /etc/my_script.sh
script I create a folder and a few files under /tmp
before deleting them again.
To test:
su www-data
/etc/my_script.sh
This gives me a lot of permission errors like this:
rm: cannot remove «/tmp/my_file.txt»: Access denied
Suggesting that my script is not actually run as root at all.
So what can I do to get this working?