I'm currently working on an appliance and trying to grant the user the possibility to restart the server which host it.
Would there be any way to give apache the right to do it ?
I've tried, when clicking on a submit button, to execute this code :
<?php exec('/sbin/reboot'); ?>
But it says that only root can do it.
So, I tried adding this in the sudoers file :
nobody ALL = NOPASSWD: /sbin/reboot
And I still got this error which prevent me from rebooting the server from PHP.
The role php is using is apache.
I've also tried using shutdown -r
now and got the same issue.
Would there be any way to do this ? I've seen several systems which allows that but I don't find how they do so...
Thanks.
Not really familiar with what you're doing, but I do notice this:
You say:
nobody ALL = NOPASSWD: /sbin/reboot
...
The role php is using is apache.
So shouldn't you say in sudoers file:
apache
ALL = NOPASSWD: /sbin/reboot