I have a program that runs as a normal user but sometimes needs to run a command that requires root privileges. So I made a shell script and gave the user permission to run that script with sudo.
The script is executed successfully when I run the program from the shell but fails when running as a service. Sudo exits with this error:
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with
the 'nosuid' option set or an NFS file system without root privileges?0
This is the unit file for the service, this is the script and in sudoers
I have added
user ALL = (root) NOPASSWD: /path/to/script
I have no idea why. Sudo works fine and the permissions for /usr/bin
and /usr/bin/sudo
are correct.