Use case: I'm trying to set up a single Samba share in a system (A) that should be freely accessible from another system (B) in the same network.
- A is running CentOS 7 with Samba 4 daemons.
- B runs Windows 7 Professional.
I set up the share in A with these parameters:
path = /home/MYUSER/dir
force user = MYUSER
force group = MYUSER
read only = No
create mask = 0644
force creater mode = 0644
force directory mode = 0755
guest ok = Yes
And map to guest = bad user. I added the correct SELinux context (or disabled SELinux, it doesn't matter).
Now, in the share path, only MYUSER has write permissions, and that is also the desired permission mask for all subdirectories, as configured. But since I'm forcing files to be written as MYUSER:MYUSER by samba (even though we will be accessing as guest), that shouldn't be a problem, right?
Wrong. When I mount the share on B I have no trouble seeing it, browsing it or reading the files in it. However, all write operations are refused as not allowed.
If I chmod o+w the path of the share, then suddenly samba can write to it... And all the files/directories I create in it are correctly owned by MYUSER:MYUSER! (Though directories, being created with permissions 0755, will in turn not be writable).
Why does this happen? Is samba first creating the files and directories as nobody (or some other user) before chowning them to MYUSER?
Can I set up samba in a way that works around this issue without requiring my share and all subdirectories to be writable by "other"?