Bug 1963151

Summary: Yum/dnf commands fail for non root user
Product: Red Hat Enterprise Linux 8 Reporter: Rehana <redakkan>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED WORKSFORME QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.5Keywords: Regression, Triaged
Target Milestone: beta   
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: 2021-05-25 14:47:48 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 Rehana 2021-05-21 14:59:36 UTC
Description of problem:
It observed that a non-root user on RHEL 8.5 system is unable to get package info/yum module list commands working 

Version-Release number of selected component (if applicable):
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.18-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.git.19.dfbe16a.el8

How reproducible:
Always 

Steps to Reproduce:
1.Register and subscribe system has root user on the system 
# 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
Status:       Subscribed

# ll /etc/pki/entitlement/
total 36
-rw-r--r--. 1 root root  3243 May 21 16:44 7011679953934151011-key.pem
-rw-r--r--. 1 root root 30739 May 21 16:44 7011679953934151011.pem

# subscription-manager list --consumed
+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)
Provides:            Red Hat CodeReady Linux Builder for x86_64
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat Enterprise Linux Atomic Host Beta
                     Red Hat Developer Tools (for RHEL Server)
                     Red Hat Container Images
                     Red Hat Developer Tools Beta (for RHEL Server)
                     Red Hat Container Images Beta
                     Red Hat Developer Toolset (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server) - Extended Update Support
                     Red Hat Enterprise Linux for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64 - Extended Update Support
                     dotNET on RHEL (for RHEL Server)
                     Red Hat Enterprise Linux for x86_64 - Extended Update Support
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended Update Support
                     Red Hat Beta
                     Red Hat EUCJP Support (for RHEL Server) - Extended Update Support
                     Oracle Java (for RHEL Server)
                     Red Hat Software Collections (for RHEL Server)
                     Oracle Java (for RHEL Server) - Extended Update Support
                     Red Hat CodeReady Linux Builder for x86_64 - Extended Update Support
                     Red Hat S-JIS Support (for RHEL Server) - Extended Update Support
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux High Availability for x86_64 - Extended Update Support
                     Red Hat Ansible Engine
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update Support
                     Red Hat Enterprise Linux Server
SKU:                 RH00003
Contract:            12112971
Account:             6367075
Serial:              4278622619648722235
Pool ID:             8a99f9ad795d50e901797ef81f4d061c
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:        L1-L3
Roles:               Red Hat Enterprise Linux Server
Service Level:       Premium
Usage:               Production
Add-ons:             
Status Details:      Subscription is current
Subscription Type:   Instance Based
Starts:              05/18/2021
Ends:                05/17/2022
Entitlement Type:    Physical


2.Execute yum clean 

# yum clean all
Updating Subscription Management repositories.
0 files removed
3.Switch to non-root user and execute yum info commands 

# su tester
$ yum info zsh
2021-05-21 10:51:14,360 [ERROR] yum:170607:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-21 10:51:14,362 [ERROR] yum:170607: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'
Error: No matching Packages to list

$ yum module list postgresql
2021-05-21 10:51:21,853 [ERROR] yum:170611:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-21 10:51:21,855 [ERROR] yum:170611: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'
Error: No matching Modules to list

Actual results:
non-root user unable to see the informations on package and modules 

Expected results:

non-root user is able to see the informations on package and modules 

Additional info:
The same works for the root user ( Demonstrating it below to show the attached subscription has content available) 

# yum info zsh
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                        39 MB/s |  30 MB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                           39 MB/s |  32 MB     00:00    
Last metadata expiration check: 0:00:06 ago on Fri 21 May 2021 10:56:02 AM EDT.
Available Packages
Name         : zsh
Version      : 5.5.1
Release      : 6.el8_1.2
Architecture : x86_64
Size         : 2.9 M
Source       : zsh-5.5.1-6.el8_1.2.src.rpm
Repository   : rhel-8-for-x86_64-baseos-rpms
Summary      : Powerful interactive shell
URL          : http://zsh.sourceforge.net/
License      : MIT
Description  : The zsh shell is a command interpreter usable as an interactive login
             : shell and as a shell script command processor.  Zsh resembles the ksh
             : shell (the Korn shell), but includes many enhancements.  Zsh supports
             : command line editing, built-in spelling correction, programmable
             : command completion, shell functions (with autoloading), a history
             : mechanism, and more.

[root@kvm-04-guest19 tester]# yum module list postgresql
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:14 ago on Fri 21 May 2021 10:56:02 AM EDT.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Name                         Stream                   Profiles                             Summary                                             
postgresql                   9.6                      client, server [d]                   PostgreSQL server and client module                 
postgresql                   10 [d]                   client, server [d]                   PostgreSQL server and client module                 
postgresql                   12                       client, server [d]                   PostgreSQL server and client module                 
postgresql                   13                       client, server [d]                   PostgreSQL server and client module                 

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


Additional Notes 2 :

The failure is observed in the downstream build , in the lasted brew build I can not reproduce the failure 
==============================

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

# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux for x86_64
Product ID:     479
Version:        8.5
Arch:           x86_64
Status:         Subscribed
Status Details: 
Starts:         05/18/2021
Ends:           05/18/2022

# yum clean all
Updating Subscription Management repositories.
0 files removed

# su tester

$ yum info zsh
2021-05-21 16:50:44,028 [ERROR] yum:21521:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-21 16:50:44,030 [ERROR] yum:21521: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'
No read/execute access in current directory, moving to /
Last metadata expiration check: 0:03:53 ago on Fri 21 May 2021 04:46:51 PM CEST.
Available Packages
Name         : zsh
Version      : 5.5.1
Release      : 6.el8_1.2
Architecture : x86_64
Size         : 2.9 M
Source       : zsh-5.5.1-6.el8_1.2.src.rpm
Repository   : rhel-8-for-x86_64-baseos-rpms
Summary      : Powerful interactive shell
URL          : http://zsh.sourceforge.net/
License      : MIT
Description  : The zsh shell is a command interpreter usable as an interactive login
             : shell and as a shell script command processor.  Zsh resembles the ksh
             : shell (the Korn shell), but includes many enhancements.  Zsh supports
             : command line editing, built-in spelling correction, programmable
             : command completion, shell functions (with autoloading), a history
             : mechanism, and more.

$ yum module list postgresql
2021-05-21 16:50:52,633 [ERROR] yum:21525:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-21 16:50:52,635 [ERROR] yum:21525: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'
No read/execute access in current directory, moving to /
Last metadata expiration check: 0:04:02 ago on Fri 21 May 2021 04:46:51 PM CEST.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Name                         Stream                   Profiles                             Summary                                             
postgresql                   9.6                      client, server [d]                   PostgreSQL server and client module                 
postgresql                   10 [d]                   client, server [d]                   PostgreSQL server and client module                 
postgresql                   12                       client, server [d]                   PostgreSQL server and client module                 
postgresql                   13                       client, server [d]                   PostgreSQL server and client module                 

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

Comment 1 Rehana 2021-05-25 14:47:48 UTC
The issue appears to be solved in the latest compose : 
========================================

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.18-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.git.19.dfbe16a.el8

# rpm -q dnf
dnf-4.4.2-11.el8.noarch

# yum clean all
Updating Subscription Management repositories.
0 files removed

# su tester
$ yum info zsh
2021-05-25 10:45:44,775 [ERROR] yum:17147:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-25 10:45:44,777 [ERROR] yum:17147: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'
No read/execute access in current directory, moving to /
Last metadata expiration check: 0:00:55 ago on Tue 25 May 2021 10:44:50 AM EDT.
Available Packages
Name         : zsh
Version      : 5.5.1
Release      : 6.el8_1.2
Architecture : x86_64
Size         : 2.9 M
Source       : zsh-5.5.1-6.el8_1.2.src.rpm
Repository   : rhel-8-for-x86_64-baseos-rpms
Summary      : Powerful interactive shell
URL          : http://zsh.sourceforge.net/
License      : MIT
Description  : The zsh shell is a command interpreter usable as an interactive login
             : shell and as a shell script command processor.  Zsh resembles the ksh
             : shell (the Korn shell), but includes many enhancements.  Zsh supports
             : command line editing, built-in spelling correction, programmable
             : command completion, shell functions (with autoloading), a history
             : mechanism, and more.

$ yum module list postgresql
2021-05-25 10:45:51,202 [ERROR] yum:17153:MainThread @logutil.py:200 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
Not root, Subscription Management repositories not updated
2021-05-25 10:45:51,206 [ERROR] yum:17153: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'
No read/execute access in current directory, moving to /
Last metadata expiration check: 0:01:01 ago on Tue 25 May 2021 10:44:50 AM EDT.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Name                         Stream                   Profiles                             Summary                                              
postgresql                   9.6                      client, server [d]                   PostgreSQL server and client module                  
postgresql                   10 [d]                   client, server [d]                   PostgreSQL server and client module                  
postgresql                   12                       client, server                       PostgreSQL server and client module                  
postgresql                   13                       client, server                       PostgreSQL server and client module                  

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