I have a webserver that also plays internet radio. As www-data user I want to run some commands, for example I've made this in /etc/sudoers file:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer
And form PHP I can manipulate volume without using password by:
exec('sudo -u user amixer set Master 3%-');
And:
exec('sudo -u user amixer set Master 3%+');
But now I want to be able to restart my own service by runing command:
exec('sudo -u user service servicename restart');
So I tried:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer, NOPASSWD: /bin/service
And this:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer, /bin/service
And even this:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer
www-data ALL=(ALL) NOPASSWD: /bin/service
But none of them seems to be working. Please help me out.
Sorry guys - my mistake. I've done some changes, tried to link form /sbin to /bin
Now I have changed it to:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer, NOPASSWD: /usr/sbin/service
And it works! Thanks! Topic closed.