Bug 1472715 - Python module rhsm should never call exit()
Python module rhsm should never call exit()
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager (Show other bugs)
7.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Jiri Hnidek
John Sefler
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-19 04:48 EDT by Jiri Hnidek
Modified: 2017-11-20 05:06 EST (History)
3 users (show)

See Also:
Fixed In Version: subscription-manager-1.20.2-1
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Github candlepin/subscription-manager/pull/1668 None None None 2017-07-19 06:30 EDT

  None (edit)
Description Jiri Hnidek 2017-07-19 04:48:19 EDT
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 05:05:33 EST
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 05:06:26 EST
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

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