How to allow easy editing of www-data owned files by a user

Xen list at xenhideout.nl
Wed Dec 6 15:03:50 UTC 2017


On Tue, 5 Dec 2017, Chris Green wrote:

>    All the wiki files are owned by 'chris' (the wiki is rooted in my
>    home directory and is synchronised across a couple of machines by
>    syncthing).
>
>    www-data can read/write/create files in the ~/chris/wiki directory
>    but they will always be owned by 'chris'.

I am really happy to see you post this because I have the exact same use 
case.

> Can anyone see a way of implementing this?  ... or any other
> reasonable solution?

I haven't read the other replies yet but your user becomes part  of 
www-data and all of the files get www-data as group.

Your wiki needs to create all files as g+w.

It can't create them as chris, but you will need to run a service that 
will chown them to your user.

I really have a script somewhere that doesn't work very well atm that 
creates automatic reports by mail on what it has changed as well.

So it's not usable now, but a simple cron job,

that will run chown -R chris.www-data ~/wiki/ (basically) will of course 
do the trick.

You will just be running this script every 10 minutes :-/.

More sophisticated will do:

   find ! -owner chris ! -group www-data -exec chown chris.www-data "{}" 
";"

or something similar...

and

   find -type d ! -perms 0771 -exec chmod 751 "{}" ";"
   find -type f ! -perms 0660 -exec chmod 660 "{}" ";"

not sure if find syntax is correct.




More information about the ubuntu-users mailing list