Run a script as root from apache
- by Lord Loh.
I would like to update my hosts file and restart dnsmasq from a web interface (php/apache2). I tried playing around with suid bits (the demonstaration). I have both apache and dnsmasq running on an EC2 instance.
I understand that Linux ignores the setuid bit on text scripts, but works on binary files. (Have I got something wrong?). I added exec("whoami"); to the example C program in Wikipedia. Although the effective UID of the C program is 0, whoami does not return root :-(
I would thoroughly like to avoid
echo password | sudo service dnsmasq restart
or adding apache to the sudoers without password! Is there a way out? How does webmin do such things?