Friday 8 July 2011

SMB -- Provide network shares suitable for group collaboration

In sharp contrast to the similar objective for NFS, this objective is clearly defined and easily achievable.

I have added a group called Users to my system and created a few users giving them the group Users as a supplemental group (e.g. useradd -G Users auser). Created a samba password for these users and then added the following to my /etc/samba/smb.conf file:
[myothershare]
browseable=yes
path = /myshareddirectory
force group = +Users
valid users = @Users myuser
write list = @Users
create mask = 0770
force create mode =660
Now, let's set SELinux settings (I'm assuming that you have already set samba_export_all_ro as per my previous post):
 setsebool -P samba_export_all_rw 1
And the security context type:
 chcon -t samba_share_t /myshareddirectory/
Let's set ownerships and permissions:
   chgrp Users /myshareddirectory/
   chmod -R 770 /myshareddirectory/
You can now,assuming that your server is 192.168.1.64, finally, mount the share with (you might need to install cifs-utils):
mount.cifs //192.168.1.64/mycolshare /test -o user=myuser
When you create a file now it should have rw permissions for both owner and group and thus files should be read and writeable for any users in the Users group.
-rw-rw----. 1 502 501 0 Jul  8 20:45 createdbyanotheruser
-rw-rw----. 1 501 501 0 Jul  8 21:02 createdbyauser

1 comment: