External Storage Local permissions (user/group) todo.txt

Nextcloud version: 13.0.4
Operating system and version: Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-131-generic x86_64)
Apache or nginx version: Apache/2.4.18
PHP version: 7.0.30-0ubuntu0.16.04.1

The issue you are facing:

Everything is running fine with this one odd problem.

I have set up an External Storage to a local directory for a user pat to house my todo.txt files. I was hoping to be able to access and modify this todo.txt file from other machines that are synced. However, something is not happy.

The local folder /home/pat/todo/ has these permissions:

drwxrwsr-x  3 pat www-data 4.0K Aug  1 10:24 todo/

Where www-data is the apache user. Both www-data and pat are in the group www-data.

The directory listing and file permissions are as follows:

-rw-r--r-- 1 pat www-data  162 Aug  1 10:23 todo.txt

Notice the group does not have +w on the todo.txt file.

If I add g+w on the todo.txt file, I can write to the file locally, and the changes are synced to my clients. Everything looks peachy!

-rw-rw-r-- 1 pat www-data  162 Aug  1 10:23 todo.txt

The Problem
The problem comes when I edit the same file on a client. If I modify todo.txt on a client, the file will sync. So far so good. But the permissions have now changed (on the server):

-rw-r--r-- 1 www-data www-data  238 Aug  1 10:39 todo.txt

This is not good.

How can I fix this, and why does www-data re-claim ownership of the file (and change the perms to remove group writing)?

My workflow/desire is to:

  1. have this local folder be accessible by the user pat on the server
  2. share this folder as a local external storage where clients can access (r/w) the files
  3. and have the sync back to the server work. (for continued access by user pat there)

So in the docs it lists that you want to set owner+group to www-data?!

sudo chown -R www-data:www-data /path/to/localdir
sudo chmod -R 0750 /path/to/localdir


Doesn’t this sort of make accessing a local folder as “external storage” moot? The owner, group, and permission get hijacked by nextcloud, making the file access locally a little… hard. :frowning: