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 880407

Summary: incorrect SELinux file contexts on /etc/multipath*
Product: Red Hat Enterprise Linux 6 Reporter: Jan Hutař <jhutar>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: agk, bmarzins, dwalsh, dwysocha, dyasny, heinzm, jpazdziora, mmalik, msnitzer, prajnoha, prockai, tlavigne, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.7.19-191.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:32:37 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: 895654    

Description Jan Hutař 2012-11-26 22:29:13 UTC
Description of problem:
I see restorecon dislikes context of /etc/multipath* dir/files.


Version-Release number of selected component (if applicable):
device-mapper-multipath-0.4.9-56.el6_3.1.x86_64


How reproducible:
always


Steps to Reproduce:
1. # restorecon -vRn /etc/multipath*
restorecon reset /etc/multipath/wwids context system_u:object_r:root_t:s0->system_u:object_r:etc_t:s0
restorecon reset /etc/multipath/bindings context system_u:object_r:root_t:s0->system_u:object_r:etc_t:s0
restorecon reset /etc/multipath.conf context system_u:object_r:root_t:s0->system_u:object_r:etc_t:s0


Actual results:
Files do not have correct context.


Expected results:
restorecon should not complain about them.


Additional info:
I have not noted this issue before although I have done same testing in the past so this might be an regression? Or, maybe this is triggered by some update? Maybe something else changed?

I have not checked too much, but `mv ...` commands in rpm scripts are suspicious:

# rpm -q --scripts device-mapper-multipath
postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add multipathd
if [ "$1" -gt "1" -a ! -e /etc/multipath/bindings -a \
    -f /var/lib/multipath/bindings ]; then
	mv /var/lib/multipath/bindings /etc/multipath/bindings
	ln -s /etc/multipath/bindings /var/lib/multipath/bindings
fi
preuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ]; then
	/sbin/service multipathd stop /dev/null 2>&1
	/sbin/chkconfig --del multipathd
fi
postuninstall scriptlet (using /bin/sh):
if [ "$1" -ge "1" ]; then
	/sbin/service multipathd condrestart >/dev/null 2>&1 || :
fi

Comment 3 Ben Marzinski 2012-11-27 03:29:02 UTC
Those moves were done to allow people to safely upgrade and downgrade a device-mapper-multipath package during the switch from using /var/lib/multipath/bindings
to /etc/multipath/bindings.  However, I'm not sure there was ever a RHEL6 release that used /var/lib/multipath/bindings, so they may be completely useless. I'll check.

Comment 4 Ben Marzinski 2012-11-27 22:23:28 UTC
I doubt that the spec file scripts have anything to do with this.  I installed
the package without those files already existing, and when multipathd created them, the bindings wasn't created with the right context. The odd thing is that the wwids file was, and multipathd creates them both, and it uses the exact same function to do it.

# ls -Z /etc/multipath
-rw-------. root root unconfined_u:object_r:lvm_metadata_t:s0 bindings
-rw-------. root root unconfined_u:object_r:etc_t:s0   wwids

I assume that there is an selinux policy reason why they were created differently, but I can't see it.

# grep multipath `rpm -q -l selinux-policy-targeted-3.7.19-139.el6.noarch`
/etc/selinux/targeted/contexts/files/file_contexts:/var/lib/multipath(/.*)?    system_u:object_r:lvm_var_lib_t:s0
/etc/selinux/targeted/contexts/files/file_contexts:/var/cache/multipathd(/.*)? system_u:object_r:lvm_metadata_t:s0
/etc/selinux/targeted/contexts/files/file_contexts:/sbin/multipathd     --     system_u:object_r:lvm_exec_t:s0
/etc/selinux/targeted/contexts/files/file_contexts:/sbin/multipath\.static     --       system_u:object_r:lvm_exec_t:s0
/etc/selinux/targeted/contexts/files/file_contexts:/var/run/multipathd\.sock   -s       system_u:object_r:lvm_var_run_t:s0

punting over to selinux to see if they know the reason for this.  Feel free to reassign this back to device-mapper-multipath if the problem is there.

Comment 5 Miroslav Grepl 2012-11-28 12:45:04 UTC
Ok, there is more issues. The problem is we have

filetrans_pattern(lvm_t, lvm_etc_t, lvm_metadata_t, file)
files_etc_filetrans(lvm_t, lvm_metadata_t, file)


which is a reason why /etc/multipath/bindings was created with lvm_metadata_t in the second case. 

So if it can be created this way and also by init script in the /etc/multipath then we need to have one labeling and run "restorecon" in the postinstall scriptlet.


Or add a label for the /etc/multipath directory.

Comment 6 Daniel Walsh 2012-11-28 15:37:07 UTC
If no other domain uses /etc/multipath, we should probably label the directory as lvm_metadata_t.

Comment 7 Ben Marzinski 2012-11-28 21:12:19 UTC
Only device-mapper-multipath uses /etc/multipath

Comment 8 Miroslav Grepl 2012-11-29 06:44:16 UTC
Ok, could you test it with

# chcon -R -t lvm_metadata_t /etc/multipath

Comment 9 Ben Marzinski 2012-12-13 21:15:10 UTC
Are you just wondering if multipath works o.k. with those contexts? Running the command

# chcon -R -t lvm_metadata_t /etc/multipath

successfully resets the files.

[root@ask-08 ~]# ls -Z /etc/multipath
-rw-------. root root system_u:object_r:lvm_metadata_t:s0 bindings
-rw-------. root root unconfined_u:object_r:lvm_metadata_t:s0 wwids

And multipath works fine with these contexts and selinux set to Enforcing.

Comment 10 Miroslav Grepl 2012-12-14 11:20:39 UTC
Thanks for testing. I added it to Fedora to see if it works.

Comment 13 errata-xmlrpc 2013-02-21 08:32:37 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2013-0314.html