Linux – Is it possible to stop Windows from changing permissions on a Linux SMB share

linuxpermissionssmb

On Ubuntu I've made my user's Public folder an SMB share (using the same user as the smbuser) – I've then mapped it as a network drive on Windows XP.

I can edit, from Windows, any file on the share, but whenever I do it changes the permissions – it keeps owner permission but resets group and everyone permissions to read-only.

e.g. file is 777, I save it on the Windows side and now it's 744.

Is there anyway to stop this happening?

Best Answer

This is due to your Samba configuration. What you want is to set the file masks, so that when Samba creates or modifies a file, the permissions are kept at a known quantity.

This is what I use in my /etc/samba/smb.conf. These options are set explicitly for each share:

[sharename]
    ...
    directory mask = 0755
    create mask = 0644
    ...

See the Samba smb.conf documentation for the create mask and directory mask options. Use security mask if you want to mask ACLs as well.

It seems that under Ubuntu, the user public folders in Ubuntu may be controlled by the [public] share definition.

Related Question