in reply to Executing Sudo Console via Web

A lot depends on how your server is configured. Are you using mod_suexec? If so, what have you set the CGI user to for your virtual host? Is that user given rights in the sudoers file? If not, what rights have you given the server user (e.g. apache) in the sudoers group? Without mod_suexec all scripts run with the rights of the server-wide CGI user (i.e. the user directive in your apache configuration file)

Do you have FollowSymLinks turned on? What is the <Directory> directive set to for /usr/bin, /usr/sbin? On a secure server you will probably have told Apache not to access those directories at all and following symbolic links is probably turned off as well.

In general, exercising sensitive root level commands through a web interface is a really bad idea security wise. To implement it you would have to violate a key security principle: give services only the rights they need to run and no more. Most of the changes you would have to make would also make your server in general wide open to attack. For example, adding apache to sudoers with ALL rights would essentially let anyone who hacked into your server account also be able to root your entire machine. Knowing the password for the apache user would be enough to run any script for which the apache user had sudoer rights.

And if you've hard coded the password in the script (your code looks like you have) or turned off the password requirement in the sudoer's file because prompting for it got in the way of your CGI script, you'll have even more problems. Even if you were using mod_suexec anyone with rights to install and run CGI scripts for that particular virtual host would share your root privileges with you!

Even if it is a pain, you are still better off doing your root level administration via an ssh connection rather than the web interface. You have much more control over who gets what rights that way.

If you really must do web based root level administration, you would be better off

But again, I still think this is a really bad idea. Use ssh, preferrably on an account with PPK only access.

Best, beth

Update: added comments about mod_pam