Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1136163 - SELinux is preventing /usr/bin/python2.7 from 'read' accesses on the directory .
Summary: SELinux is preventing /usr/bin/python2.7 from 'read' accesses on the directory .
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager
Version: 7.0
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: candlepin-bugs
QA Contact: Sean Toner
URL:
Whiteboard: abrt_hash:de0ab578ec3d01cc08d243af9fb...
Depends On:
Blocks: rhsm-rhel72
TreeView+ depends on / blocked
 
Reported: 2014-09-02 04:56 UTC by Matěj Cepl
Modified: 2023-09-12 00:40 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-09-08 13:12:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Matěj Cepl 2014-09-02 04:56:09 UTC
Description of problem:
Perhaps it is because I have never registered my system with RHN (because I use it over internal yum repos).
SELinux is preventing /usr/bin/python2.7 from 'read' accesses on the directory .

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that python2.7 should be allowed read access on the  directory by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep rhsmcertd-worke /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:rhsmcertd_t:s0
Target Context                unconfined_u:object_r:gconf_home_t:s0
Target Objects                 [ dir ]
Source                        rhsmcertd-worke
Source Path                   /usr/bin/python2.7
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           python-2.7.5-16.el7.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.12.1-153.el7_0.10.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 3.10.0-123.el7.x86_64 #1 SMP Mon
                              May 5 11:16:57 EDT 2014 x86_64 x86_64
Alert Count                   5
First Seen                    2014-09-01 17:04:39 CEST
Last Seen                     2014-09-02 04:45:30 CEST
Local ID                      69afdfbd-265f-4184-bd93-f7546dbe14dc

Raw Audit Messages
type=AVC msg=audit(1409625930.332:1876): avc:  denied  { read } for  pid=14967 comm="rhsmcertd-worke" name="site-packages" dev="dm-0" ino=426143 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=unconfined_u:object_r:gconf_home_t:s0 tclass=dir


type=SYSCALL msg=audit(1409625930.332:1876): arch=x86_64 syscall=openat success=yes exit=EIO a0=ffffffffffffff9c a1=a36b10 a2=90800 a3=0 items=0 ppid=1700 pid=14967 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=rhsmcertd-worke exe=/usr/bin/python2.7 subj=system_u:system_r:rhsmcertd_t:s0 key=(null)

Hash: rhsmcertd-worke,rhsmcertd_t,gconf_home_t,dir,read

Additional info:
reporter:       libreport-2.1.11
hashmarkername: setroubleshoot
kernel:         3.10.0-123.el7.x86_64
type:           libreport

Comment 2 Miroslav Grepl 2014-09-03 11:31:50 UTC
 -E     Ignore  environment  variables like PYTHONPATH and PYTHONHOME that modify the
              behavior of the interpreter.

-s     Don't add user site directory to sys.path.

Comment 4 Adrian Likins 2015-07-09 13:48:46 UTC
Some notes before I forget: Issue seems to originate from having a PYTHONPATH or PYTHONHOME set (or other mechanisms that add paths to the pythonpath), so /usr/bin/python[2.7] ends up attempting to read files from those paths as part of it's module discovery, but the selinux policy for rhsmcertd does not allow that, causing the AVC denials.

The suggestion for '-E' and '-s' for rhsmcertd-worker.py should work. Could also attempt to scrub python path altering env vars from rhsmcertd's env before/while invoking rhsmcertd-worker, but I suspect '-E -s' will cover more cases.

Comment 5 Adrian Likins 2015-07-09 19:06:29 UTC
pr at https://github.com/candlepin/subscription-manager/pull/1221

Comment 6 Chris "Ceiu" Rog 2015-07-23 18:35:53 UTC
commit 7c066d0a155c122f451f1a3a255b9140e02ae894
Author: Adrian Likins <alikins>
Date:   Thu Jul 9 14:59:47 2015 -0400

    1136163: Ignore pythonpath to avoid selinux AVCs
    
    For rhsmcertd-worker.py in particular, since it runs
    as a child of rhsmcertd, which has very restrictive
    selinux policy by default.
    
    Because of either PYTHONPATH env var or system/site/user
    changes to the pythonpath, rhsmcertd-worker.py could
    end up attempting to find and open modules in path
    that the selinux policy prevents it from accessing.
    
    If the path ended up including '.', it would attempt
    to read from cwd and cause denials.
    
    So specify the '-E' and '-s' args to /usr/bin/python
    -E     : ignore PYTHON* environment variables (such as PYTHONPATH)
    -s     : don't add user site directory to sys.path; also
             PYTHONNOUSERSITE

Comment 8 Sean Toner 2015-08-25 18:16:04 UTC
I tried to replicate the problem with the following:

1) I took out the -Es change in rhsmcertd-worker.py
2) I tried

Comment 9 Sean Toner 2015-08-25 18:18:30 UTC
Accidentally hit save too soon :)

2) I did:  export PYTHONPATH="."
3) from /usr directory ran:  systemctl restart rhsmcertd

And nothing happened. I am not sure what directory root will be prevented having read access by selinux.  Alternatively, if I use a non-root user, how can I start rhsmcertd without an effective UID of root?

Comment 10 John Sefler 2015-08-26 19:42:13 UTC
The fix from comment 6 is available in subscription-manager-1.15.8-1 or newer.

NEEDINFO from reporter as we not been able to reproduce the original error.
Please confirm that upgrading to subscription-manager-1.15.8-1 or newer resolves the AVC denial.

Comment 11 Sean Toner 2015-09-08 13:12:28 UTC
We have tried to reproduce the problem but without any success.  also, the reporter of the problem has also not been working with subscription manager and was unable to reproduce it as well.

We have tested the -Es args passed to the python process argument which was the purported fix for the problem, and it does not seem to cause any other undue effects.

If the problem re-occurs, we can reopen this bug.

Comment 12 Matěj Cepl 2015-09-14 16:09:30 UTC
Yes with subscription-manager-gui-1.15.9-7.el7.x86_64 and subscription-manager-1.15.9-7.el7.x86_64 I can work without making SELinux angry. And it is always a way faster.

Comment 15 Red Hat Bugzilla 2023-09-12 00:40:03 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days


Note You need to log in before you can comment on or make changes to this bug.