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 1472715 - Python module rhsm should never call exit()
Summary: Python module rhsm should never call exit()
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager
Version: 7.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jiri Hnidek
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-19 08:48 UTC by Jiri Hnidek
Modified: 2018-04-10 09:50 UTC (History)
3 users (show)

Fixed In Version: subscription-manager-1.20.2-1
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2018-04-10 09:49:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 1668 0 None None None 2017-07-19 10:30:09 UTC
Red Hat Product Errata RHBA-2018:0681 0 None None None 2018-04-10 09:50:47 UTC

Description Jiri Hnidek 2017-07-19 08:48:19 UTC
Description of problem:
Python module rhsm is used by other projects (e.g. virt-who) and it should not call exit(), but it should raise some exception, because application using rhsm module cannot resurrect from calling exit() by some external module.

Version-Release number of selected component (if applicable):
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.37-1
subscription management rules: 5.24.1
subscription-manager: 1.19.12-1.el7
python-rhsm: 1.19.6-1.el7

How reproducible:
always


Steps to Reproduce:
1. Start Python interpreter:

$ python

2. Import rhsm submodule called 'certificate'

>>> import python_rhsm.certificate

3. Try to get certificate from some non-existent file:

>>> c = python_rhsm.certificate.create_from_file('/foo/non_existing_cert.pem')
No such file or directory

Actual results:
Python interpreter is terminated as well any other program trying to do similar thing.

Expected results:
Calling python_rhsm.certificate.create_from_file('/foo/non_existing_cert.pem') should raise some exception.

Additional info:
This can happen in production, when system is not registered and there is no file: /etc/pki/consumer/cert.pem. There are no other exit() call in rhsm module only one in: python-rhsm/src/rhsm/certificate2.py

Comment 4 Shwetha Kallesh 2017-11-20 10:05:33 UTC
Reproducer:

[root@hp-ms-01-c15 ~]# subscription-manager  register --serverurl subscription.rhsm.stage.redhat.com
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: shwetha_tier1_test
Password: 
The system has been registered with ID: 12a574bf-3a83-4a23-8b28-785d2b0d1507 
[root@hp-ms-01-c15 ~]# su shwetha --command 'rct cat-cert /etc/pki/consumer/cert.pem'
Permission denied
[root@hp-ms-01-c15 ~]# subscription-manager  version
server type: Red Hat Subscription Management
subscription management server: 2.0.43-1
subscription management rules: 5.26
subscription-manager: 1.19.21-1.el7
python-rhsm: 1.19.9-1.el7

Comment 5 Shwetha Kallesh 2017-11-20 10:06:26 UTC
Verification:

[root@dhcp35-10 ~]# su shwetha --command 'rct cat-cert /etc/pki/consumer/cert.pem'
Unable to read certificate file '/etc/pki/consumer/cert.pem': Error loading certificate: [Errno 13] Permission denied: '/etc/pki/consumer/cert.pem'


[root@dhcp35-10 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.43-1
subscription management rules: 5.26
subscription-manager: 1.20.5-1.el7

Comment 8 errata-xmlrpc 2018-04-10 09:49:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0681


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