Granting privileges using visudo still prevents user to execute command
Following this solution, I want to grant to the user
daemon the execution of
Here what I did:
find the user that
apache2uses when spawning:
# ps | grep httpd 252 root /usr/bin/httpd -k start 260 daemon /usr/bin/httpd -k start 262 daemon /usr/bin/httpd -k start 264 daemon /usr/bin/httpd -k start 467 root grep httpd
find the right path for
# which date /bin/date
visudoadd the following lines:
Cmnd_Alias DATE=/bin/date daemon ALL=NOPASSWD: DATE
test the new privileges:
# sudo -u daemon date -s "2023-09-09 10:16:00" date: can't set date: Operation not permitted Sat Sep 9 10:16:00 UTC 2023
Is there anything wrong in my syntax?
I also tried with:
ALL ALL=NOPASSWD: DATE
but it’s the same.
It’s a Buildroot environment.
You need to specify the exact path matching the
sudoers configuration. Your test is also back to front: starting from root, you need to become
daemon, then try to run
sudo -u daemon sudo /bin/date -s "2023-09-09 10:16:00"
(Your current test tries to run
date as the
daemon user, which won’t work.)