0

When uploading files via a webform, the files are then owned by the Apache process (www-data:www-data on Ubuntu, for example).

We want users to have a public_html directory. The problem is that any files uploaded via web processes can no longer be edited / managed by that user.

How can I force the ownership of files uploaded via web forms to always be user:www-data where user is the linux user of course.

I noticed in /etc/apache2/envvar there are two lines I can configure these lines:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

Is this where the resulting ownership is coming from after a file is uploaded? Is there something I can put for APACHE_RUN_USER that will default to the user that's usually found /home/(user) ?

Or is there better way to handle this?

1
  • That is where the ownership is coming from, but unfortunately there's nothing I know of that will let you set the ownership from the Apache side without severely compromising security. Jul 21, 2017 at 18:50

1 Answer 1

0

As a bit of a drastic measure, you can use mpm_itk to run different parts of your website as different users.

Another, better option is to use file ACLs and set the default permissions to allow the user to change the file at their leisure. To do this, do you can use setfacl: setfacl -m "default:user:$USERNAME:rwX" $DIRECTORY.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .