Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    20

    Default Need to run own scripts as root

    I have a need to run my own scripts with root permission but can't seem to make that
    happen. I have tried several ways and the scripts never have full root capability.
    To keep my server stable and secure I have a need to execute some commands as root
    through a browser (when I am not near my main computer).
    I know cPanel does it through their scripting so this is why I ask here.
    How may I set things up so I have an area through a browser (password protected of course)
    that I may execute perl scripts of mine that will have root permissions to do things on the server?
    Any help would be most appreciated.
    Thank you

  2. #2
    cPanel Partner NOC This forum account has been confirmed by cPanel staff to represent a vendor.cPanel Partner NOC Badge
    Join Date
    Nov 2001
    Location
    San Clemente, Ca
    Posts
    703

    Default

    If you run your scripts through the WHM they should run as root.

    otherwise you will have to write a wrapper in C and give it suid perms.. Be careful!
    Shaun Reitan
    NDCHost.com - cPlicensing.net - ProVPS.com
    Contact us for your cPanel Licensing needs! We Price Match, We provide Support, We take care of our customers!

  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    20

    Default

    If you could be so knid as to explain how to run through WHM. I would not know how to write the c wrapper, I can write only perl.
    Thank you again

  4. #4
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    Have a look through the existing scripts in /usr/local/cpanel/whostmgr/docroot/cgi/addon_* which should give you enough information.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  5. #5
    Member bamasbest's Avatar
    Join Date
    Jan 2004
    Posts
    531

    Default

    Chirpy is being a politically correct moderator by not mentioning something.

    Visit his site.

    For a whopping $15 bucks you can purchase a nifty script that allows for file management/shell commands via whm!

  6. #6
    Member
    Join Date
    Jan 2004
    Posts
    20

    Default

    Well it appears I could run it through whm but for technical reasons I could not run
    it remotely through my limited pocket pc browser (would not access via the non-typical port)
    So, could you possibly give any type of a point towards an explanation of writing
    the c wrapper then setting the suid perms.
    ..or is there any other way of running scripts with full root permmissions through the
    typical http or ssl ports?
    Thank you again

  7. #7
    cPanel Partner NOC This forum account has been confirmed by cPanel staff to represent a vendor.cPanel Partner NOC Badge
    Join Date
    Nov 2001
    Location
    San Clemente, Ca
    Posts
    703

    Default

    Somthing like this probably work..

    #include <stdio.h>
    #include <sys/types.h>
    #include <unistd.h>


    main(int argc, char **argv)
    {
    int pid, status;

    if (argc != 2) {
    printf("Usage: %s <command>\n",argv[0]);
    return 1;
    }

    setuid(0);

    pid = fork();
    if(pid == 0) {
    execl(argv[1],argv[1],NULL);
    }
    while (wait(&status) != pid);

    return 0;
    }
    Shaun Reitan
    NDCHost.com - cPlicensing.net - ProVPS.com
    Contact us for your cPanel Licensing needs! We Price Match, We provide Support, We take care of our customers!

Similar Threads & Tags
Similar threads

  1. Plugin run as root
    By abrender in forum cPanel Developers
    Replies: 1
    Last Post: 07-24-2008, 09:34 AM
  2. How to run scripts?
    By SXR1337 in forum New User Questions
    Replies: 3
    Last Post: 05-05-2007, 10:13 AM
  3. some pl scripts only run with -w
    By bernieberg in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 04-09-2006, 12:33 PM
  4. Cron <root@server> root run-parts /etc/cron.hourly
    By vishal in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 11-29-2003, 08:47 AM
  5. run PHP scripts as root?
    By kosmo in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 11-13-2002, 05:16 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube