1

Basically I'm having trouble with permissions being inconsistent between Samba and the local file system. Locally I set the file permission to -r--r--r-- with chmod 444 textfile.txt and confirm these settings with ls -al. Then I do a Samba mount. If I look at the same file's permissions via Samba what I see is -rwxr-xr-x or -r-xr-xr-x, but not -r--r--r--. This happens even when a Linux box is looking at himself via Samba.

I'm required to use Samba between Linux VMs using various vendors and versions (as well as Windows VMs, but this note is about Linux only.) I'm testing with CentOS 7 & 8, RedHat 7 & 8, OpenSUSE 15 and SUSE 15. I get similar results from all permutations of these Linux distros. The only one that works correctly is CentOS8 as a Samba client to OpenSUSE15 as the Samba server--this is the only case where Samba's displayed permissions match the permissions displayed locally.

Yes, NFS would be easier, but I must get this working via Samba. Note that this is just a test environment--some of the things below reflect my attempts to simplify the environment. Once I get things working properly, I'll tighten up security.

Here is my setup and steps:

In smb.conf, I've shared the entire drive as C. I've already added root to the SMB users and assigned a password.

[global]
    workgroup = WORKGROUP
    wins support = yes
    passdb backend = tdbsam
    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw
[C]
    Path = /
    Browseable = yes
    Writeable = yes
    only guest = no
    create mask = 0777
    directory mask = 0777
    Public = yes
    Guest ok = yes    

I'm using the same VMs, steps and files, with all permutations. With all VMs, I'm logged to a bash shell as root via PuTTY.

On the Server machine, create a folder with a text file, assign permissions and verify.

mkdir /temp
cd /temp
cp /etc/samba/smb.conf /temp/smb.conf
    It could be any file, I'm using smb.conf as an example.
chmod 444 smb.conf
ll smb.conf
    -r--r--r-- 1 root root <size> <date> smb.conf

From the Client machine, perform a mount command and look at the file permissions via Samba:

mkdir /mnt/test
mount -t cifs //svrname/c /mnt/test -o username=root,password=mypasswd
    In the simplest loopback case, svrname is 'localhost'.
ll /mnt/test/temp/smb.conf
    -rwxr-xr-x 1 root root <size> <date> smb.conf

I need the Samba view of permissions for that file to match the local permissions, like this:

ll /mnt/test/temp/smb.conf
    -r--r--r-- 1 root root <size> <date> smb.conf

However other than that one case mentioned above, I always see -rwxr-xr-x or -r-xr-xr-x.

I've tried all sorts of things but with no luck. Any ideas?

Thanks, Jeff

0

Make sure Samba's Unix extensions are enabled. E.g.,:

[global]
unix extensions = yes
⋮

otherwise, the protocol only supports Windows permissions (ACLs), not Unix permissions. (I thought yes was the default, but maybe the distro changed that).

Similarly, the mount needs to enable them as well, the option is unix there. Also, you may want to set guest ok = no to make sure you're actually authenticating, and not accidentally getting guest.

  • Although unix extensions is not in the smb.conf manual it's definitely accepted. Looks like testparm primarily displays options that are not using their default values. If true then unix extensions seems to default to yes. – Jeff Jan 23 '20 at 17:04
  • The mount.cifs man page does not list unix as an option, and it definitely throws an error when running testparm. There is only a nounix option. – Jeff Jan 23 '20 at 17:04
  • I definitely set guest ok = no as suggested. I tried all sorts of permutations of unix extensions in smb.conf and nounix in the mount command. No improvement. I noticed another post yesterday speculating that the x bits I'm seeing might be the result of some confusion with the DOS archive bit. However this does not explain why the w bits appear where they should not. – Jeff Jan 23 '20 at 17:05
  • @Jeff Apparently the unix option is new (see, e.g., manpages.debian.org/testing/cifs-utils/mount.cifs.8.en.html has it, search for |unix|) ... but its been the default for a while. So it should be on. And you don't seem to have force create mode or similar, so this is odd. – derobert Jan 23 '20 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.