The problem
The most problematic issue I've encountered in trying to make a locally shared directory is that copying files/directories into the shared directory will preserve the existing permissions, both using standard UGO permissions and POSIX ACLs. Manually or even using a cronjob to correct the permissions is obviously not a solution. Also note that I cannot tell the end-user to copy without preserving permissions, I don't have that much control over them.
If somebody were able to present a solution for this issue I'd be satisfied.
I'll summarize several methods which one can use to create a shared directory.
Common methods for sharing directories
Using standard UGO permissions
- Set a default umask of 002 in /etc/login.defs (i.e. umask u=rwx,g=rwx,o=rx
- Add users to a shared group
- Create a directory
- Change the group of the directory to the shared group
- chmod g+s the directory (the setgid bit, the group will be inherited for any created directory/file inside the directory)
However this method is a little bit too inflexible for certain scenarios.
Using POSIX ACLs
For a more extensive discussion, see the following posts: HOWTO: Local shared folder and Re: Permissions on a shared directory.
- Create a directory
- Change the ACLs and default ACLs to allow a shared group (in this case foo) read/write access
- setfacl -m g:foo:rwx && setfacl -dm g:foo:rwx
The default ACL will take care of the permissions.
References
General references
Here are some links that should give you some more insight into the topic.
- Eiciel 0.8 - Users guide (describes POSIX ACLs versus UGO permissions)
- Debian mailing list, Re: Umask 002 policy
- Wikipedia umask
- Launchpad Bug #173267 :Kernel ACL support for NFS/CIFS in 8.04?
Ubuntu Forum discussions
There are several other threads where the topic of creating a shared directory is discussed. However, the reason I have for creating this thread is to for once and for all solve the issue of files/directories preserving their permissions when being copied into a shared directory (thereby not allowing other users access to these files).



Adv Reply

Bookmarks