Samba File Server: Stop files from being set with executable bit

While doing a bit of code cleanup today, I found some files which were marked as executable even though they weren't meant to be.


As I looked around at the files affected, a colleague did some snooping on git and found out why it was being set.

"Err Twig, I think it's you".

After double checking the git logs, yep it was me. How embarassing!


Preventing the stupid setting

Fortunately it's an easy fix to stop it from happening.

Open up the Samba FS config file

  • sudo vi /etc/samba/smb.conf
  • Under "[global]", paste in:

map archive = no

  • Save and restart

Bonus: Fixing affected files

Unfortunately, this part isn't so easy

You can use this command to quickly search and list out files affected:

find -type f -perm /u+x | vim -

If you want to just find and turn off the executable bit automatically, then use:

find -type f -perm /u+x -exec chmod -x {} \;

find -type d -perm /u+x -exec chmod 0755 {} \;

It'll be up to you to set +x back onto any files which were supposed to have it.


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog