Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

PHP writable directory

Discussion in 'General Discussion' started by Host4u2, Jun 13, 2003.

  1. Host4u2

    Host4u2 Well-Known Member

    Mar 24, 2002
    Likes Received:
    Trophy Points:
    Hi, I want to be able to have files and directories writable by PHP scripts without them being globally writeable, this doesn't seem to currently be possible and I think I need either to be able to chgrp my files and/or directories to group "nobody" OR for PHP to run as the account name in the same way that CGI programmes do.

    PHP scripts are currently running as "nobody" on the server (or at least that's who they write files as), whereas CGI scripts run as the user, I want to create a directory that a PHP script can write files to without letting all server users modify them.

    For a CGI programme I can set my permissions this way:

    drwxr-xr-x 2 bandehc bandehc 4096 Jun 13 07:24 writable_directory
    (user bandehc can write, nobody else can)

    but in order to write to it using PHP I need to make it globally writable:

    drwxrwxrwx 2 bandehc bandehc 4096 Jun 13 07:24 writable_directory
    (anyone can write)

    which is obviously not secure. It would be much more secure to have the directory permissions set so that the group "nobody" could write to it:

    drwxrwxr-x 2 bandehc nobody 4096 Jun 13 07:24 writable_directory
    (user bandehc and group nobody can write, nobody else can)

    BUT if you run the command:

    # chgrp nobody writable_directory

    you get the error:

    chgrp: changing group of `writable_directory': Operation not permitted

    I hope that makes sense, let me know if it doesn't.

    . Support Ticket Number:
  2. Juanra

    Juanra Well-Known Member

    Sep 22, 2001
    Likes Received:
    Trophy Points:
    Search for phpsuexec in these forums. Support Ticket Number:

Share This Page