chmod 777 is not changing the permissions to 777

8

I'm trying to change the permissions of temp_dir to 777. Why are these commands not accomplishing that? I'm using Linux by the way.

kylefoley@kfoley76:/mnt/disks$ chmod 777 /mnt/disks/temp_dir
kylefoley@kfoley76:/mnt/disks$ stat -c "%a %n" temp_dir
755 temp_dir

I also tried the verbose switch

kylefoley@kfoley76:/mnt/disks$ chmod -v 777 /mnt/disks/temp_dir
mode of '/mnt/disks/temp_dir' changed from 0755 (rwxr-xr-x) to 0777 (rwxrwxrwx)
kylefoley@kfoley76:/mnt/disks$ stat -c "%a %n" temp_dir
755 temp_dir

I also don't understand why I can't use sudo

kylefoley@kfoley76:/mnt/disks/temp_dir$ sudo chmod 777 fix_mistakes
chmod: cannot access 'fix_mistakes': Permission denied

Even when I log in as root user

kylefoley@kfoley76:/mnt/disks/temp_dir$ sudo -i
root@kfoley76:~# sudo chmod 777 /mnt/disks/temp_dir
chmod: cannot access '/mnt/disks/temp_dir': Permission denied

I should also add that this bug must have something to do with the fact that the directory in question is a gcsfuse mounted disk, available from gcloud. Other attempts to change permissions worked fine:

kylefoley@kfoley76:~$ mkdir hey
kylefoley@kfoley76:~$ stat -c "%a %n" hey
755 hey
kylefoley@kfoley76:~$ chmod 777 hey
kylefoley@kfoley76:~$ stat -c "%a %n" hey
777 hey

kylefoley76

Posted 2020-02-07T06:51:37.487

Reputation: 243

1Please post what umask outputs. – gronostaj – 2020-02-07T07:11:37.597

1deduction1 on /mnt/disks/temp_dir type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1001,default_permissions) – kylefoley76 – 2020-02-07T07:39:07.313

1that was the umask output – kylefoley76 – 2020-02-07T07:39:15.873

3Note that chmod 777 should never be run. The number of circumstances where world writability does not seriously damage the UNIX security model (particularly given existence of accounts like nobody used to sandbox execution of untrusted code) are very few. – Charles Duffy – 2020-02-07T16:13:28.690

well, i have such a difficult time determining whether or not i am the owner of the file. – kylefoley76 – 2020-02-08T07:18:57.617

Answers

15

gcsfuse sets file and directory permissions when mounting. Specifically, the options are:

  • file_mode – Permission bits for files, in octal
  • dir_mode – Permissions bits for directories, in octal

Source: https://github.com/GoogleCloudPlatform/gcsfuse/blob/e0a0e0826897b09581c24065fb6a92912ee79d03/flags.go#L78

If you do not specify the options, the defaults are dir_mode=0755,file_mode=0644.

Source: https://github.com/GoogleCloudPlatform/gcsfuse/blob/e0a0e0826897b09581c24065fb6a92912ee79d03/flags.go#L51

These options apply to all files and directories in the mount. This FUSE file system does not have the capability of changing permissions for specific files or directories, which is why chmod does nothing.


Furthermore, gcsfuse has additional access restrictions that limit access to the user who mounted the file system. Details:

As a security measure, fuse itself restricts file system access to the user who mounted the file system (cf. fuse.txt). For this reason, gcsfuse by default shows all files as owned by the invoking user. Therefore you should invoke gcsfuse as the user that will be using the file system, not as root.

If you know what you are doing, you can override these behaviors with the allow_other mount option supported by fuse and with the --uid and --gid flags supported by gcsfuse. Be careful, this may have security implications!

Source: https://github.com/GoogleCloudPlatform/gcsfuse/blob/d25be2491879e3745c3ed3d8e816774defc1cc5c/docs/mounting.md#access-permissions

This is why you aren't able to access the mount from another user. To allow other users to access the mount, specify allow_other in your mount options.

Deltik

Posted 2020-02-07T06:51:37.487

Reputation: 16 807

3

I was able to solve the problem in the following way: I had to go to Cloud API Access Scopes and verify under the VM configuration that it has read write or full access for storage. This involved pressing edit on the gcloud console which lists my instances. At the bottom of the page, there was the limitation for storage which I changed to 'full'. That did it.

kylefoley76

Posted 2020-02-07T06:51:37.487

Reputation: 243

Please accept your own answer (or another), to help others who read this question in future. Note that on some sites you may have to wait before accepting an answer., – Mawg says reinstate Monica – 2020-02-07T08:27:52.927