0

I'm using a Linux/Debian. In the following series of commands I was in directory temp_dir4. I mounted a google storage bucket to that directory and then changed the permissions otherwise I would have gotten a permission denied error when I ran ls.

kylefoley@kfoley76:/mnt/disks/temp_dir4$ sudo -i chmod o+rx -R /mnt/disks/temp_dir4
kylefoley@kfoley76:/mnt/disks/temp_dir4$ sudo gcsfuse deduction1 /mnt/disks/temp_dir4
Using mount point: /mnt/disks/temp_dir4
Opening GCS connection...
Opening bucket...
Mounting file system...
File system has been successfully mounted.
kylefoley@kfoley76:/mnt/disks/temp_dir4$ ls

Next I ran a program over at a different directory which was a python program that would just read the files in the directory. This program was:

lst1 = os.listdir('/mnt/disks/temp_dir4/')
print (lst1)

I got the following error:

File "fix_mistakes.py", line 1733, in <module>
    temp17()
  File "fix_mistakes.py", line 1729, in temp17
    lst1 = os.listdir('/mnt/disks/temp_dir4/')
PermissionError: [Errno 13] Permission denied: '/mnt/disks/temp_dir4/'

I then tried to go back to that directory and change the permissions but I could not:

kylefoley@kfoley76:/mnt/disks$ sudo -i chmod o+rx -R /mnt/disks/temp_dir4
kylefoley@kfoley76:/mnt/disks$ cd temp_dir4
-bash: cd: temp_dir4: Permission denied

kylefoley@kfoley76:/mnt/disks$ sudo -i chmod a+w /mnt/disks/temp_dir4
kylefoley@kfoley76:/mnt/disks$ cd temp_dir4
-bash: cd: temp_dir4: Permission denied

Also, I need to change the permissions of temp_dir4 so that when I run that python program I won't get hit with another permission denied error.

logic1976
  • 253

1 Answers1

0

I have no experience with gcsfuse at all but I know few general facts:

  1. Mounting anything over a directory will not affect programs that already use the directory. Your ls inherited its working directory from the shell, this is not the mounted filesystem. But if you did ls "$PWD" (equivalent to ls /mnt/disks/temp_dir4) or cd "$PWD", then you would probably hit Permission denied because now /mnt/disks/temp_dir4 refers to the mounted filesystem.

  2. gcsfuse uses FUSE, Filesystem in Userspace. If you mount as root then it will work for root; unless you use allow_other (see this). It's normal chown and chmod don't work with FUSE. The documentation of the tool reads:

    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!

    To know the security implications read this answer.

    An example command:

    sudo mount -t gcsfuse -o rw,allow_other,uid=1001,gid=1001 deduction1 /mnt/disks/temp_dir4
    

    Where -t gcsfuse tells mount to use mount.gcsfuse. Your original command with gcsfuse as the executable is just a handy alternative (although I'm not sure if it allows you to pass allow_other; it should).

    But to mount the filesystem for your current user only, it's enough (and safer!) to mount it as the current user (without sudo). One of the points of having a Filesystem in Userspace is to allow a regular user to mount it. The already mentioned documentation states:

    Important: You should run gcsfuse as the user who will be using the file system, not as root. Similarly, the directory should be owned by that user. Do not use sudo for either of the steps above or you will wind up with permissions issues.

    So unmount the filesystem you mounted as root (if still mounted):

    sudo fusermount -u /mnt/disks/temp_dir4
    

    Then simply mount it as your user:

    gcsfuse deduction1 /mnt/disks/temp_dir4
    

    If this succeeds then your user will be able to use the filesystem.