Permissions CIFS – Why Files in SMBFS Share Created with Executable Bit Set

cifspermissions

I mounted a samba share using the smbmount command:

$ sudo smbmount \\\\foo\\bar /mnt/bar -o user=tom

When I create new files, they get created with the executable bit set for owner, group and world. For e.g.

$ touch hello.txt 
$ ls -la hello.txt
-rwxr-xr-x 1 root root 0 Dec  2 12:28 hello.txt

The same file when created on a NFS mounted share sets up correct permissions without any executable bit set.

Why is this happening? How can it be fixed?

Best Answer

NFS was invented in the Unix world and so understands traditional Unix permissions out of the box. (The ACL of modern unix systems are another matter, but recent implementations of NFS should cope with them.)

Samba was invented in the IBM/Microsoft PC world, to exchange files with systems that had no permissions beyond read-only/read-write. It is now native to Windows. By default, Samba does not transmit Unix permissions. Depending on the configuration, either all files are marked executable (which is annoying) or all files (except directories) are marked non-executable (which is annoying).

There are various extensions to the Samba/CIFS protocol that make it more suited for Unix use. Try enabling Unix extensions in the server configuration:

[global]
unix extensions = yes
Related Question