对于所有包含的常规文件,我有一组目录应该具有rw-rw-r–,对于所有包含的目录,我有rwxrwxr-x.我可以使用setfacl -R -d -mg :: rw / directory / name之类的东西为所有常规文件和目录设置默认权限,但是这会将新文件和新目录的默认权限设置为相同的值,即不想要.
如何使用组的rwx默认权限创建一个文件系统块,但只是rw文件的默认权限?
解决方法:
如果为所有内容设置x标志,那么用户“创建”权限也将生效.这意味着通常文件不会有x标志:
$setfacl -d -m u::rwx .
$setfacl -d -m g::rwx .
$setfacl -d -m o::rx .
$getfacl .
# file: .
# owner: sweh
# group: sweh
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x
$mkdir DIR
$ls -ld DIR
drwxrwxr-x+ 2 sweh sweh 4096 Aug 10 20:05 DIR
$touch file
$ls -l file
-rw-rw-r-- 1 sweh sweh 0 Aug 10 20:05 file
$touch DIR/file
$ls -l DIR/file
-rw-rw-r-- 1 sweh sweh 0 Aug 10 20:06 DIR/file
这保持了umask的变化:
$umask 077
$mkdir DIR2
$ls -ld DIR2
drwxrwxr-x+ 2 sweh sweh 4096 Aug 10 20:08 DIR2
$touch file3
$ls -l file3
-rw-rw-r-- 1 sweh sweh 0 Aug 10 20:08 file3
$> file4
$ls -l file4
-rw-rw-r-- 1 sweh sweh 0 Aug 10 20:08 file4
新创建的目录继承默认ACL:
$getfacl DIR2
# file: DIR2
# owner: sweh
# group: sweh
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x
但是,这不会从已编译的程序中删除x标志:
$gcc -o x x.c
$ls -l x
-rwxrwxr-x 1 sweh sweh 6680 Aug 10 20:12 x
在这种情况下,这是因为gcc执行chmod,因此会覆盖默认值:
open("x", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3
....
chmod("x", 0775)
标签:acl,linux,permissions,defaults
来源: https://codeday.me/bug/20190816/1671925.html