Bug 2109666

Summary: nagios-selinux actually confines "unconfined" Nagios plugins
Product: [Fedora] Fedora EPEL Reporter: Ben Webb <benmwebb>
Component: nagiosAssignee: Guido Aulisi <guido.aulisi>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: epel9CC: agibson2, b.heden, guido.aulisi, jose.p.oliveira.oss, pessoft, redhat, shawn.starr, smooge, s, swilkerson, tjb
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ben Webb 2022-07-21 18:29:59 UTC
Description of problem:
The nagios-selinux package replaces the system nagios SELinux module with one
that appears to prohibit most common Nagios operations. "Unconfined" plugins
such as check_procs do not work at all without disabling SELinux.

I have a small reproducer below that uses NRPE rather than a full Nagios
install. Plugins work normally with the default selinux-policy-targeted, but
fail if nagios-selinux is installed.

Version-Release number of selected component (if applicable):
nagios-selinux-4.4.6-7.el9~bootstrap.noarch

How reproducible:
Always

Steps to Reproduce:
% dnf install nrpe nagios-plugins-procs nagios-plugins-nrpe
% systemctl start nrpe
% /usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_total_procs
PROCS OK: 113 processes | procs=113;150;200;0;
% dnf install nagios-selinux
% /usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_total_procs
Unable to read output
% grep avc /var/log/audit/audit.log |tail -1
type=AVC msg=audit(1658426463.166:127): avc:  denied  { execute } for  pid=1792 comm="check_procs" name="ps" dev="dm-0" ino=4330077 scontext=system_u:system_r:nagios_unconfined_plugin_t:s0 tcontext=system_u:object_r:bin_t:s0 tclass=file permissive=0

Actual results:
nagios_unconfined_plugin_t plugins such as check_procs are denied by SELinux.

Expected results:
Plugins work without SELinux denials.

Additional info:
I see similar avc denials for virtually every plugin on my full Nagios server,
but these all go away and everything works normally (at least for me) if I
rpm -e --nodeps nagios-selinux

My Nagios install worked before with RHEL 8.6, but I notice the nagios
RPM didn't require nagios-selinux at that time (and I didn't have it installed).

Comment 1 static 2022-10-14 05:01:24 UTC
I was looking into what to upgrade centos7 to in the future for Nagios and I ran into this testing on 9 also.  The host check doesn't even work (check_ping).  I tried fixing all the AVC denials for it using setroubleshoot and the ausearch/semodule -i but pinging still didn't work unless I disable selinux completely.

Comment 2 static 2022-10-14 05:02:29 UTC
I meant setting selinux to permissive.  It didn't require disabling it with the kernel parameter to do that.