views:

321

answers:

3

We have two users:

user1 user2

They both belong to the group 'admin'.

We have a directory that has been set to 775. The directory's group has been changed to 'admin'. Each user has full access to write into that directory, though when a user writes a new file to the directory, the group permissions of the folder are not persisted to the file that was written.

How should we make it so that files inherit the directory's group permissions?

Clarification: when a new file or directory is written, it uses the users' group as the group of the new file, rather than that of the directory, which makes sense - but how do I not make that happen?

+2  A: 

I think you should look here.

As the site says, "Unix doesn't support the idea of inherited permissions."

However, there is a section on ACLs (Access Control Lists), which I think is what you are looking for. By setting up an ACL, you can have your files inherit the same ACL from the directory, which I think is what you are asking for. setfacl is the shell command that will be what you need to look into.

Hope that helps!

samoz
+1  A: 

If you are using ext3 or ReiserFS, this page about creating a Linux file server may help. Specifically step 7 suggests the following command.

setfacl -d -m g:sales:rw /groups/sales
Mike
+3  A: 

You can propagate group permissions by setting the directory's setgid bit (chmod g+s). This may not be portable across all *nixes and all file systems.

http://en.wikipedia.org/wiki/Setuid#setgid_on_directories

http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html

Cirno de Bergerac
Perfect, thanks!
Nick Sergeant
Note that this is the SYSV compliant behaviour that you can modify by using +s on dirs. BSD behaviour has always been to have group inheritance.
Keltia
It is portable across POSIX-compliant systems, which (at least for this purpose) means anything that ends in X (Unix, Linux, MacOS X).
Jonathan Leffler