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 1934076

Summary: Invalid context set for non-standard mount points
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: python-blivetAssignee: Vojtech Trefny <vtrefny>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.3CC: jentrena, jstodola, lmiksik, pdwyer, vtrefny
Target Milestone: rcKeywords: TestCaseNeeded, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: python-blivet-3.2.2-10.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1937650 1962503 (view as bug list) Environment:
Last Closed: 2021-05-18 15:55:03 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: 1937650, 1962503    

Description Renaud Métrich 2021-03-02 13:03:06 UTC
Description of problem:

When installing a system with non-standard mount points such as "/apps", the mount point is created with "etc_runtime_t" label instead of "default_t".

This is due to using the "0" parameter as mode in matchpatchcon() instead of explicitly specifying it's a directory.
Indeed, in the SELinux database, there are 2 rules for "/apps" and related:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
/.*                                                all files          system_u:object_r:default_t:s0 
/[^/]+                                             regular file       system_u:object_r:etc_runtime_t:s0 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Proposed patch:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
--- blivet/util.py.orig	2021-03-02 13:48:58.830329994 +0100
+++ blivet/util.py	2021-03-02 13:49:18.434350915 +0100
@@ -12,6 +12,7 @@
 import hashlib
 import warnings
 import abc
+import stat
 from decimal import Decimal
 from contextlib import contextmanager
 from functools import wraps
@@ -452,7 +453,7 @@
     """ Return the default SELinux context for the given path. """
     context = None
     try:
-        context = selinux.matchpathcon(os.path.normpath(path), 0)[1]
+        context = selinux.matchpathcon(os.path.normpath(path), stat.S_IFDIR)[1]
     except OSError as e:
         log.info("failed to get default SELinux context for %s: %s", path, e)
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------



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

python-blivet-3.2.2-6


How reproducible:

Always


Steps to Reproduce:
1. Use the following kickstart excerpt

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
zerombr
clearpart --all --initlabel
#autopart --type=lvm
bootloader --location=mbr
partition /boot --fstype=xfs --size=512 --ondrive=sda
partition pv.01 --size=1 --ondrive=sda --grow
volgroup root_vg pv.01
logvol swap --fstype=swap --size=1024 --name=swap --vgname=root_vg
logvol / --fstype=xfs --size=10240 --name=root --vgname=root_vg
logvol /apps --fstype=xfs --size=1024 --name=apps --vgname=root_vg --fsoptions 'nodev,nosuid'
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Install and check /apps context while installing

Actual results:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# ls -Zd /mnt/sysimage/apps
system_u:object_r:etc_runtime_t:s0 /mnt/sysimage/apps
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Expected results:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# ls -Zd /mnt/sysimage/apps
system_u:object_r:default_t:s0 /mnt/sysimage/apps
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Comment 15 errata-xmlrpc 2021-05-18 15:55:03 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 (python-blivet 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-2021:1890