我在/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
不知道这样做是否安全,有没有更好的方法?
答案1
我认为问题在于您将“imjournal.state”文件存储在错误的位置,因此 SELinux 阻止写入。您不应创建授予过多权限的自定义策略模块,而应使用默认位置,即 /var/lib/rsyslog。默认配置说:
$WorkDirectory /var/lib/rsyslog
$IMJournalStateFile imjournal.state