#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    'lo all!

    I wish to automate certain administrative tasks on my dedicated Linux server with PHP. However, it would be necessary that my script is running with the privileges of the root and it is not advised to launch Apache under the root user. How can I change the current user in my PHP script?

    Thank you for your lights.
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Read up on suexec in the PHP manual.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    I sought "suexec" on php.net and zend.com and I did not find anything. Are you sure this command exists?

    [This message has been edited by manu02 (edited June 30, 2000).]
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    24
    Rep Power
    0
    Hello,

    I am not sure if this is on the same subject or not but I am trying to make a filemanger script and I want to be able to have the PHP script be able to delete/create/modify files.

    As of now I can't do the actions because when ever my script makes an attempt I get a permission denied because the script is like a general web surfer. I could fix this be giving write permissions to every file/directory but I REALLY don't want to do this.

    Is there a way to make the script so it is like the owner of the files and has the same permissions as I do?


    [This message has been edited by Aoeex (edited July 01, 2000).]
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    Before posting my question, I made a search in many forums (Zend, DevShed, PHPBuilder, PHP Club Forums...). Many people ask the same thing: how to change the privileges of a PHP script without modifying the Apache configuration. No solution was found, then, is this impossible? Is there Linux/PHP gurus in the room?
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    24
    Rep Power
    0
    I did find some stuff on that suexec and it sounds about like what I want but I am not too sure how to use it. If somebody could explain it better to me I might figure it out sooner or later. I don't know much about apache or linux so I would need a lot of explaining done. the informaation I found is at
    http://www.apache.or.jp/docs/suexec.html
  12. #7
  13. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>I don't know much about apache or linux so I would need a lot of explaining done.
    >.Is there Linux/PHP gurus in the room?

    This has less to do with Apache and PHP and it's not just for linux, it's so called "Unix Basics about Permissions".

    Let say you run Apache as nobody and nogroup,
    let say the user "bob" and his file -> /home/bob/public_html/somefile.ext, do "ls -Al", it would show something like this ->
    -rw-r--r-- 1 bob bob 313 June 23 21:25 somefile.ext
    then, somefile.ext is readable by All including "nobody" but not writable or executable. If you chmod it to 664 (-rw-rw-r--), then it's still writable and by "bob" since nobody else is in "bob" group. Let say you chmod it to 646 (-rw-r--rw-), then it's writable by "nobody". If you chmod it to 745 (-rwx-r--r-x), then it's executable (but not writable) by "nobody".

    >>How can I change the current user in my PHP script?
    manu02, with all the permisson stuffs being said, you have a few alternatives:

    1) Recompile your PHP as CGI, not as a module of Apache, then run from command line as root
    2) Or convert your PHP to Perl and run from command line as root
    3) Run Apache as 'root'
    4) suEXEC

    Making Sense?

    Aoeex, suEXEC is what you needed, or else, you need to chmod your files to appropriate permission so "nobody" can 'r' or 'w' or 'x' it. With suexec, let say it's a Perl script, its permission could be as low as "-rwx------" (700).

    [This message has been edited by freebsd (edited July 02, 2000).]

Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. Change this PHP script to use NETPBM instead of GD
    By hknight in forum Project Help Wanted
    Replies: 1
    Last Post: February 10th, 2004, 11:46 AM
  4. Replies: 1
    Last Post: February 4th, 2004, 01:39 PM
  5. Executing PHP script using crontab with PHP module
    By crazyIvan in forum PHP Development
    Replies: 0
    Last Post: January 23rd, 2004, 08:27 AM

IMN logo majestic logo threadwatch logo seochat tools logo