I want to give one of the web developers testuser permission to set his own .htpasswd password using the /usr/bin/htpasswd command on the web server 'mywebserver'.
The web server tree belongs to the wwwadmin user, who therefore owns the .htpasswd file in the web root and is able to run htpasswd routinely.
In my understanding of sudo the next line in /etc/sudoers of the web server (stock Apache, CentOS 6) should do the job:
testuser mywebserver=(wwwadmin) /usr/bin/htpasswd
The truth is that whenever the user testuser runs:
sudo /usr/bin/htpasswd .htpasswd someusername
the command is rejected with:
[sudo] password for testuser:
Sorry, user testuser is not allowed to execute '/usr/bin/htpasswd' as root on mywebsever.mydomain.com.
The log /var/log/secure shows:
Apr 1 17:13:51 mywebserver sudo: testuser : command not allowed ; TTY=pts/2 ; PWD=/var/www/html ; USER=root ; COMMAND=/usr/bin/htpasswd .htpasswd someusername
I'm baffled an have spent hours digging here and elsewhere on hints on why this happens (and why is root mentioned as user instead of wwwadmin).
Any clues would be appreciated!