I think you need to use the following parameters:
# I changes the permissions to rw-rw-r--
# You should be able to change them to 775 if you need the files to
# be executable
create mask = 664
force create mode = 664
security mask = 664
force security mode = 664
# I set the SGID flag here as I thought this is what you wanted
# You could change to 0775
directory mask = 2775
force directory mode = 2775
directory security mask = 2775
force directory security mode = 2775
I was looking for a nice explanation of how these settings work, but could not find anything better then man smb.conf
You will have to scroll down a bit for those options.
Basically, in a nutshell, windows permissions are not the same as unix (linux) and it is a bit odd how samba maps permissions.
Answer from Panther on askubuntu.comI think you need to use the following parameters:
# I changes the permissions to rw-rw-r--
# You should be able to change them to 775 if you need the files to
# be executable
create mask = 664
force create mode = 664
security mask = 664
force security mode = 664
# I set the SGID flag here as I thought this is what you wanted
# You could change to 0775
directory mask = 2775
force directory mode = 2775
directory security mask = 2775
force directory security mode = 2775
I was looking for a nice explanation of how these settings work, but could not find anything better then man smb.conf
You will have to scroll down a bit for those options.
Basically, in a nutshell, windows permissions are not the same as unix (linux) and it is a bit odd how samba maps permissions.
I had the same problem, but everything like mask directives did not work for me (Samba 4.3.11):
create mask = 0664
force create mode = 0664
directory mask = 02775
force directory mode = 02775
The only option that worked was under the [global] or share section:
inherit permissions = yes
Just change all folder and file permissions to your need, so future folders and files will inherit the same permissions.
The problem turned out to be the security mode settings within my configuration (or lack there of). The following smb.conf configuration is now working for me and all users within my security group "dev" now have 775 for all files they create within the share:
[development_server]
comment = Development directories
path = /sites
writeable = yes
valid users = @dev
guest ok = no
create mask = 0775
force create mode = 0775
security mask = 0775
force security mode = 0775
directory mask = 0775
force directory mode = 0775
directory security mask = 0775
force directory security mode = 0775
I found this solution while digging through askubuntu
Check obey PAM restrictions parameter. If enabled Samba will create files with umask restriction for given user.
I would try removing the create and directory mask settings. I can get it to work by just using this:
force create mode = 0775
force directory mode = 0775
force user = zuallauz
force group = www-data
That forces all the new directories and files created to have 0775 permissions.
Failing that you could try setting the parent directory manually once via command line to 775 (or whatever permissions you need) then using:
inherit permissions = yes
Theoretically all new files should inherit their parent directory's permissions. Don't forget to restart samba after changing the config:
sudo restart smbd
sudo restart nmbd
See good documentation on all the settings here.
My understanding of create mask is that samba users are allowed to modify those permissions up to the mask. So if you set it to 0777 for example, then a user would be able to modify all bits. This is not the same as unix file masks. So your setting of 0664 would mean that a user can modify the permissions on User (rw), Group (rx) and Other (r). This does not mean that the files will be created with those permissions - simply means that the user can use those permissions.
You can use force create mode instead which should do what you need:
force create mode = 0664
