0770 permission error with external storage on a Synology DS

My nextcloud installation is currently locked because permission of my directory is not set to 0770. A simple chmod 770 command did not help. The installation was running fine for a longer time beforehand.

My setup

Nextcloud runs on a docker container on a ubuntu 18.04 server. I have mounted a shared folder of my Synology NAS using /etc/fstab

//nasname/nextcloud /home/user/docker/Next/data cifs credentials=/home/user/.synology-cred,uid=33,gid=0,dir_mode=0770,file_mode=0600,nounix,vers=1.0 0 0

Here, uid=33 corresponds to the user www-data.

In docker I map /home/user/docker/Next/ to /var/www/html.

On my server I see the permission

drwxrwx---+ 14 www-data root    4096 Apr 29 21:27 .
drwxrwxr-x+ 18 dennis   dennis  4096 Aug 25 22:27 ..
drwxr-xr-x+ 43 www-data root    4096 Mär 25 22:14 3rdparty
drwxr-xr-x+ 47 www-data root    4096 Feb 11  2021 apps
-rwxrwx---+  1 www-data root   17900 Mär 25 22:14 AUTHORS
drwxr-xr-x+  2 www-data root    4096 Apr 25 14:33 config
-rw-r--r--+  1 www-data root    3900 Mär 25 22:14 console.php
-rwxrwx---+  1 www-data root   34520 Mär 25 22:14 COPYING
drwxr-xr-x+ 22 www-data root    4096 Mär 25 22:14 core
-rw-r--r--+  1 www-data root    5122 Mär 25 22:14 cron.php
drwxr-xr-x+ 21 www-data root    4096 Jul  2 21:54 custom_apps
drwxrwxrwx  10 root     root       0 Apr 19 21:54 data
-rw-r--r--+  1 www-data root    4123 Mär 25 22:14 .htaccess
-rw-r--r--+  1 www-data root     156 Mär 25 22:14 index.html
-rw-r--r--+  1 www-data root    2960 Mär 25 22:14 index.php
drwxr-xr-x+  6 www-data root    4096 Mär 25 22:14 lib
-rwxr-xr-x+  1 www-data root     283 Mär 25 22:14 occ
drwxr-xr-x+  2 www-data root    4096 Mär 25 22:14 ocm-provider
drwxr-xr-x+  2 www-data root    4096 Mär 25 22:14 ocs
drwxr-xr-x+  2 www-data root    4096 Mär 25 22:14 ocs-provider
-rw-r--r--+  1 www-data root    3144 Mär 25 22:14 public.php
-rwxrwx---+  1 www-data root    5341 Mär 25 22:14 remote.php
drwxr-xr-x+  4 www-data root    4096 Mär 25 22:14 resources
-rw-r--r--+  1 www-data root      26 Mär 25 22:14 robots.txt
-rw-r--r--+  1 www-data root    2446 Mär 25 22:14 status.php
drwxrwx---+  3 www-data root    4096 Feb 11  2021 themes
-rw-r--r--+  1 www-data root     101 Mär 25 22:14 .user.ini
-rw-r--r--+  1 www-data root     383 Mär 25 22:14 version.php

using ls -la. Where the data folder seems to be the problem. sudo chmod 770 -R data runs for a while but does not change permissions. If I try to change the owner by sudo chown -R www-data data I get a permission denied error.

If I ssh into my Synology diskstation as root user the data folder which is called nextcloud here has the following properties

d---------+ 10 root root 4096 Apr 19 21:54 nextcloud

and inside the directory

d---------+ 10 root root       4096 Apr 19 21:54 .
drwxr-xr-x  30 root root       4096 Aug 25 03:36 ..
drwx------+ 15 serveruser  users      4096 Apr 25 22:48 appdata_oc2hji3rs2ih
drwx------+  7 serveruser  users      4096 Feb 14  2021 user1
drwxrwxrwx+  3 root root       4096 May 15 15:58 @eaDir
drwx------+  2 serveruser  users      4096 Feb 11  2021 files_external
drwx------+  5 serveruser  users      4096 Mar 27 22:33 __groupfolders
-rwx------+  1 serveruser  users       542 Mar 25 22:14 .htaccess
-rwx------+  1 serveruser  users         0 Mar 25 22:14 index.html
drwx------+  6 serveruser  users      4096 May  7 13:04 user2
drwx------+  7 serveruser  users      4096 Apr 30 19:53 user3
-rwx------+  1 serveruser  users 121716861 Aug 25 22:37 nextcloud.log
-rwx------+  1 serveruser  users         0 Mar 25 22:14 .ocdata
d---------+ 13 root root       4096 Apr 19 22:16 #recycle

serveruser is a user on the Synology disc station. I use its credentials on my my server to get access to the data via fstab. On the UI I have given that user full access to the folder and all of its subfolders.

Do you have any idea how I can fix this issue? I have granted the user nuc full access to the folder and subfolders because several folders of my photo archive were not visible within the Nextcloud installation. After that, everything still worked fine. Later, maybe after an upgrade or reboot, the error occured. Nextcloud currently runs on 21.0.0.

Thanks for your help!

Hmm. chmod 777 might fix that, but of course that opens up the folder to anyone who can access the drive. if you are on a shared network, that’s likely a poor solution. Access control limits (setfacl) probably has a better answer if this is not usable?

Changing to 777 would shut down web access for security reasons from what I know.

I decided to get rid of the NAS solution and have connected an HDD directly to my server. This solved the issue.