Samba share permissions can be a bit fiddly. The user and group IDs which own the file on the Samba server will propagate over to the client machines, which will enforce local permissions themselves.
Ideally, you want to have the same users/groups on all machines. This isn’t always practical but could be achieved with a config management tool such as Puppet or SaltStack, or indeed by backing your local users from an LDAP server.
If this is not possible, the following is suggested:
On your Samba server
- Create a group which will own all the files, for example samba-users
- Add all of your Samba users to the group you created – e.g. adduser downloader samba-users
- Chown all of your shared files and folders to root:samba-users
- Chmod all of your shared files to 660
- Chmod all of your shared folders to 770
- Add the below to the config for your share to enforce the above for all new files and folders:
force create mode = 0664
directory mask = 0775
force directory mode = 0775
force group = samba-users
On your client server(s)
- Create a group which will be able to access all the files on the share, for example samba-users
- Obtain the group ID (GID) from /etc/group for this group
- In the mount options of the share (in /etc/fstab) add the uid 0 (root) as in the below example
- In the mount options of the share (in /etc/fstab) add the gid as in the below example where the GID is 1002
If you u(n)mount and remount the share you will see that all the files are now owned by the group you specified in fstab.
There might be a better way… feel free to comment if you know what it is.