I am running the following command line:
myuser@server:/var/www/html/folder/htdocs$ php remove.php
myuser is not in the sudoers file. This incident will be reported.
Within remove.php I run:
exec('sudo -u myuser /usr/bin/wipe '.$main_path.$base.' -f -c -s');
And I've set my sudoers file:
www-data ALL=(myuser) NOPASSWD: ALL
And I've set sudoers to 0440:
-r--r----- 1 root root 838 Sep 18 11:07 sudoers
Why am I told that myuser
isn't in the sudoers file when it is?
sudo adduser yourusername sudo
. You have to do this from a user that already has sudo privilege. – Nmath Sep 18 '20 at 10:29sudo -u myuser /usr/bin/wipe
and its erroring too - same error – Antony Sep 18 '20 at 10:37usermod -aG sudo myuser
and a reboot did the fix :) thanks – Antony Sep 18 '20 at 10:52www-data ALL=(myuser) NOPASSWD: ALL
allows userwww-data
to executesudo -u myuser somecommand
- it does not allowmyuser
to executesudo
themself. See for example Trying to understand the difference between “modernNeo ALL=(ALL:ALL) ALL” and “modernNeo ALL=(ALL) ALL” in the sudoers file – steeldriver Sep 18 '20 at 11:19