logrotate无法在CentOS 7上为我们的应用程序旋转日志文件。这似乎是由于这个AVC错误:
type=AVC msg=audit(1441112694.305:19502): avc: denied { write } for pid=9146 comm="logrotate" name="autuitive.log" dev="xvda1" ino=26262388 scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
我将错误传递给audit2allow实用程序来创build一个允许它的规则,但是当我尝试启用该规则时,出现以下错误:
[root@app1 ~]# semodule -i logrotate.pp libsepol.print_missing_requirements: logrotate's global requirements were not met: type/attribute logrotate_t (No such file or directory). libsemanage.semanage_link_sandbox: Link packages failed (No such file or directory). semodule: Failed!
这是生成的规则本身:
[root@app1 ~]# cat logrotate.te module logrotate 1.0; require { type logrotate_t; type usr_t; class file write; } #============= logrotate_t ============== allow logrotate_t usr_t:file write;
我认为这是因为系统上已经有一个logrotate.pp文件( /etc/selinux/targeted/modules/active/modules/logrotate.pp )。
您应该使用不同的名称创build本地策略,例如
audit2allow -M MY_logrotate <somefilewithmessages
然后使用
semodule -i MY_logrotate.pp
安装它。 是的,这不是最好的错误消息。