Running Fedora 9/10, Apache 2, PHP 5...
Can I run a shell script as root, from a PHP script using exec()?
Do I just give Apache root priveleges, and then add
Don't run Apache as root
. Apache has been designed to cope very well with starting as root
and then dropping its privileges just as soon as it can
Don't use sudo
within your script either - it'll be too easy to end up with sudo
misconfigured such that any script running on your server gets to run any program it likes with root
privileges
Look at making your own program run "setuid", so that it gets root privileges, but then drops them (just like Apache does) when it doesn't need them any more
Make sure your "setuid" executable can't be run by anybody who isn't supposed to be able to run it.