我有一个应用程序在/opt/reports中生成具有root:root的文件的报告文件,在0600年。为了允许外部系统自动处理这些报告,我创build了一个新的服务帐户用户,使用组“report”组/opt/reports报告并设置SUIG位,然后在/opt/reports目录中设置默认ACL,使其包含报告组和400,屏蔽为400。
我注意到,当我手动创build一个文件的权限都设置为预期,但是当应用程序创build一个文件的默认值不会被inheritance。
[root@reports1 ~]# getfacl /opt/reports getfacl: Removing leading '/' from absolute path names # file: opt/reports # owner: root # group: report user::rwx group::rx other::rx [root@reports1 ~]# setfacl -R -d -n -mg:report:r,m::r /opt/reports/ [root@reports1 ~]# getfacl /opt/reports getfacl: Removing leading '/' from absolute path names # file: opt/reports # owner: root # group: report user::rwx group::rx other::rx default:user::rwx default:group::rx #effective:r-- default:group:report:r-- default:mask::r-- default:other::rx
手动创build文件似乎工作正常
[root@reports1 ~]# echo "This is a test file" > /opt/reports/testfile.txt [root@reports1 ~]# ls -l /opt/nessus_reports/testfile.txt -rw-r--r--+ 1 root report 20 Apr 24 11:16 /opt/reports/testfile.txt [root@reports1 ~]# getfacl /opt/reports/testfile.txt getfacl: Removing leading '/' from absolute path names # file: opt/reports/testfile.txt # owner: root # group: report user::rw- group::rx #effective:r-- group:report:r-- mask::r-- other::r--
但是,在使用应用程序生成报告时,屏蔽会传播到新文件
[root@reports1 ~]# ls -l /opt/reports/018b274b-7c21-859d-6295-1af24b14da8451d8fe886e9c192d -rw-------+ 1 root report 125952 Apr 24 11:18 /opt/reports/018b274b-7c21-859d-6295-1af24b14da8451d8fe886e9c192d [root@reports1 ~]# getfacl /opt/reports/018b274b-7c21-859d-6295-1af24b14da8451d8fe886e9c192d getfacl: Removing leading '/' from absolute path names # file: opt/reports/018b274b-7c21-859d-6295-1af24b14da8451d8fe886e9c192d # owner: root # group: report user::rw- group::rx #effective:--- group:report:r-- #effective:--- mask::--- other::---
这是预期的行为,我只是误解有关的术语? 我是否错过了某处的国旗或选项,我是否完全从错误的方向接近它?
[首先,看起来你的SUIG位丢失了(我希望在getfacl输出中有一个“flags:-s-”)。 但是,这不是什么导致这个问题。
看起来,报告生成器不仅创build了具有027 umask的文件,而且还在该文件上执行了显式的chmod()。 当它这样做时,POSIX ACL掩码会丢失。
尝试以下操作(以root身份):
touch /opt/reports/testfile.txt getfacl /opt/reports/testfile.txt chmod 640 /opt/reports/testfile.txt getfacl /opt/reports/testfile.txt
看起来显式的chmod()破坏了一些东西。
这是默认行为,因为创build时的文件具有创build它们的用户的用户:组关联。 尽pipe如此,还是有希望的。 您只需确保应用程序运行时,由报告组作为其主要组的用户运行。 那里有很多如何做的例子。 如果你看看/etc/init.d中的一些脚本,几乎所有的脚本在启动服务的时候都会这样做。 祝你好运! (在一个侧面说明,它表明你是一个Windowspipe理员,因为对子对象的整体inheritance权限是Windows风格权限的默认权限,心灵切换到文件的unix样式acl的可能有点棘手。)