我在 /etc/rsyslog.conf 中有这两个参数
$ModLoad imjournal # provides access to the systemd journal
...
# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on
我遇到了 SELinux 的问题,Rsyslog 记录了这个:
Jun 6 10:53:14 vpod1-logm-front-3 rsyslogd: fopen() failed: 'Permission denied', path: '/var/spool/imjournal.state.tmp' [v8.24.0 try http://www.rsyslog.com/e/2013 ]
我必须添加一个新策略(由 audit2alow 生成)
cat >syslog-imjournal.te << EOF
module syslog-imjournal 1.0;
require {
type syslogd_t;
type var_spool_t;
class dir { add_name remove_name write };
class file { create rename unlink write };
}
#============= syslogd_t ==============
allow syslogd_t var_spool_t:dir write;
allow syslogd_t var_spool_t:dir { add_name remove_name };
allow syslogd_t var_spool_t:file { create rename unlink write };
EOF
checkmodule -m -o syslog-imjournal.m syslog-imjournal.te
semodule_package --module syslog-imjournal.m --outfile syslog-imjournal.pp
semodule --install=syslog-imjournal.pp --priority=400
我不知道这样做是否安全,有没有更好的方法?