Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1750821

Summary: sudo nrpe nagios check still AVCs after bz1653309 fix release
Product: Red Hat Enterprise Linux 8 Reporter: Filip Krska <fkrska>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.4CC: ahogbin, lvrabec, mmalik, ofalk, peter.vreman, plautrba, qe-baseos-security, ssekidde, vmojzis, zpytela
Target Milestone: rcKeywords: Patch, Regression, Reproducer, Triaged
Target Release: 8.2Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1745999 Environment:
Last Closed: 2020-11-04 01:55:53 UTC 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:
Bug Depends On:    
Bug Blocks: 1122832    

Description Filip Krska 2019-09-10 14:19:26 UTC
Reproduces with 

selinux-policy-3.14.1-61.el8
nagios-plugins-nrpe-3.2.1-9.el8
device-mapper-multipath-0.7.8-7.el8_0.2
upstream nagios check-multipath 0.4.7

as well

+++ This bug was initially created as a clone of Bug #1745999 +++

Description of problem:

Even after RHBA-2019:2127 release nagios nrpe checks using sudo still fails with AVCs.


Version-Release number of selected component (if applicable):

selinux-policy-3.13.1-252.el7.1
nagios-plugins-nrpe-3.2.1-8.el7
device-mapper-multipath-0.4.9-127.el7
upstream nagios check-multipath 0.4.7

How reproducible:

Always

Steps to Reproduce:
1. Install nrpe, nagios, nagios-plugins-nrpe, device-mapper-multipath, upstream check-multipath to /usr/local/bin

2. configure

command[check_multipath]=/usr/local/bin/check_multipath -m 4 -o 8 -n ok -g "-XPMEL-,2,4:-XPECC-,2,4:-XPHA-,4,8:"

line in /etc/nagios/nrpe.cfg

3. allow sudo:

# cat /etc/sudoers.d/nagios 
Defaults:NAGIOS	!requiretty
User_Alias	NAGIOS = nagios, nrpe
NAGIOS		ALL=(root) 	NOPASSWD: /sbin/multipath -l

4. cd /lib64/nagios/plugins/

5. setsebool -NP nagios_run_sudo true

6. systemctl start nagios.service

7. systemctl start nrpe.service

8. ./check_nrpe -H 127.0.0.1 -c check_multipath

Actual results:

ERROR: Command failed, 'sudo' not configured for command: '/usr/sbin/multipath -l'? |Host: |


Expected results:

e.g.:

OK<br/>No LUN found or no multipath driver.<br/>


Additional info:

Workaround via `ausearch -c 'multipath' | audit2allow -M my-multipath`, `ausearch -c 'sudo' | audit2allow -M my-sudo` gives:

# cat my-multipath.te 

module my-multipath 1.0;

require {
	type lvm_control_t;
	type nrpe_t;
	type lvm_metadata_t;
	type sysctl_fs_t;
	class file { getattr open read };
	class dir search;
	class chr_file { getattr ioctl open read write };
}

#============= nrpe_t ==============
allow nrpe_t lvm_control_t:chr_file { getattr ioctl open read write };
allow nrpe_t lvm_metadata_t:dir search;
allow nrpe_t sysctl_fs_t:dir search;
allow nrpe_t sysctl_fs_t:file { getattr open read };

# cat my-sudo.te 

module my-sudo 1.0;

require {
	type nrpe_t;
	type initrc_var_run_t;
	class file { lock open read };
}

#============= nrpe_t ==============
allow nrpe_t initrc_var_run_t:file { lock open read };

Comment 5 Peter Vreman 2020-04-09 15:29:29 UTC
For me adding the following selinux rule allow make the nrpe nagios check with sudo working for all commands and not only multipath.
This is the same workaround it had to used rhel7 before the RHBA-2019:2127 was available.

allow init_t nagios_unconfined_plugin_t:dbus send_msg;

Comment 33 errata-xmlrpc 2020-11-04 01:55:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4528