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 1876828 - dnf list emits a "[Errno 13] Permission denied: '/var/log/rhsm/rhsm.log" message
Summary: dnf list emits a "[Errno 13] Permission denied: '/var/log/rhsm/rhsm.log" message
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.0
Assignee: mhorky
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-08 09:47 UTC by Greg Kurz
Modified: 2024-12-20 19:15 UTC (History)
7 users (show)

Fixed In Version: subscription-manager-1.28.20-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:37:33 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 2715 0 None Merged [1.28] 1876828: Try to suppress errors in stderr when not run as root 2021-09-17 13:20:37 UTC
Red Hat Product Errata RHBA-2021:4390 0 None None None 2021-11-09 19:37:46 UTC

Description Greg Kurz 2020-09-08 09:47:44 UTC
Description of problem:

The 'dnf list' command complains it cannot log to '/var/log/rhsm/rhsm.log'. This seems a little awkward for a supposedly read-only command.

Version-Release number of selected component (if applicable):

dnf-4.2.23-4.el8.noarch

How reproducible:

100%

Steps to Reproduce:
1. dnf list
2.
3.

Actual results:

2020-09-08 05:44:55,232 [ERROR] dnf:8135:MainThread @logutil.py:194 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:36:02 ago on Tue 08 Sep 2020 05:08:53 AM EDT.
Installed Packages
...

Expected results:

Not root, Subscription Management repositories not updated

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:36:02 ago on Tue 08 Sep 2020 05:08:53 AM EDT.
Installed Packages
...


Additional info:

Same happens with other read-only sub-commands, eg. 'info', 'search' or 'module list'.

Comment 1 Daniel Mach 2020-09-08 11:01:56 UTC
I believe this is caused by calling the subscription-manager plugin. Reassigning to that component.

Comment 3 Rehana 2021-07-29 12:25:19 UTC
Reproducing the issue :
====================

# subscription-manager version
server type: This system is currently not registered.
subscription management server: 3.2.19-1
subscription management rules: 5.41
subscription-manager: 1.28.19-1.el8

# su test

$ yum repolist

2021-07-28 17:46:04,252 [ERROR] yum:16336:MainThread @logutil.py:221 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated

This system is not registered with an entitlement server. You can use subscription-manager to register.

No repositories available

$ dnf module list
2021-07-28 17:46:17,121 [ERROR] dnf:16342:MainThread @logutil.py:221 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated

This system is not registered with an entitlement server. You can use subscription-manager to register.

@modulefailsafe
Name                                      Stream                                       Profiles                                     Summary                                                  
virt                                      rhel [e]                                     common                                       Virtualization module                                    

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

$ dnf info zsh
2021-07-28 17:46:20,357 [ERROR] dnf:16346:MainThread @logutil.py:221 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching Packages to list

Pre-verifying with the fix:
==========================
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.19-1
subscription management rules: 5.41
subscription-manager: 1.28.19-1.git.6.c1dd7c3.el8

switch to a non-root user 
=========================
with the fix when a non-root operates the dnf commands , the error logs will be added to $XDG_CACHE_HOME/rhsm/rhsm.log

$ ll -lh ~/.cache/rhsm/rhsm.log
-rw-rw-r--. 1 test test 0 Jul 29 15:18 /home/test/.cache/rhsm/rhsm.log

$ tail ~/.cache/rhsm/rhsm.log
1) module list 

$ dnf module list
Not root, Subscription Management repositories not updated
Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs)                                                                                                                        406  B/s | 361  B     00:00    
Errors during downloading metadata for repository 'rhel-8-for-x86_64-baseos-beta-rpms':
  - Status code: 403 for https://cdn.redhat.com/content/beta/rhel8/8/x86_64/baseos/os/repodata/repomd.xml (IP: 2.16.212.251)
Error: Failed to download metadata for repo 'rhel-8-for-x86_64-baseos-beta-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

$ tail ~/.cache/rhsm/rhsm.log
2021-07-29 15:19:09,704 [ERROR] dnf:51036:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'

^NOTICE the error log is added to ~/.cache/rhsm/rhsm.log

2) Yum repolist 

$ yum repolist
Not root, Subscription Management repositories not updated
repo id                                                                                      repo name
rhel-8-for-x86_64-appstream-beta-rpms                                                        Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta (RPMs)
rhel-8-for-x86_64-baseos-beta-rpms                                                           Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs)

$ tail ~/.cache/rhsm/rhsm.log
2021-07-29 15:19:09,704 [ERROR] dnf:51036:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:29,793 [ERROR] yum:51048:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'

^NOTICE the error log is added to ~/.cache/rhsm/rhsm.log

3) package info

$ dnf info zsh
Not root, Subscription Management repositories not updated
Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs)                                                                                                                        115  B/s | 361  B     00:03    
Errors during downloading metadata for repository 'rhel-8-for-x86_64-baseos-beta-rpms':
  - Status code: 403 for https://cdn.redhat.com/content/beta/rhel8/8/x86_64/baseos/os/repodata/repomd.xml (IP: 2.16.212.251)
Error: Failed to download metadata for repo 'rhel-8-for-x86_64-baseos-beta-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

$ tail ~/.cache/rhsm/rhsm.log
2021-07-29 15:19:09,704 [ERROR] dnf:51036:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:29,793 [ERROR] yum:51048:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:39,117 [ERROR] dnf:51055:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'

^NOTICE the error log is added to ~/.cache/rhsm/rhsm.log

4) Install pacakges

$ yum install zsh
Not root, Subscription Management repositories not updated
Error: This command has to be run with superuser privileges (under the root user on most systems).

$ tail ~/.cache/rhsm/rhsm.log
2021-07-29 15:19:09,704 [ERROR] dnf:51036:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:29,793 [ERROR] yum:51048:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:39,117 [ERROR] dnf:51055:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-07-29 15:19:47,672 [ERROR] yum:51061:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'


^NOTICE the error log is added to ~/.cache/rhsm/rhsm.log


Based on the above observation preverifying the bug .

Comment 6 Rehana 2021-08-09 14:28:37 UTC
Verifying on :

# rpm -qa subscription-manager --changelog | grep 1876828
- 1876828: Try to suppress errors in stderr when not run as root

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.19-1
subscription management rules: 5.41
subscription-manager: 1.28.20-1.el8

# subscription-manager register --auto-attach --username=**** --password=*****
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
The system has been registered with ID: *********
The registered system name is: *********
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status:       Subscribed

# su - test
Last login: Mon Aug  9 10:23:46 EDT 2021 on pts/0

$ yum repolist
Not root, Subscription Management repositories not updated
repo id                                repo name
rhel-8-for-x86_64-appstream-beta-rpms  Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta (RPMs)
rhel-8-for-x86_64-baseos-beta-rpms     Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs)

$ ll -lh ~/.cache/rhsm/rhsm.log
-rw-rw-r--. 1 test test 220 Aug  9 10:23 /home/test/.cache/rhsm/rhsm.log

$ dnf module list
Not root, Subscription Management repositories not updated
Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta (RPMs)        621  B/s | 512  B     00:00    
Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs)           571  B/s | 512  B     00:00    
@modulefailsafe
Name                Stream                 Profiles               Summary                            
virt                rhel [e]               common                 Virtualization module              

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

$ dnf info zsh
Not root, Subscription Management repositories not updated
Last metadata expiration check: 0:00:15 ago on Mon 09 Aug 2021 10:26:08 AM EDT.
Error: No matching Packages to list

$ yum install zsh
Not root, Subscription Management repositories not updated
Error: This command has to be run with superuser privileges (under the root user on most systems)

$ tail ~/.cache/rhsm/rhsm.log
2021-08-09 10:23:56,035 [ERROR] yum:16613:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-08-09 10:26:06,561 [ERROR] dnf:16669:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-08-09 10:26:23,064 [ERROR] dnf:16686:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'
2021-08-09 10:26:47,414 [ERROR] yum:16698:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'

^^ Notice now the error logs are added to ~/.cache/rhsm/rhsm.log location . Based on the above observation, moving the bug to Verified!!

Comment 9 errata-xmlrpc 2021-11-09 19:37:33 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 (subscription-manager bug fix and enhancement update), 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-2021:4390


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