Centos – Windows Changes File Permissions in Samba File Shares

centoslinuxsambawindows

I have mounted an external USB drive that is used for file shares on CentOS. All of the clients access the shares are Windows XP or 7. Within Windows, I use the "Manage your credentials" feature in "User Accounts" to allow the Windows machines to access different shares.

I recursively changed the owner, group, and permissions level to match the snippet below for the entire Sales Manager share. The credentials for the user "manager" are set in Windows "Manage your credentials" for access control. I then map the share to a network drive in Windows.

-rwxrwx--- 1 root    managers 924672 Oct 30 08:18 fileName.xls

After a member of the "managers" group opens and saves a file the permissions gets changed to the snippet below. This causes other users who are members of the "managers" group to lose the ability to write that file. In this example, I used the user manager to access a demo file. You can see how manager is now the owner and loses x. The group changes to the default group of the user accessing the file. The group also loses wx.

-rw-r--r-- 1 manager managers 919552 Oct 30 08:25 fileName.xls 

Best Answer

I had this same issue. Linux Samba server settings have a create mask where you can set the default create permissions. There is a force user setting where you can force created files to always be the same user.

Settings location in ubuntu:

/etc/samba/smb.conf

If your permissions are changing even though you are just editing the file this could be because your particular editor has an "atomic save" feature. This is where the editor creates a temporary file and writes the changes to there and then replaces the temporary file with the original. This would mean that every time you modify a file you are actually deleting and creating a new file.

Related Question