Open atc0005 opened 6 years ago
Workaround for anyone landing here affected by the change in the current 8.33.0 package:
sudo mkdir -p /etc/systemd/system/rsyslog.service.d
sudo nano /etc/systemd/system/rsyslog.service.d/10-enable-creation-of-pid-file.conf
sudo systemctl daemon-reload
sudo systemctl restart rsyslog
Here is the content to put into the /etc/systemd/system/rsyslog.service.d/10-enable-creation-of-pid-file.conf
file:
# /etc/systemd/system/rsyslog.service.d/10-enable-creation-of-pid-file.conf
[Service]
# Upstream package choice:
#ExecStart=/usr/sbin/rsyslogd -n -iNONE
# Our override (options prior to 8.33.0 release):
ExecStart=
ExecStart=/usr/sbin/rsyslogd -n
A little late to this, but yesterday I added a change to the logrotate script, so the HUP will now be triggered by:
systemctl kill -s HUP rsyslog.service
as @mbiebl described here: https://github.com/rsyslog/rsyslog/commit/6fafe7c9965449e270fcd4d87eeda4689f0df1d6. That should fix it, right?
systemctl kill -s HUP rsyslog.service
fails with current rhel7 selinux policies:
type=USER_AVC msg=audit(1527989823.315:169170): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { stop } for auid=0 uid=0 gid=0 path="/usr/lib/systemd/system/rsyslog.service" cmdline="systemctl kill -s HUP rsyslog.service" scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
so workaround given by atc0005 still the best (?) solution here for RHEL SELinux folks
[root@RHEL7 ~]# cat test.log | audit2why
type=USER_AVC msg=audit(1527989823.315:169170): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { stop } for auid=0 uid=0 gid=0 path="/usr/lib/systemd/system/rsyslog.service" cmdline="systemctl kill -s HUP rsyslog.service" scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
Was caused by:
Unknown - would be allowed by active policy
Possible mismatch between this policy and the one under which the audit message was generated.
Possible mismatch between current in-memory boolean settings vs. permanent ones.
And to allow:
[root@RHEL7 ~]# cat test.log | audit2allow
#============= logrotate_t ==============
#!!!! This avc is allowed in the current policy
allow logrotate_t systemd_unit_file_t:service stop;
regarding systemd_unit_file_t it looks like logrotate_t is almost in "god mode":
sesearch -AC -s logrotate_t -t systemd_unit_file_t -c service
Found 2 semantic av rules:
allow logrotate_t systemd_unit_file_t : service { start stop status reload enable disable } ;
allow logrotate_t systemd_unit_file_type : service { start status reload } ;
so it kinda strange stop isn't already there. but i will always choose workaround with pid file over selinux module because it affects only rsyslog. giving logrotate_t power to potentially shutdown any systemd service (while it lacks of that power currently -- and yes, it is already almost "god" now) is totally another level of workaround. personally -- i'll stick with pid file in such case
if logrotate has the ability to send rsyslog the HUP signal, it also has the ability to send it TERM or KILL
David Lang
well, in current selinux policies stop is right there and it wasn't there before...
all i was trying to say is if i had to choose between those two workarounds i wouldn't choose selinux module as it changes not only rsyslog stuff. it broadens capabilities beyond rsyslog case
nowadays rsyslog creates pid file and policies have "stop" ability. no more problems, life is good again...
no disagreement about not wanting to rely on selinux and systemd.
Short version:
Details:
From the
/etc/logrotate.d/syslog
file on a CentOS 7 system:[root@centos7-test init.d]# ls -l /var/run/syslogd.pid
[root@centos7-test init.d]# systemctl status rsyslog
According to rpm, the faulty
/etc/logrotate.d/syslog
file is owned by the latest 8.33.0 package:[root@centos7-test init.d]# rpm -qf /etc/logrotate.d/syslog
See also rsyslog/rsyslog-pkg-ubuntu#74 and rsyslog/rsyslog#2143