NYCPHP Meetup

NYPHP.org

[nycphp-talk] File create ownership

Dan Cech dcech at phpwerx.net
Fri Nov 2 09:23:16 EDT 2007


Urb LeJeune wrote:
>     I have a multipart form for uploading graphics and documents.
> It works fine. However, the ownership of the uploaded file - on a Linux
> box - is set to apache:apache. I need the ownership to be
> user-name:apache. An executing script, not running as root, cannot
> change the ownership.
> 
>     Is the ownership of a created file a configurable option?

I'm not aware of any .ini value to specify the ownership details for
uploaded files.

Is there a particular reason that you need this ownership setup?

One potential solution would be to add a restricted sudoers entry for
apache which would allow it to execute chown to a specific user only
under a specified directory.  Something like:

apache  ALL = (root) NOPASSWD: /bin/chown user-name /var/www/*

might do the trick, allowing you to use:

exec('/usr/bin/sudo /bin/chown user-name '.
escapeshellarg($pathname),$output,$retval);

Good luck!

Dan



More information about the talk mailing list