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 1715661

Summary: IOError: [Errno 13] Permission denied: '/etc/rhsm/syspurpose/syspurpose.json'
Product: Red Hat Enterprise Linux 7 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED DUPLICATE QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.7   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-31 13:26:50 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:

Description John Sefler 2019-05-30 23:16:35 UTC
Description of problem:
Encountering AVC denials when rhsmcertd-worker tries to write the /etc/rhsm/syspurpose/syspurpose.json file

Version-Release number of selected component (if applicable):
[root@kvm-01-guest10 ~]# rpm -q subscription-manager selinux-policy
subscription-manager-1.24.6-1.el7.x86_64
selinux-policy-3.13.1-246.el7.noarch


How reproducible:
always

Steps to Reproduce:
[root@kvm-01-guest10 ~]# service auditd restart
Stopping logging:                                          [  OK  ]
Redirecting start to /bin/systemctl start auditd.service
[root@kvm-01-guest10 ~]# setenforce 1
[root@kvm-01-guest10 ~]# restorecon -Rv /etc /run /var
restorecon:  Warning no default label for /run/lvmetad.pid
restorecon:  Warning no default label for /run/lock/subsys
restorecon:  Warning no default label for /run/lock/subsys/anamon
restorecon:  Warning no default label for /run/lock/subsys/rhnsd
restorecon:  Warning no default label for /run/lock/subsys/network
restorecon:  Warning no default label for /run/initramfs
restorecon:  Warning no default label for /run/initramfs/rwtab
restorecon:  Warning no default label for /run/initramfs/state
restorecon:  Warning no default label for /run/initramfs/state/var
restorecon:  Warning no default label for /run/initramfs/state/var/lib
restorecon:  Warning no default label for /run/initramfs/state/var/lib/dhclient
restorecon:  Warning no default label for /run/initramfs/state/etc
restorecon:  Warning no default label for /run/initramfs/state/etc/sysconfig
restorecon:  Warning no default label for /run/initramfs/state/etc/sysconfig/network-scripts
restorecon:  Warning no default label for /run/initramfs/.need_shutdown
restorecon:  Warning no default label for /run/initramfs/log
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-yxfkozk.tar.xz
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-yxfkozk.tar.xz.md5
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-ivqwzzp.tar.xz
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-ivqwzzp.tar.xz.md5
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-mqatsfl.tar.xz
restorecon:  Warning no default label for /var/tmp/sosreport-kvm-01-guest10-2019-05-29-mqatsfl.tar.xz.md5
restorecon:  Warning no default label for /var/tmp/systemd-private-51b4d3de5f1946af9ffa452e47b61b06-ntpd.service-GgX7pt
restorecon:  Warning no default label for /var/tmp/systemd-private-51b4d3de5f1946af9ffa452e47b61b06-ntpd.service-GgX7pt/tmp
[root@kvm-01-guest10 ~]# START_DATE_TIME=`date "+%m/%d/%Y %T"`
[root@kvm-01-guest10 ~]# 
[root@kvm-01-guest10 ~]# 
[root@kvm-01-guest10 ~]# 
[root@kvm-01-guest10 ~]# subscription-manager config --logging.default_log_level=DEBUG
[root@kvm-01-guest10 ~]# subscription-manager config --rhsmcertd.splay=0
[root@kvm-01-guest10 ~]# subscription-manager service-level --set="Standard"
service_level_agreement set to "Standard".
[root@kvm-01-guest10 ~]# subscription-manager register --username stage_auto_testuser --serverurl=subscription.rhsm.stage.redhat.com
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Password: 
The system has been registered with ID: 5179b823-5cd8-4681-b1df-397836e28862
The registered system name is: kvm-01-guest10.lab.eng.rdu2.redhat.com
[root@kvm-01-guest10 ~]# systemctl restart rhsmcertd.service
[root@kvm-01-guest10 ~]# sleep 120
[root@kvm-01-guest10 ~]# 
[root@kvm-01-guest10 ~]# 
[root@kvm-01-guest10 ~]# ausearch -m AVC -m USER_AVC -m SELINUX_ERR -i -ts ${START_DATE_TIME}
----
type=PROCTITLE msg=audit(05/30/2019 19:05:50.396:5374) : proctitle=/usr/bin/python /usr/libexec/rhsmcertd-worker 
type=SYSCALL msg=audit(05/30/2019 19:05:50.396:5374) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x7fd801658d24 a1=O_RDWR|O_CREAT|O_TRUNC a2=0666 a3=0xfffffff8 items=0 ppid=2385 pid=2389 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=rhsmcertd-worke exe=/usr/bin/python2.7 subj=system_u:system_r:rhsmcertd_t:s0 key=(null) 
type=AVC msg=audit(05/30/2019 19:05:50.396:5374) : avc:  denied  { write } for  pid=2389 comm=rhsmcertd-worke name=syspurpose.json dev="dm-0" ino=33558018 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file permissive=0 
----
type=PROCTITLE msg=audit(05/30/2019 19:05:51.851:5375) : proctitle=/usr/bin/python /usr/libexec/rhsmcertd-worker --autoheal 
type=SYSCALL msg=audit(05/30/2019 19:05:51.851:5375) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x7fc09a259d74 a1=O_RDWR|O_CREAT|O_TRUNC a2=0666 a3=0xfffffff8 items=0 ppid=2385 pid=2439 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=rhsmcertd-worke exe=/usr/bin/python2.7 subj=system_u:system_r:rhsmcertd_t:s0 key=(null) 
type=AVC msg=audit(05/30/2019 19:05:51.851:5375) : avc:  denied  { write } for  pid=2439 comm=rhsmcertd-worke name=syspurpose.json dev="dm-0" ino=33558018 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file permissive=0 
[root@kvm-01-guest10 ~]# 




Actual results:
  two AVC denials above

Expected results:
  <no matches>

Additional info:

[root@kvm-01-guest10 ~]# tail -f /var/log/rhsm/rhsm.log
2019-05-30 19:05:51,588 [DEBUG] rhsmcertd-worker:2439:MainThread @connection.py:591 - Making request: PUT /subscription/consumers/5179b823-5cd8-4681-b1df-397836e28862
2019-05-30 19:05:51,851 [INFO] rhsmcertd-worker:2439:MainThread @connection.py:638 - Response: status=204, requestUuid=4fcff036-84c4-407c-86f6-9027965f0315, request="PUT /subscription/consumers/5179b823-5cd8-4681-b1df-397836e28862"
2019-05-30 19:05:51,852 [DEBUG] rhsmcertd-worker:2439:MainThread @files.py:381 - Successfully updated remote syspurpose on the server.
2019-05-30 19:05:51,852 [WARNING] rhsmcertd-worker:2439:MainThread @base_action_client.py:71 - Exception caught while running <subscription_manager.syspurposelib.SyspurposeSyncActionInvoker object at 0x7fc09a202ad0> update
2019-05-30 19:05:51,852 [ERROR] rhsmcertd-worker:2439:MainThread @base_action_client.py:72 - [Errno 13] Permission denied: '/etc/rhsm/syspurpose/syspurpose.json'
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/subscription_manager/base_action_client.py", line 62, in _run_update
    update_report = lib.update()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/certlib.py", line 32, in update
    self.report = self.locker.run(self._do_update)
  File "/usr/lib64/python2.7/site-packages/subscription_manager/certlib.py", line 18, in run
    return action()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/syspurposelib.py", line 138, in _do_update
    return action.perform()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/syspurposelib.py", line 199, in perform
    result = store.sync()
  File "/usr/lib/python2.7/site-packages/syspurpose/files.py", line 289, in sync
    self.update_local(local_result),
  File "/usr/lib/python2.7/site-packages/syspurpose/files.py", line 361, in update_local
    return self.update_file(self.path, data)
  File "/usr/lib/python2.7/site-packages/syspurpose/files.py", line 494, in update_file
    f = io.open(path, mode, encoding='utf-8')
IOError: [Errno 13] Permission denied: '/etc/rhsm/syspurpose/syspurpose.json'

Comment 2 John Sefler 2019-05-30 23:36:36 UTC
Good news...
This appears to be fixed by bug 1703573 and the scenario in comment 0 passes when the latest selinux-policy-3.13.1-249.el7.noarch is installed.

Comment 3 John Sefler 2019-05-31 13:26:50 UTC

*** This bug has been marked as a duplicate of bug 1703573 ***