The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DSO+mod_ruid2 - PHP still running as 'nobody'

Discussion in 'General Discussion' started by HemanthJ, Mar 5, 2013.

  1. HemanthJ

    HemanthJ Member

    Joined:
    Feb 28, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    I've just used EasyApache to rebuild Apache to include mod_ruid2. But even after setting it as ON PHP scripts are still being executed as nobody.

    Details:

    Configure PHP and suEXEC:


    The following post came up in searches but it should be fixed in the cPanel version I'm using.

    http://forums.cpanel.net/f334/case-52294-support-mod_ruid2-229432-p3.html#post1086201

    Please Help. :confused:

    Thanks,
    Hemanth
     
  2. LeadDogGraphics

    LeadDogGraphics Well-Known Member

    Joined:
    Feb 25, 2012
    Messages:
    97
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    West Palm Beach, FL
    cPanel Access Level:
    Root Administrator
    Are you sure that it is running as nobody?

    The default behavior of mod_ruid2 is to run as nobody while nothing is going on, and momentarily switch users while executing a task.
     
  3. HemanthJ

    HemanthJ Member

    Joined:
    Feb 28, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks for the reply mate.

    That is an interesting thought. Whenever I check the Process Manager from WHM, it list ~100 entries like the following:

    When I had fcgi+suexec, there used to be a lots of entries by my cpanel username (with command as the php binary).

    Is there any way to test if php is being executed as the user or as nobody?
     
  4. cPanelKurtN

    cPanelKurtN Well-Known Member
    Staff Member

    Joined:
    Jan 29, 2013
    Messages:
    95
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Hi HemanthJ,

    If you compiled PHP with the POSIX extension, you can run the following code under one of your virtual hosts:
    PHP:
    <?php
        $user_info 
    posix_getpwuidposix_geteuid() );
        
    $pid getmypid();
        
    printf"PID:%d, UID:%s (%s)<br>\n"$pid$user_info['uid'], $user_info['name'] );
    ?>
     
  5. HemanthJ

    HemanthJ Member

    Joined:
    Feb 28, 2012
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks Kurt; but that didn't work because I didn't have POSIX.

    I found the following simple script which did the job.

    PHP:
    <?php
    echo shell_exec('whoami');
    ?>
    It printed my cPanel username, yay!! :D I hope it prints the process owner rather than the file owner.
     
    #5 HemanthJ, Mar 8, 2013
    Last edited: Mar 8, 2013
  6. cPanelKurtN

    cPanelKurtN Well-Known Member
    Staff Member

    Joined:
    Jan 29, 2013
    Messages:
    95
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    whoami is sufficient for displaying current Effective User of the running process.

    PHP functions like get_current_user() and getmyuid() will give you the file information you're referring to.
     
Loading...

Share This Page