这可能是晚上的时间,但这令我感到困惑。 图片如下。
[root@node1 acltest]# getfacl foo/ # file: foo # owner: root # group: testuser user::rwx group::rx other::--- [root@node1 acltest]# ls -la . total 24 drwxr-xr-x 3 root root 4096 Feb 9 21:53 . drwxr-xr-x 25 root root 4096 Feb 9 21:54 .. drwxr-x--- 2 root testuser 4096 Feb 9 21:53 foo [root@node1 acltest]# setfacl -mm::rwx foo [root@node1 acltest]# getfacl foo/ # file: foo # owner: root # group: testuser user::rwx group::rx mask::rwx other::--- [root@node1 acltest]# ls -la . total 24 drwxr-xr-x 3 root root 4096 Feb 9 21:53 . drwxr-xr-x 25 root root 4096 Feb 9 21:54 .. drwxrwx---+ 2 root testuser 4096 Feb 9 21:53 foo [root@node1 acltest]# su - testuser [testuser@node1 ~]$ cd /acltest/foo/ [testuser@node1 foo]$ ls -la . total 16 drwxrwx---+ 2 root testuser 4096 Feb 9 21:53 . drwxr-xr-x 3 root root 4096 Feb 9 21:53 .. [testuser@node1 foo]$ touch bar touch: cannot touch `bar': Permission denied
换言之,我创build了一个目录foo ,模式为0750 , root作为所有者, testuser作为组。 ( testuser是testuser的私有组,但这并不重要。)
getfacl命令在该目录上正确显示没有ACL,并且还没有掩码。 如果我现在要添加一个已命名的组或用户,该掩码将相应地设置为组权限。
如果我现在明确地将掩码设置为rwx ,那么ls所显示的组权限也会改变。 我知道这是相反的发生(当组权限改变时掩码改变),但这似乎令人费解。
更令人费解,因为getfacl输出不显示组权限为rwx但是 – 正如所述 – ls一样。
哪一个是对的? 显然, getfacl的输出是正确的,因为testuser不能写入foo 。 顺便说一下,因为我没有授予testuser组这样做的权限。
它继续。 我不能通过使用chmod允许foo上的testuser组写权限。 我必须使用setfacl -mg:testuser:rwx foo明确地设置ACL setfacl -mg:testuser:rwx foo允许testuser最终触摸foo/bar 。
有人可以解释getfacl和ls的输出差异背后的基本原理吗? 我知道将正常的权限和ACL一起使用可能会非常棘手,但这似乎是错误的。 (虽然我期望明显地错过一些东西)
我已经看到为什么组上的chmod(1)会影响ACL掩码?
从acl的man(5)页面
ACL_MASK The ACL_MASK entry denotes the maximum access rights that can be granted by entries of type ACL_USER, ACL_GROUP_OBJ, or ACL_GROUP.
然后:
- 否则,如果进程的有效组ID或任何补充组ID与文件组或ACL_GROUPtypes的任何条目的限定符相匹配,则
if the ACL contains an ACL_MASK entry, then if the ACL_MASK entry and any of the matching ACL_GROUP_OBJ or ACL_GROUP entries contain the requested permissions, access is granted, else access is denied.
这意味着可以在目录上授予rwx,但是chmod位必须同意它。