Samba、Windows ACL 和不需要的可执行位

Gre*_*osz 3 access-control-list samba4

我在 Ubuntu 18.04 LTS 服务器上设置了支持 ACL 的 Samba,我面临以下情况。

以下是smb.conf内容:

[global]
   # naming
   workgroup = WORKGROUP
   server string = %h server (Samba, Ubuntu)

   # networking
   disable netbios = yes
   local master = no
   domain master = no
   preferred master = no

   # domain accounts
   security = ADS
   realm = EXAMPLE.COM
   encrypt passwords = yes
   invalid users = root

   idmap config *:backend = tdb
   idmap config *:range = 70001-80000

   template shell = /bin/bash

   winbind nss info = rfc2307
   winbind use default domain = yes
   winbind rpc only = yes
   winbind cache time = 10

   vfs objects = acl_xattr
   map acl inherit = yes
   acl group control = yes
   store dos attributes = no

   # logging
   log file = /var/log/samba/log.%m
   max log size = 1000

   # permissions
   create mode = 0644
   directory mode = 0755
   inherit acls = yes
   map archive = no

   # printers
   load printers = no

   # veto files
   veto files = /._*/.DS_Store/

[All Users]
   comment = All Home Directories
   path = /home/EXAMPLE
   browseable = yes
   read only = no
   valid users = @dl_acc_ro @dl_acc_rw
Run Code Online (Sandbox Code Playgroud)

从 macOS Sierra,我连接到 .samba 共享smb://myserver.com/test。然后我打开一个终端,$ cd /Volumes/test最后我创建了一个带有$ touch xxx.

这是$ ls -l我的 Mac 上的输出:

$ ls -l
-rwx------  1 gregory  staff  0 Sep 26 20:00 xxx
Run Code Online (Sandbox Code Playgroud)

现在在服务器本身上:

$ ls -l
-rwxrwxr-x+ 1 gregory utilisa. du domaine 0 Sep 26 18:00 xxx
Run Code Online (Sandbox Code Playgroud)

和 ACL:

$ getfacl /home/EXAMPLE/gregory
getfacl: Removing leading '/' from absolute path names
# file: home/EXAMPLE/gregory
# owner: gregory
# group: utilisa.\040du\040domaine
user::rwx
group::r-x
other::r-x


$ getfacl /home/EXAMPLE/gregory/xxx
getfacl: Removing leading '/' from absolute path names
# file: home/EXAMPLE/gregory/xxx
# owner: gregory
# group: utilisa.\040du\040domaine
user::rwx
user:gregory:rwx
group::r-x
group:utilisa.\040du\040domaine:r-x
mask::rwx
other::r-x
Run Code Online (Sandbox Code Playgroud)

如您所见,由touch所创建的常规文件设置了可执行位。有没有办法避免这种行为?我希望通过 Samba 创建的常规文件具有0644权限。

作为记录,我在 Linux 工作站上进行了测试,它表现出相同的行为,这让我相信这一切都发生在 Samba 服务器端。

sho*_*hok 5

桑巴手册:

因此,存在于 Samba 磁盘共享中的文件中的三个 Unix 可执行位中的任何一个都没有用。然而,DOS 文件有它们自己的属性,当它们存储在 Unix 环境中时需要保留这些属性:归档、系统和隐藏位。Samba 可以通过在 Unix 端重用文件的可执行权限位来保留这些位——如果它被指示这样做的话。然而,映射这些位有一个不幸的副作用:如果 Windows 用户将一个文件存储在 Samba 共享中,而您在 Unix 上使用 ls -al 命令查看它,某些可执行位将不代表您的意思期待他们。

如何禁用它?以下来自手册:

三个 Samba 选项决定是否映射位:映射存档、映射系统和映射隐藏。这些选项分别将归档、系统和隐藏属性映射到文件的所有者、组和全局执行位。您可以将这些选项添加到 [data] 共享中,按如下方式设置它们的每个值:

 [data]
    map archive = no
    map system = no
    map hidden = no
Run Code Online (Sandbox Code Playgroud)

您还可以使用store dos attributes标志调用禁用可执行位。