March 2010
After copying a file with rw-r-----
on a CIFS-mounted volume, the copy gets rwxr-----
.
So it's gaining the execute
bit:
ls -l blah.txt
-rw-r--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:16 blah.txt
cp blah.txt blah2.txt
ls -l blah.txt blah2.txt
-rw-r--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:16 blah.txt
-rwxr--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:32 blah2.txt
The obvious solution is to set the create mask
in /etc/smaba/smb.conf
, but this creates another problem: unpacking a tarball leaves all the files that come out of the archive lacking execute permissions
.
There is a more subtle setting though, hidden away in the lengthy smb.conf
manpage:
map archive (S)
This controls whether the DOS archive attribute should be mapped to
the UNIX owner execute bit. The DOS archive bit is set when a file
has been modified since its last backup. One motivation for this
option is to keep Samba/your PC from making any file it touches
from becoming executable under UNIX. This can be quite annoying for
shared source code, documents, etc...
Note that this requires the create mask parameter to be set such
that owner execute bit is not masked out (i.e. it must include
100). See the parameter create mask for details.
Default: map archive = yes
So... setting map archive = no
in /etc/samba/smb.conf
:
[Global] <snip> map archive = no <snip>
gains us the proper behaviour:
ls -l blah.txt
-rw-r--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:16 blah.txt
cp blah.txt blah2.txt
ls -l blah.txt blah2.txt
-rw-r--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:16 blah.txt
-rw-r--r-- 1 xxxxxxx xxxxxxx 5 2010-03-11 12:32 blah2.txt
Tarballs also unpack properly again.