Open llange opened 3 years ago
We have some dirty hacks in the spec file already to make the service file work with ex. sles: https://github.com/naemon/naemon-core/blob/master/naemon-core.spec#L154-L157 However, i'd recommend to first find out whats necessary to get it running with selinux and then see how we can implement that while maintaining backwards compatibility. (right now we still build packages for rhel6)
TLDR; I'm proposing to remove the
su
from systemd unit file in order to make a first step towards running Naemon with SELinux.Details: On a fresh Red Hat Enterprise Linux release 8.3 (Ootpa) with Naemon installed (naemon-core-1.2.4-12.9.x86_64), and SELinux active (
enforcing
) I'm unable to start naemon.while the systemctl information are not helpful, I narrowed it to the use of
su
in the systemd unit file:while investigating further, I understood that the current systemd unit file wants to execute some of the
ExecStartPre
commands as root (mkdir, chown), and the last one as usernaemon
(the one--verify-config
). This dates from commit 6235cd14bb2047456a8e16c2b95aec43035b688f which explains the necessity to drop privileges asap.However, as written, the current systemd unit file is not working (at least in my configuration) with SELinux - because of the use of
su
I found that using a new syntax, introduced in systemd release 231 (Cf NEWS) could help us choosing which of the
ExecStartPre
commands are run with full privileges and which are going to be executed asUser=
(i.e.naemon
) ; thus allowing us to get rid ofsu
.Meanwhile, the
PermissionsStartOnly=true
is now deprecated since systemd release 240 (Cf NEWS) and may be ignored in the future.This is why I suggest the following changes to the unit file:
The downside, of course, is the lack of compatibility with systemd < 231.
If there is interest, I can make a PR.
Note: please understand that this change was not enough for me to run Neamon with SELinux. It's just a first step.