I want that a regular user to be able to execute apachectl in the system. And that would be the only thing that they can do outside of it normal permissions. What I did is to add this line at the bottom of the sudoers file:
sampleuser ALL=(root) NOEXEC:/usr/sbin/apachectl
So, as the user sampleuser, I executed apachectl
command, and I get this error:
sudo apachectl stop
[sudo] password for sampleuser:
/usr/sbin/apachectl: line 105: /usr/sbin/httpd: Permission denied
Now it seems like the permission is with the /usr/sbin/httpd command since apachectl
script calls that executable file. So I added another line to the sudoers file:
sampleuser ALL=(root) NOEXEC:/usr/sbin/httpd
Now I executed the same command and I get the same error:
sudo apachectl start
[sudo] password for sampleuser:
/usr/sbin/apachectl: line 105: /usr/sbin/httpd: Permission denied
My question now, is that if there's a fix for this without having to edit the apachectl script file or another method that probably is easier than what I'm trying to do.
Thank you.