Bug 637555

Summary: Mock selinux plugin creates /proc/filesystems with incorrect permissions
Product: [Fedora] Fedora Reporter: Carl Roth <roth>
Component: mockAssignee: Clark Williams <williams>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: dcantrell, mebrown, nalin, williams
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: mock-1.1.10-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-10-28 22:22:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
untested patch to fix selinux plugiin permissions problems
none
updated patch with modified permissions none

Description Carl Roth 2010-09-26 15:00:56 UTC
Description of problem:

The new(ish) selinux plugin for mock creates /proc/filesystems using a temporary file and bind mount; this temporary file is created by default with 0600 permissions.

As a result, processes inside the chroot running in userland cannot read /proc/filesystems.  This breaks some spec files that need to read /proc/filesystems (e.g. for the 'mlocate' or 'updatedb' tool).

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

mock-1.1.5-1.fc13

How reproducible:

Always

Steps to Reproduce:
1. create a spec file
2. in the %build stanza, add 'wc -l /proc/filesystems'
3. try to build the SRPM using mock
  
Actual results:

SRPM build fails with permissions error

Expected results:


Additional info:

I think the fix is simple (at least, I implemented it with a supplemental mock plugin).  In the selinux preinit hook, there should also be something like

  self.rootObj.mountCmds.append("chmod go+r %s" % self.filesystems)

This opens up the read permissions on the bind-mounted file so that userland processes can read it.

Comment 1 Clark Williams 2010-09-27 14:46:12 UTC
Created attachment 449907 [details]
untested patch to fix selinux plugiin permissions problems

Rather than shell out again, I thought we could just set the permissions after the temp file was created, using os.chmod(). Would you try the attached patch ad see if it fixes your problem?

Comment 2 Carl Roth 2010-09-28 15:01:40 UTC
I verified that this patch works on my system.  Note that the permissions you chose:

  stat.S_IWUSR|stat.S_IRUSR|stat.S_IRGRP|stat.S_IWGRP|stat.S_IROTH|stat.S_IWOTH

are probably too broad.  The actual /proc/filesystems entry AFAIK is only

  stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH

Comment 3 Clark Williams 2010-09-28 15:17:00 UTC
Created attachment 450215 [details]
updated patch with modified permissions

Ahh, good point. I've attached a modified patch which sets permissions to read-only for everyone. 

I'll try and get an update out this week

Comment 4 Clark Williams 2010-10-15 03:25:51 UTC
New version of mock in koji (mock-1.1.6) that contains this fix:

https://koji.fedoraproject.org/koji/buildinfo?buildID=200570

Comment 5 Nalin Dahyabhai 2010-10-15 19:09:47 UTC
This packages fixes it for me.

Comment 6 Fedora Update System 2010-10-20 15:41:18 UTC
mock-1.1.6-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc13

Comment 7 Fedora Update System 2010-10-20 15:41:48 UTC
mock-1.1.6-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc14

Comment 8 Fedora Update System 2010-10-20 15:43:55 UTC
mock-1.0.13-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.13-1.el5

Comment 9 Fedora Update System 2010-10-20 15:46:18 UTC
mock-1.0.13-1.fc12 has been submitted as an update for Fedora 12.
https://admin.fedoraproject.org/updates/mock-1.0.13-1.fc12

Comment 10 Fedora Update System 2010-10-21 05:56:24 UTC
mock-1.1.6-1.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update mock'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc13

Comment 11 Fedora Update System 2010-10-28 22:22:00 UTC
mock-1.1.6-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2010-11-01 20:58:32 UTC
mock-1.1.6-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2010-12-14 16:14:06 UTC
mock-1.0.14-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.14-1.el5

Comment 14 Fedora Update System 2011-01-18 20:04:17 UTC
mock-1.0.15-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.15-1.el5

Comment 15 Fedora Update System 2011-02-20 02:26:27 UTC
mock-1.1.9-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc13

Comment 16 Fedora Update System 2011-02-20 02:29:35 UTC
mock-1.0.16-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.16-1.el5

Comment 17 Fedora Update System 2011-02-20 02:32:27 UTC
mock-1.1.9-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.el6

Comment 18 Fedora Update System 2011-02-20 02:35:20 UTC
mock-1.1.9-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc14

Comment 19 Fedora Update System 2011-03-03 08:25:05 UTC
mock-1.1.9-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Fedora Update System 2011-03-03 08:33:56 UTC
mock-1.1.9-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2011-05-13 20:34:10 UTC
mock-1.1.10-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc15

Comment 22 Fedora Update System 2011-05-13 20:38:49 UTC
mock-1.1.10-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc14

Comment 23 Fedora Update System 2011-05-13 20:43:05 UTC
mock-1.0.17-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.17-1.el5

Comment 24 Fedora Update System 2011-05-13 20:47:23 UTC
mock-1.1.10-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc13

Comment 25 Fedora Update System 2011-05-13 20:51:38 UTC
mock-1.1.10-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.el6

Comment 26 Fedora Update System 2011-05-19 04:35:32 UTC
mock-1.1.10-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 27 Fedora Update System 2011-05-25 02:42:53 UTC
mock-1.1.10-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 28 Fedora Update System 2011-05-25 03:17:14 UTC
mock-1.1.10-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 29 Fedora Update System 2011-06-02 19:07:05 UTC
mock-1.0.17-1.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 30 Fedora Update System 2011-06-02 19:16:59 UTC
mock-1.1.10-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.