# External Storage: files & dirs created with wrong permissions

**URL:** <https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969>\
**Category:** ℹ️ Support\
**Tags:** docker, external\_storage\
**Created:** [January 22, 2020, 7:48pm UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969 "2020-01-22T19:48:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hitech95](https://help.nextcloud.com/user_avatar/help.nextcloud.com/hitech95/32/20633_2.png) [@hitech95](https://help.nextcloud.com/u/hitech95)\
**Post date:** [January 22, 2020, 7:48pm UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/1 "2020-01-22T19:48:53Z")

</div>

Hi,  
I’m facing a problem with Nextcloud.

I have mounted a local directory to all the users. The users can browse and upload stuff without any problem.

The issues is that the same folder is mounted to other services and the file permissions prevent the other users/services to modify the files uploaded via nextcloud.

For example, direcotories are created with 755 I would like to have a 775 permission so all the users in teh same group can write and modify that directory. Same for the files: I want that the whole group have the permission to edit that file.

Now, nextcloud is setting its user correctly and also the group the only issue is the restrictive mask for a shared folder.

Is there a way to specify a create mask for that specific external storages?

Regards,  
hitech95

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [January 24, 2020, 10:24am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/2 "2020-01-24T10:24:00Z")

</div>

What Operationg system?  
What kind of external storage?

---

<div class="post-metadata">

**Author:** ![Samuel\_Weisbuch](https://help.nextcloud.com/letter_avatar/samuel_weisbuch/32/5_5575768a8748004e209b776fc1b2916d.png) [@Samuel\_Weisbuch](https://help.nextcloud.com/u/Samuel_Weisbuch)\
**Post date:** [January 24, 2020, 12:12pm UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/3 "2020-01-24T12:12:58Z")

</div>

facing the same problem. Want my files added by nextcloud to have 777 permissions.  
Anyone solved this ?

---

<div class="post-metadata">

**Author:** ![hitech95](https://help.nextcloud.com/user_avatar/help.nextcloud.com/hitech95/32/20633_2.png) [@hitech95](https://help.nextcloud.com/u/hitech95)\
**Post date:** [January 26, 2020, 10:57pm UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/4 "2020-01-26T22:57:50Z")

</div>

The host OS is Debian, Nextcloud is running under Docker.

Local storage is a simple local directory.

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [January 28, 2020, 8:07am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/5 "2020-01-28T08:07:40Z")

</div>

With Linux/unix systems you have to use the umask settings for the nextcloud/webserver user.  
This will set the default behavior of setting file/directory permissions.

---

<div class="post-metadata">

**Author:** ![hitech95](https://help.nextcloud.com/user_avatar/help.nextcloud.com/hitech95/32/20633_2.png) [@hitech95](https://help.nextcloud.com/u/hitech95)\
**Post date:** [January 28, 2020, 1:24pm UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/6 "2020-01-28T13:24:30Z")

</div>

Yes, but this will change the mask of all the files/dirs created by Nextcloud.

I have to change this only for this specific External Storage

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [May 21, 2020, 6:37am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/7 "2020-05-21T06:37:54Z")

</div>

BUMP!  
How do we fix this within the application? I am running nextcloud in a container and not really able to rebuild the whole container from scratch at this time.

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [May 25, 2020, 6:44am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/8 "2020-05-25T06:44:39Z")

</div>

nextcloud is a php application (as you know 😀) so one can use the functions _fileperms_ and _chmod_ of php to check and set file permissions. As this (as far as I know) is not already implemented, you have to do it yourself - maybe an addon?

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [May 25, 2020, 7:19am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/9 "2020-05-25T07:19:28Z")

</div>

An addon to an addon?

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [May 25, 2020, 7:38am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/10 "2020-05-25T07:38:31Z")

</div>

Addon to a base functionality (documents)?

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 25, 2020, 8:21am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/11 "2020-05-25T08:21:46Z")

</div>

> [@hitech95](#):
>
> so all the users in teh same group can write and modify that directory

How about to set Access Control Lists?

```
sudo setfacl -Rdm g:SomeGroup:rwx /your/folder/to/share/docker
sudo chmod -R 775 /your/folder/to/share/docker

```

The above command forces any new sub-folders within the `/your/folder/to/share/docker` folder to inherit permissions from the docker folder.

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [May 25, 2020, 8:30am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/12 "2020-05-25T08:30:50Z")

</div>

… and if the filesystem supports ACLs, and if the application honors these ACLs it could work… but usually not.

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [May 25, 2020, 8:35am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/13 "2020-05-25T08:35:51Z")

</div>

I was hoping this was something that could be fixed within the functionality of the core application or the add-on rather than use a work-around. It is something that is usually handled on an application level and should be addressed. Especially when dealing with shared access.

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 25, 2020, 8:53am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/14 "2020-05-25T08:53:23Z")

</div>

To be honest in this case helps cron with simple line:

```
find . ! -group foo -exec chown www-data:foo {} \;

```

All files and folders are set to the group `foo` and will be nice to added your `www-data` to this group also:

```
usermod -a -G foo www-data
```

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [May 25, 2020, 9:08am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/15 "2020-05-25T09:08:09Z")

</div>

You want me to create an entire new docker container to work around this one issue of changing the group access to +w by changing the owner of the folder? Would it not be better to just write this into the code so that when it writes a file it sets the group write access to +w or allows us to set what it sets in the options? This way people do not have to learn cron, or shell commands, or how to create a docker container (in my case) and start hacking the sh\*t out of their system?

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 25, 2020, 9:18am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/16 "2020-05-25T09:18:39Z")

</div>

No.  
I also use a docker and expose shared folder e.g. under `/var/docker/shared` Then all containers has this folder mounted and (usually) use docker user and docker group to create and access files.

Simple cron with find command from above on a host machine will change group so that **other applications** from the Host machine can access files.

E.g. my nextcloud is on local machine with user `www-data`. Now I trying to access docker shared folder under `/var/docker/shared` from it. I set group to `foo` and added user `www-data` to this group. Now my Nextcloud from local host and docker containers has an access to the shared local folder. Also I can added to group `foo` my local user and access files without `sudo`.

---

<div class="post-metadata">

**Author:** ![hartmut001](https://help.nextcloud.com/letter_avatar/hartmut001/32/5_5575768a8748004e209b776fc1b2916d.png) [@hartmut001](https://help.nextcloud.com/u/hartmut001)\
**Post date:** [May 25, 2020, 9:28am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/17 "2020-05-25T09:28:50Z")

</div>

… if your docker container has the same uids and gids matching the uids/gids of the server presenting the shared folder - if not -\> mess!!

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [May 25, 2020, 9:44am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/18 "2020-05-25T09:44:39Z")

</div>

Its depends on particular container, if .yaml file will not use PUID/GUID as variables or from environments, but something that is ether hard coded or could not be changed without rebuild the container, then user could be even in numbers because does not exist in local host.  
But this is not a big issue as soon as your container mounted folders are managed.

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [May 25, 2020, 10:04am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/19 "2020-05-25T10:04:45Z")

</div>

Why can we not just fix the options in the plugin so we can specify a file and folder create mask instead of jumping through all these hoops. And yeah, if the shared folder is big with lots of files then every five my minutes I have to have my server sorting through all that? Then if someone uploads a file for 5 minutes no one else can access it? This is all silly. Just fix the problem in the code. PLEASE??? Why is this so difficult?

---

<div class="post-metadata">

**Author:** ![DesktopMasters](https://help.nextcloud.com/user_avatar/help.nextcloud.com/desktopmasters/32/25228_2.png) [@DesktopMasters](https://help.nextcloud.com/u/DesktopMasters)\
**Post date:** [June 30, 2020, 2:42am UTC](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969/20 "2020-06-30T02:42:35Z")

</div>

This is obviously a huge bug that prevents the app from being usable. So I am just going to sit here and politely BUMP THIS in hopes that the developer of it sees it and ads the few lines of coded needed to make this work.

[Next page](https://help.nextcloud.com/t/external-storage-files-dirs-created-with-wrong-permissions/68969.md?page=2)
