Bug 863483

Summary: Bad SELinux label of passwd file when preparing chroot env using yum
Product: Red Hat Enterprise Linux 6 Reporter: Martin Bukatovic <mbukatov>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: ffesti, james.antill, jzeleny, pmatilai, tcallawa
Target Milestone: rcKeywords: SELinux
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-15 12:57:13 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: 810905    

Description Martin Bukatovic 2012-10-05 15:04:25 UTC
Description of problem:

The passwd file has been assigned wrong selinux label when preparing chroot
enviroment for apache using yum --installroot.

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

# rpm -q yum setup redhat-release-server httpd
yum-3.2.29-30.el6.noarch
setup-2.8.14-16.el6.noarch
redhat-release-server-6Server-6.3.0.3.el6.i686
httpd-2.2.15-15.el6_2.1.i686

Steps to Reproduce:

1. create chroot dir
   mkdir -p /var/tmp/chroot/foobar
2. initialize rpm db there
   mkdir -p /var/tmp/chroot/foobar/var/lib/rpm
   rpm --root /var/tmp/chroot/foobar --initdb
3. install rhel release in chroot
   yumdownloader --destdir=/var/tmp redhat-release-server
   rpm --root /var/tmp/chroot/foobar -ivh --nodeps /var/tmp/redhat-release*rpm
4. install httpd package
   yum --installroot=/var/tmp/chroot/foobar -y install httpd

Actual results:

# ls -lZ /var/tmp/chroot/foobar/etc/passwd
-rw-r--r--. root root unconfined_u:object_r:shadow_t:s0 /var/tmp/chroot/foobar/etc/passwd

Expected results:

# ls -lZ /var/tmp/chroot/foobar/etc/passwd
-rw-r--r--. root root system_u:object_r:etc_t:s0  /var/tmp/chroot/foobar/etc/passwd

Additional info:

Since file /etc/passwd is located in setup package:

# rpm -qf /etc/passwd
setup-2.8.14-16.el6.noarch

I tried to install just setup package in the chroot env (steps are the same,
just installing setup package instead of httpd) and selinux context was set
right. Nevertheless when I additionally installed httpd, the label was broken
again.

When I install httpd normally (without --installroot), label is also ok.

Comment 2 RHEL Program Management 2012-12-14 08:12:41 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 3 Florian Festi 2014-12-15 12:57:13 UTC
For me this looks like the selinux policy is missing in the chroot and is though not honoured during the execution of the scriptlets (which execute adduser). RPM has special code to deal with selinux under this situation but the OS has not.

Installing the selinux policy in the chroot might fix this. Even if not rpm won't be able to fix the way SELinux works within a chroot. I close this for now as NOTABUG.