in reply to How to send server / shell command via cgi?

Here is what my sudoers file looks like

# /etc/sudoers

#

# This file MUST be edited with the 'visudo' command as root.

#

# See the man page for details on how to write a sudoers file.

#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification

root ALL=(ALL) ALL

www-data ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password

# (Note that later entries override this, so you might need to move

%www ALL=(ALL) NOPASSWD: ALL

www ALL=(ALL) NOPASSWD: ALL

www localhost=NOPASSWD: ALL

www www-data=NOPASSWD: ALL

%sudo ALL=NOPASSWD: ALL

  • Comment on Re: How to send server / shell command via cgi?

Replies are listed 'Best First'.
Re^2: How to send server / shell command via cgi?
by morgon (Priest) on May 20, 2009 at 14:42 UTC
    If you don't care about security ramifications you can just add
    http ALL=(ALL) NOPASSWD: ALL
    assuming http is the user-account your cgi-script runs under and then run the command in your cgi-script as
    system("sudo -u root <your_command>")
    It will then run as root and should not have permission problems.

    That should get you started for a more secure setup later.

    hth

      Thank you all for your help that last bit got it working!