3

Let's say I have access to directory on some filesystem - /media/vc1/ mounted and owned by user1. I want to give access to user2 (uid == 1001) to some directory in /media/vc1/ (without making copy of files). Ideally, I would like to create directory /home/user2/mnt which would contain contents of /media/vc1/ . I have tried to run following command as root:

mount --bind -o uid=1001 /media/vc1/ /home/user2/mnt/

It does not work, here is stat of mnt directory:

Access: (0700/drwx------)  Uid: ( 1000/   user1)   Gid: ( 1000/   user1)

and access is denied to user2.

To be clear, I'm not able to remount /media/vc1 as different user.

According to this answer, you can't use uid and gid options with --bind. I'm not sure how correct command would look like (I don't want to make this permanent using fstab.).

DavidPostill
  • 162,382
user224348
  • 133
  • 1
  • 5

1 Answers1

5

The --bind option does one thing only: It translates paths, much like a symlink does. It does not act as a standalone filesystem and does not override any access checks.

To alter UIDs, use an actual overlay filesystem such as bindfs.

grawity
  • 501,077