Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect SELinux label on nrpe_ansible.cfg under RHEL/Rocky 8 #36

Open
iay opened this issue Oct 9, 2023 · 0 comments · May be fixed by #38
Open

Incorrect SELinux label on nrpe_ansible.cfg under RHEL/Rocky 8 #36

iay opened this issue Oct 9, 2023 · 0 comments · May be fixed by #38

Comments

@iay
Copy link

iay commented Oct 9, 2023

The way the nrpe_ansible.cfg file is created means that it inherits its SELinux label from the /etc/nagios directory:

[root@r8c nagios]# ls -laZ
total 28
drwxrwxr-x.   2 root root system_u:object_r:nagios_etc_t:s0   46 Oct  9 13:39 .
drwxr-xr-x. 118 root root system_u:object_r:etc_t:s0        8192 Oct  9 13:39 ..
-rw-r--r--.   1 root root system_u:object_r:nagios_etc_t:s0  674 Oct  9 13:39 nrpe_ansible.cfg
-rw-r--r--.   1 root root system_u:object_r:nrpe_etc_t:s0   8229 Oct  9 13:39 nrpe.cfg

Unfortunately this means it isn't readable by the nrpe daemon, resulting in failures if SELinux is in enforcing mode.

I assume that nrpe.cfg escapes this problem either because it already existed as part of the package install, or because there's SELinux support for /etc/nagios/nrpe.cfg specifically. It has the correct label, anyway.

Fixing it seems to be fairly straightforward. I did this in a fork:

# Create nrpe_ansible.cfg
- name: Create nrpe_ansible.cfg from template
  template:
    src: "nrpe_ansible.cfg.j2"
    dest: "{{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg"
    owner: root
    group: root
    mode: 0644
    setype: nrpe_etc_t
  notify: restart nagios-nrpe-server

Adding the setype option results in the following:

[root@r8c nagios]# ls -laZ
total 28
drwxrwxr-x.   2 root root system_u:object_r:nagios_etc_t:s0   46 Oct  9 13:39 .
drwxr-xr-x. 118 root root system_u:object_r:etc_t:s0        8192 Oct  9 13:39 ..
-rw-r--r--.   1 root root system_u:object_r:nrpe_etc_t:s0    674 Oct  9 13:39 nrpe_ansible.cfg
-rw-r--r--.   1 root root system_u:object_r:nrpe_etc_t:s0   8229 Oct  9 13:39 nrpe.cfg

The daemon is now able to read the file and commands are available as expected.

@iay iay linked a pull request Feb 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant