Sunday, April 26, 2015

Prevent Mac OSX from writing hidden (._XXX and .DS_Store) files to your samba share

I had a cifs/smb share on a linux server which was being polluted with hidden files (like ._DS_Store and .DS_Store) created by MacOSX clients.  It doesn't really cause any problems, but for users who use the same share with a client which is not a Mac, these files are visible and it is really annoying and looks messy.

On Mac OS X you can disable writing of hidden files to shares by using the following command in Terminal:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
killall Finder
 
HOWEVER, that only sorts out the problem for that one Mac, any others connecting to the share will need the same treatment so this is not really the ideal solution.

The better solution is to disallow these types of files on the cifs/smb share instead. Any and all Macs using the share are then not permitted to save those files

You can do this easily by editing your /etc/samba/smb.conf file and adding the veto files option, as in this example:

  [TV]
   path = /share/TV
   guest ok = yes
   browseable = yes
   create mask = 0666
   directory mask = 0777
   read only = no
   writeable = yes
   available = yes
   veto files = /._*/.DS_Store/


The veto files can be a single file pattern, or multiple so long as you seperate each one with a /

Once the config change is made, restart samba with:

service samba restart

No comments:

Post a Comment