Bug 1136163
| Summary: | SELinux is preventing /usr/bin/python2.7 from 'read' accesses on the directory . | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Matěj Cepl <mcepl> |
| Component: | subscription-manager | Assignee: | candlepin-bugs |
| Status: | CLOSED NOTABUG | QA Contact: | Sean Toner <stoner> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.0 | CC: | alikins, crog, jsefler, mcepl, mgrepl, stoner, vbenes, wpoteat |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Unspecified | ||
| Whiteboard: | abrt_hash:de0ab578ec3d01cc08d243af9fb43b92a9a0b93f23e59247ca379880b331b365 | ||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-09-08 13:12:28 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: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1121117 | ||
-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.
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. 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
I tried to replicate the problem with the following: 1) I took out the -Es change in rhsmcertd-worker.py 2) I tried 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? 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. 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. 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. The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days |
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