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.com
🌐
Samba
samba.org › samba › docs › using_samba › ch08.html
Samba
For map archive to work properly, the execute bit for other must not be masked off with the create mask parameter. When the inherit permissions option is set to yes, the create mask, directory mask, force create mode, and force directory mode are ignored. The normal behavior of setting the permissions on newly created files is overridden such that the new files and directories take on permissions from their parent directory.
🌐
Stack Exchange
unix.stackexchange.com › questions › 772883 › why-do-force-create-mode-and-force-directory-mode-parameters-exist-in-smb-co
networking - Why do "force create mode" and "force directory mode" parameters exist in smb.conf? - Unix & Linux Stack Exchange
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I am reading How to Set Up a Network Shared Folder on Ubuntu With Samba. At the "Step 2: Configuring Samba" section the following configuration is given: [sambashare] comment= Network Shared Folder by Samba Server on Ubuntu path = /home/your_username/sambashare force user = smbuser force group = smbgroup create mask = 0664 force create mode = 0664 directory mask = 0775 force directory mode = 0775 public = yes read only = no
🌐
Blogger
networkingathome.blogspot.com › 2015 › 04 › samba-force-create-modeforce-directory.html
Samba "force create mode"/"force directory mode" not working, how to solve?
April 7, 2015 - After reading the Samba documentation I concluded that I need to set the "force create mode"/"force directory mode" parameters for this share and this should do the trick. After setting it up it was working well for my account (the first, account ...
🌐
Samba
lists.samba.org › archive › samba › 2016-June › 200586.html
[Samba] Force Create Mode Problems
June 21, 2016 - # The default is to use the user's home directory: ; [Profiles] ; path = /var/lib/samba/profiles ; browseable = no ; guest ok = yes # A publicly accessible directory that is read only, except for users in the # "staff" group (which have write permissions): ; [public] ; comment = Public Stuff ; path = /home/samba ; public = yes ; writable = yes ; printable = no ; write list = +staff [ftpshares] writeable = yes admin users = @"RSC+Domain Admins" path = /mnt/fs/ftps write list = "Domain Users",@"Domain Users" valid users = "Domain Users",@"Domain Users" force create mode = 0766 browsable = yes force directory mode = 0766 eric krause | network engineer ringside.cutters.flavor.picnic.moonlink 248 548 2500 w 248 217 3782 c ringsidecreative.com <http://ringsidecreative.com/>
🌐
Red Hat
access.redhat.com › solutions › 3186651
Samba force create mode does not seem to be enforced when running cp -a - Red Hat Customer Portal
June 14, 2024 - I would like all clients to write files using 0777 permissions. To do this, I have edited my smb.conf with the following options: [glustershare] ... vfs objects = glusterfs ... directory mode = 0777 create mode = 0777 force directory mode = 0777 force create mode = 0777 ...
🌐
Samba
samba.samba.narkive.com › DN4jX6Nr › problem-with-force-create-mode-et-al
Problem with "force create mode" et. al.
Post by Ryan Waldron However, for some reason, Samba doesn't seem to recognize those parameters. It acts like I just made them up. What follows are the snippet defining that share, and the error messages I get from the log file as well as those from running 'testparm'. Can anyone tell me what dumb thing I'm doing wrong here? ---snip--snip--- [Share] comment = Company Shares path = /share public = yes writable = yes printable = no force create group = staff force create mask = 0040 force directory mask = 2040 ---snip--snip--- ---snip--snip--- [2000/05/21 22:28:10, 2] param/loadparm.c:do_section(2481) Processing section "[Share]" [2000/05/21 22:28:10, 0] param/loadparm.c:map_parameter(1681) Unknown parameter encountered: "force create group" I think you're using the wrong parameters.
Find elsewhere
🌐
Samba
bugzilla.samba.org › show_bug.cgi
7492 – create mask and force create mode ignored when creating new files
June 4, 2010 - The Samba-Bugzilla – Bug 7492 create mask and force create mode ignored when creating new files Last modified: 2010-06-16 10:52:10 UTC
Top answer
1 of 1
3

Often the issue is caused by enabling one of the following:

  • map archive (uses unix execute bit for owner)
  • map system (uses unix execute bit for group)
  • map hidden (uses unix execute bit for other)
  • inherit permissions causes samba to ignore create mask, etc
  • there's also inherit acls which should default to no

"File Permissions and Attributes on MS-DOS and Unix" in Chapter 8. Advanced Disk Shares explains the above nicely.

However, microsoft office products cause weird behaviour and trigger a bug/unexpected behaviour. Even with create mask and/or force create mode set and avoiding the above map or inherit option, I've seen group execute permissions get set when editing documents using microsoft office applications. This doesn't happen with other programs, e.g. edit a .txt file with notepad and permissions stay sane. Office doesn't just create files, it also messes a bit with temp files, renaming and permissions.

After a lot of digging around, it might be also be mixed up with a Samba POSIX ACL bug of sorts:

  • Old 2007 debian bug report "samba: misinterprets create mode with POSIX acls"
  • "Wrong behaviour for default ACLs" seems to be the most recent bug report for samba, but is sadly closed 'RESOLVED INVALID' (prematurely?).

Observed behaviour on the Linux side

The extended ACLs for an empty word docx file created via windows explorer context menu (not yet opened and saved by word)

$ getfacl test.docx 
# file: test.docx
# owner: tester
# group: tester
user::rw-
group::rw-
other::---

After saving via MS word 2016

$ getfacl test.docx 
# file: test.docx
# owner: tester
# group: tester
user::rw-
user:tester:rw-
group::rw-
group:tester:rw-
mask::rwx

When checking the samba config, on Ubuntu 16.04 LTS, it seems map archive is enabled by default, but that should use the owner's execute bit, not the group execute bit, so that wasn't the cause in my case

$ testparm -s -v 2>&1 | grep 'map archive'
map archive = Yes

Observed behaviour on the Windows side

Using SysInternals Process Monitor and comparing editing a .txt file with notepad.exe vs. a .docx file with WINWORD.EXE, the office suite does a lot of fancy footwork creating temp files, renaming, etc. In particular, unlike notepad.exe, WINWORD.EXE seems to fiddle with access control lists. As seen by procmon

SetSecurityFile
Information:    Group, DACL

So I suspect this is why the UNIX group permission gets fiddled with by microsoft office applications.

Deeper investigation required turning on windows file object security auditing to see what exactly changed. Event ID 4670 shows the the ~WRD0000.tmp permission changes applied (I think word uses this for periodic saving and recovery if it crashes).

Object:
    Object Server:    Security
    Object Type:    File
    Object Name:    C:\Users\<user>\Desktop\TestAudit\~WRD0000.tmp
    Handle ID:    0xfd0

Process:
    Process ID:    0x1ae4
    Process Name:    C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE

Permissions Change:
    Original Security Descriptor:
D:AI(A;ID;FA;;;SY)(A;ID;FA;;;BA)(A;ID;FA;;;S-1-5-<SID>-1001)
    New Security Descriptor:
D:(A;;0x1200a9;;;WD)(A;ID;FA;;;SY)(A;ID;FA;;;BA)(A;ID;FA;;;S-1-5-21-<SID>-1001)

The permission change in SDDL (Security Descriptor Definition Language) is a DACL (discretionary access control list part) where it appears an extra ACE (Access Control Entry) was added. ACE (A;;0x1200a9;;;WD) gets added right at the front. This is how I interpreted it:

  • A; meaning allow access, stayed the same
  • ; no inheritance
  • 0x1200a9; means FILE_GENERIC_READ | FILE_EXECUTE read & execute access
  • WD means the 'everyone' trustee

Then later on, the ~WRD0000.tmp gets renamed to test.docx which I saw in process monitor as a SetRenameInformationFile operation. So in the end test.docx ends up with some of the ACE changes word did for whatever reason.

🌐
Stack Overflow
stackoverflow.com › questions › 53553112 › samba-create-mode-and-directory-mode-not-working-in-ubuntu18
ubuntu 18.04 - Samba create_mode and directory_mode not working in ubuntu18 - Stack Overflow
inherit permissions = yes unix extensions = no obey pam restrictions = no force create mode = 0664 force directory mode = 2700 force user = mike · In Ubuntu16 it is working as configured in samba.
🌐
Samba
lists.samba.org › archive › samba › 2010-August › 157775.html
[Samba] (force) create mode not instantly applied
August 16, 2010 - Thereby it does not matter what I change on the client, even if I remove all access rights. After clicking OK, the permissions of the file would be set to the specified (force) create mode and cannot be changed from the client any more. Example: - connect to samba share from winxp - create file "test.txt" from client - file gets "rw--w----", but should get "rw-rw-r--" (664, see smb.conf) - edit file permissions from winxp, e.g.
🌐
Google Groups
groups.google.com › g › linux.samba › c › yMRS4ATHcOY
[Samba] Force Create Mode Problems
# The default is to use the user's home directory: ; [Profiles] ; path = /var/lib/samba/profiles ; browseable = no ; guest ok = yes # A publicly accessible directory that is read only, except for users in the # "staff" group (which have write permissions): ; [public] ; comment = Public Stuff ; path = /home/samba ; public = yes ; writable = yes ; printable = no ; write list = +staff [ftpshares] writeable = yes admin users = @"RSC+Domain Admins" path = /mnt/fs/ftps write list = "Domain Users",@"Domain Users" valid users = "Domain Users",@"Domain Users" force create mode = 0766 browsable = yes fo
🌐
Google Groups
groups.google.com › g › linux.samba › c › hKiufxt5rkU
[Samba] force group does not work
-- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/options/samba ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... > create mask = 0770 > force create mode = 0770 > directory mask = 0770 > force directory mode = 0770 > > # Miscellaneous > veto oplock files = /*.doc/*.xls/*.ppt/*.mdb/*.docx/*.xlsx/*.ppt > > > # ============= Shares ============= # > > [MyShare] > comment = NAS > path = /mnt/MyShare > guest ok = No > read only = No > valid users = @Groupname > forece user = MyUsername > force group = Groupname > > > > > > > > Any help would be greatly appreciated ;) > > Best Regards > L.
🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-server-73 › samba-force-group-not-working-4175679079
[SOLVED] SAMBA - force group not working
July 20, 2020 - Hey folks - this is my first post... my Linux experience goes back to the 90's but I have been out for a long time. My current environment is:
🌐
Samba
lists.samba.org › archive › samba › 2017-February › 206810.html
[Samba] Windows file directory creation permission confusion
February 23, 2017 - Greetz, Louis > -----Oorspronkelijk ... to working > properly from the Windows clients. No setting I change in smb.conf have > any effect on files and folders created from windows clients. (I see > this kind of question a lot other places so you must be tired of it.) > > Smb.conf > [GLOBAL] > force create mode = 0770 > force directory mode = 0770 > create mask = 0660 > > I don't have any create/mask statements in the share as they do not seem > to ...