4

How do you share a directory

/home/shared

between two users "eris" and "discordia" such that both can access the directory in their respective home directory, e.g.

/home/eris/shared

and

/home/discordia/shared

and both have full recursive read and write permission on the respective directory? The directories should lie on the same filesystem.

  • I tried using bind mounts and ACLs but these do not work well when moving (and copying?) files into the shared directory, in which case the default ACL will not be applied and the files will keep their original permissions instead,
  • The same holds for using the setguid flag,
  • bindfs with the "mirror" option does what I am looking for, but at the cost of dramatically poor performance, as shown by Guy Paddock.
  • setting the global umask to 002 is not an option,
  • neither is using vfat.
  • Would a symbolic link do the trick? With the correct access rights on the original directory, /home/share. – Laurent C. Apr 13 '14 at 6:06
  • @LaurentC., using a symlink alone would not set the right permissions for new files that are created in or moved into the directory. – Josephine Apr 14 '14 at 0:50
1

The methods you've mentioned are how I would've attempted to do it, in particular ACLs using setfacl to do it. I'd try and set the ACL at the top and make it so that it's recursively applied, but this would not protect files/dirs that are moved into this directory which are lacking it, I believe.

You could use something like incron to run a script anytime new directories or files are introduced into this "shared" directory via a move, and apply the necessary ACLs using setfacl if they're missing.

  • This looks like a good answer. I did not know about inotify, yet. One minor downside is that inotify also triggers the moved_to event when moving or renaming files inside the directory-subtree. This might lead to unnecessary program calls by incron or watcher, which is an incron alternative that can handle directories recursively. – Josephine Apr 14 '14 at 1:17
  • Alas, I just learned that inotify can not inform about the destination of a move if the destination folder is not being watched. So there is no way to revert a setfacl when moving a file or directory out of a shared folder into a not shared folder. The ACL will still hold for this file although this might not be intended. – Josephine Apr 14 '14 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.