[GH-ISSUE #522] mp_umask appears to not be recursive and s3fs_mkdir seems to also disregard mp_umask #291

Closed
opened 2026-03-04 01:44:06 +03:00 by kerem · 2 comments
Owner

Originally created by @BAGELreflex on GitHub (Jan 18, 2017).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/522

Setup

I am mounting my bucket with the following command (plus some added debugging while working through this issue).

sudo /usr/local/bin/s3fs mybucket:/mydirectory /mnt/myfiles/mydirectory -o url=https://s3-us-west-2.amazonaws.com -o endpoint=us-west-2 -o uid=0 -o gid=48 -o allow_other -o mp_umask=007 -o dbglevel=info -f

Server environment

CentOS Linux release 7.3.1611 (Core)
Apache/2.4.6 (CentOS)
PHP 7.1.0 (cli) (built: Dec  3 2016 11:17:43) ( NTS )

Usage

The bucket mounts fine, I can read/write as owner (root) and group (apache).

I am working on integrating file uploads by user to be stored in my S3 bucket via s3fs. The application is written in PHP. Part of the application needs to be able to create directories inside the bucket. I am doing this via PHP's built-in mkdir().

Debugging

Here is more debugging info available after issuing the s3fs command to mount the bucket.

[bagel@testbox ~]$ ls -lah /mnt/myfiles/
total 512
drwxr-xr-x. 3 root root   27 Jan 18 15:45 .
drwxr-xr-x. 3 root root   22 Jan 18 09:50 ..
drwxrwx---. 1 root apache  0 Dec 31  1969 mydirectory

[bagel@testbox ~]$ sudo ls -lah /mnt/myfiles/mydirectory/
[sudo] password for bagel:
drwxrwx---. 1 root apache   0 Dec 31  1969 .
drwxr-xr-x. 3 root root    27 Jan 18 15:45 ..
-rw-rw----. 1 root apache 650 Jan 18 13:59 file1.png
drwxrwsr-x. 1 root apache   0 Dec 30 09:57 folder1
drwxrwsr-x. 1 root apache   0 Dec 30 09:57 folder2
drwxrwsr-x. 1 root apache   0 Jan  5 11:56 folder3

Question

Per UMASK documentation I would expect a umask of 007 to be drwxrwx--- recursively. Perhaps I misunderstand what the umask is for? My mountpoint permissions are correct, so the umask should recurse through all children, is my understanding.

My main issue is when I create a directory via PHP's mkdir() it gets created with the default permissions of 755. This can be seen from the debugging output:

[INF] s3fs.cpp:s3fs_mkdir(1033): [path=/folder4][mode=0755]

I can understand PHP not being able to set permissions via mkdir()'s second parameter (which sets the permission), however I do not understand why s3fs would disregard the mp_umask when creating this new directory. I cannot create a sub-directory in the new directory due to the 755 permissions given to the newly created directory.

drwxr-xr-x. 1 root apache   0 Jan  18 11:56 folder4

Any help or explanation would be greatly appreciated!

Originally created by @BAGELreflex on GitHub (Jan 18, 2017). Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/522 ### Setup I am mounting my bucket with the following command (plus some added debugging while working through this issue). ``` sudo /usr/local/bin/s3fs mybucket:/mydirectory /mnt/myfiles/mydirectory -o url=https://s3-us-west-2.amazonaws.com -o endpoint=us-west-2 -o uid=0 -o gid=48 -o allow_other -o mp_umask=007 -o dbglevel=info -f ``` ### Server environment ``` CentOS Linux release 7.3.1611 (Core) Apache/2.4.6 (CentOS) PHP 7.1.0 (cli) (built: Dec 3 2016 11:17:43) ( NTS ) ``` ### Usage The bucket mounts fine, I can read/write as owner (root) and group (apache). I am working on integrating file uploads by user to be stored in my S3 bucket via s3fs. The application is written in PHP. Part of the application needs to be able to create directories inside the bucket. I am doing this via [PHP's built-in mkdir()](http://php.net/manual/en/function.mkdir.php). ### Debugging Here is more debugging info available after issuing the s3fs command to mount the bucket. ``` [bagel@testbox ~]$ ls -lah /mnt/myfiles/ total 512 drwxr-xr-x. 3 root root 27 Jan 18 15:45 . drwxr-xr-x. 3 root root 22 Jan 18 09:50 .. drwxrwx---. 1 root apache 0 Dec 31 1969 mydirectory [bagel@testbox ~]$ sudo ls -lah /mnt/myfiles/mydirectory/ [sudo] password for bagel: drwxrwx---. 1 root apache 0 Dec 31 1969 . drwxr-xr-x. 3 root root 27 Jan 18 15:45 .. -rw-rw----. 1 root apache 650 Jan 18 13:59 file1.png drwxrwsr-x. 1 root apache 0 Dec 30 09:57 folder1 drwxrwsr-x. 1 root apache 0 Dec 30 09:57 folder2 drwxrwsr-x. 1 root apache 0 Jan 5 11:56 folder3 ``` ### Question Per [UMASK documentation](https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html) I would expect a umask of `007` to be `drwxrwx---` recursively. Perhaps I misunderstand what the umask is for? My mountpoint permissions are correct, so the umask should recurse through all children, is my understanding. My main issue is when I create a directory via PHP's `mkdir()` it gets created with the default permissions of `755`. This can be seen from the debugging output: ``` [INF] s3fs.cpp:s3fs_mkdir(1033): [path=/folder4][mode=0755] ``` I can understand PHP not being able to set permissions via `mkdir()`'s second parameter (which sets the permission), however I do not understand why s3fs would disregard the `mp_umask` when creating this new directory. I cannot create a sub-directory in the new directory due to the `755` permissions given to the newly created directory. ``` drwxr-xr-x. 1 root apache 0 Jan 18 11:56 folder4 ``` Any help or explanation would be greatly appreciated!
kerem closed this issue 2026-03-04 01:44:06 +03:00
Author
Owner

@ggtakec commented on GitHub (Jan 29, 2017):

@BAGELreflex
The mp_umask and umask options are different.

The umask option affects operations below the mount point.
This is the same as the mount command umask. (See mount command man page)

In s3fs, there was a request to apply the umask to the mount point directory.
The option to achieve that is the mp_umask option.
The umask value specified with this option affects only the directory of the mount point.

If you want umask to be applied to the file/directory under the mount point, specify "umask=007".

Thanks.

<!-- gh-comment-id:275889520 --> @ggtakec commented on GitHub (Jan 29, 2017): @BAGELreflex The mp_umask and umask options are different. The umask option affects operations below the mount point. This is the same as the mount command umask. (See mount command man page) In s3fs, there was a request to apply the umask to the mount point directory. The option to achieve that is the mp_umask option. The umask value specified with this option affects only the directory of the mount point. If you want umask to be applied to the file/directory under the mount point, specify "umask=007". Thanks.
Author
Owner

@ggtakec commented on GitHub (Mar 30, 2019):

We kept this issue open for a long time.
I will close this, but if the problem persists, please reopen or post a new issue.

<!-- gh-comment-id:478227116 --> @ggtakec commented on GitHub (Mar 30, 2019): We kept this issue open for a long time. I will close this, but if the problem persists, please reopen or post a new issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#291
No description provided.