ACL - 所有新创建的文件自动使用相同的 ACL

gas*_*par 4 linux acl permissions

我想为例如设置 ACL。/tmp/test 文件夹如下:

/tmp/test 所有者是用户“gaspar”,组“testgroup”的成员。
用户“testuser”也是组“testgroup”的成员,我只想向该用户+所有者(用户“gaspar”)授予 rwx 权限。
另外,我需要自动为 /tmp/test 中所有新创建的文件/目录设置相同的 acl。

当我像这样设置facl时:

setfacl -Rdm u:testuser:rwx,g:testgroup:-,o::- /tmp/test/
Run Code Online (Sandbox Code Playgroud)

getfacl -p /tmp/test/授予权限:

# file: /tmp/test/
# owner: gaspar
# group: testgroup
user::rwx
group::---
other::---
default:user::rwx
default:user:testuser:rwx
default:group::---
default:group:testgroup:---
default:mask::rwx
default:other::---
Run Code Online (Sandbox Code Playgroud)

然后用户“testuser”没有 /tmp/test 文件夹的权限。您能否建议问题出在哪里,我应该纠正什么?

当我像这样设置 acl 时(没有“d”选项),用户“testuser”拥有他应该拥有的权限,但显然新创建的文件/目录没有相同的 acl:

setfacl -Rm u:testuser:rwx,g:testgroup:-,o::- /tmp/test/

getfacl -p /tmp/test/

# file: /tmp/test/
# owner: gaspar
# group: testgroup
user::rwx
user:testuser:rwx
group::---
group:testgroup:---
mask::rwx
other::---
Run Code Online (Sandbox Code Playgroud)

任何建议表示赞赏!

Chr*_*her 5

/tmp在您的系统上,重新启动后文件就会消失,对吧?也许这不是一个永久解决方案的好位置。在目录上设置 ACL 并将 ACL 应用于目录中的所有新文件系统对象时,请记住设置两个掩码:(1) 目录本身的掩码和 (2) 默认掩码(对于所有新文件系统对象) )。

setfacl -m u::rwx,g::r-x,o::--- /tmp/test
setfacl -d -m u::rwx,g::r-x,o::--- /tmp/test
Run Code Online (Sandbox Code Playgroud)

上面的-m开关是 的掩码/tmp/test,并且-d开关使该掩码成为同一目录中所有新文件系统对象的默认掩码。它相当于 0750。也可以使用八进制值。

用户、组和其他掩码的工作方式相同:g:groupname:---或组合使用:u:username:---,g:groupname:---,o::---。不指定用户名或组名会将掩码应用于当前用户/组所有权。

请注意,并非所有软件都支持 ACL。例如,并非所有 SFTP/SCP 客户端都知道它们。