Results 1 to 6 of 6

Thread: Run perlscript with sudo permissions through phpscript

  1. #1
    Join Date
    Apr 2007
    Location
    Behind my Lappie
    Beans
    114
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Run perlscript with sudo permissions through phpscript

    Hi there

    I'm trying to set up a php-script that calls a perl-script with sudo permissions (the perl-script needs these permissions to run its commands).

    This php-script is hosted on a LAMP apache server (in Ubuntu) and is run by the user www-data (pseudouser created by apache).
    I have tried adding the line:
    Code:
    www-data ALL=(ALL) NOPASSWD:ALL
    But it doesn't seem to work and it seems like somewhat of a security issue.

    How can I do this?
    Thanks in advance
    Last edited by Eax.exe; March 3rd, 2010 at 09:24 PM.
    "Freedom is an illusion"

  2. #2
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Run perlscript with sudo permissions through phpscript

    Make the perl script SUID root and use perl-suid to run it.
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  3. #3
    Join Date
    Apr 2007
    Location
    Behind my Lappie
    Beans
    114
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Run perlscript with sudo permissions through phpscript

    Quote Originally Posted by diesch View Post
    Make the perl script SUID root and use perl-suid to run it.
    Can you explain how please?
    "Freedom is an illusion"

  4. #4
    Join Date
    Apr 2007
    Location
    Behind my Lappie
    Beans
    114
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Run perlscript with sudo permissions through phpscript

    I installed the package "super" containing "setuid" but I have no idea how to use it :/
    "Freedom is an illusion"

  5. #5
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Run perlscript with sudo permissions through phpscript

    1. install the package perl-suid
    2. make root the owner and www-data the group of the file:
    Code:
    sudo chown:www-data root your_perl_script
    3. set the SUID bit, read and exec permissions for the group, no permisions for others:
    Code:
    sudo chmod u+s,g=rx,o-rwx your_perl_scrip
    4. In the first line of the script replace perl with suidperl
    e.g. change
    Code:
    #!/usr/bin/perl -w
    to
    Code:
    #!/usr/bin/suidperl -w
    Now if you run the script it's running as root.

    Be careful as
    everyone in the www-data group can run this script as root!
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  6. #6
    Join Date
    Apr 2007
    Location
    Behind my Lappie
    Beans
    114
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Run perlscript with sudo permissions through phpscript

    Quote Originally Posted by diesch View Post
    1. install the package perl-suid
    2. make root the owner and www-data the group of the file:
    Code:
    sudo chown:www-data root your_perl_script
    3. set the SUID bit, read and exec permissions for the group, no permisions for others:
    Code:
    sudo chmod u+s,g=rx,o-rwx your_perl_scrip
    4. In the first line of the script replace perl with suidperl
    e.g. change
    Code:
    #!/usr/bin/perl -w
    to
    Code:
    #!/usr/bin/suidperl -w
    Now if you run the script it's running as root.

    Be careful as
    everyone in the www-data group can run this script as root!
    Thank you so so much
    "Freedom is an illusion"

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •