Bug 806457

Summary: If yum runs with no enabled or active repo's, we delete the product cert
Product: Red Hat Enterprise Linux 6 Reporter: Adrian Likins <alikins>
Component: subscription-managerAssignee: Adrian Likins <alikins>
Status: CLOSED CURRENTRELEASE QA Contact: Entitlement Bugs <entitlement-bugs>
Severity: urgent Docs Contact:
Priority: high    
Version: 6.3CC: bkearney, cduryee, cww, dgregor, jlaska, jmolet, jsefler, syeghiay, whayutin
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 807669 812043 812051 (view as bug list) Environment:
Last Closed: 2012-05-30 13:14:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 738066, 807669, 808232, 812043, 812051, 812446    

Description Adrian Likins 2012-03-23 19:43:21 UTC
Description of problem:

<install fresh 6.3>
register subscription-manager
sudo yum localinstall <somelocalrpm>

THE INSTALLED PRODUCT CERT GETS DELETED[1]

Why? Because in that scenario, we have no
"active" repos (ie, repo's that are enabled
and have packages installed) or any 
"enabled" repo's (ie, enabled in yum repo config)

In this case, we end up deleting the installed
product cert (we try to delete product certs
that are not active)

Also, we do not log anywhere that a product
cert has been deleted.

[1] </sefler>

Comment 2 Adrian Likins 2012-03-23 20:16:47 UTC
I have a patch that seems to fix this, and it seems fairly straightforward (well, for being productid.py anyway).

Comment 3 wes hayutin 2012-03-27 19:45:23 UTC
*** Bug 807433 has been marked as a duplicate of this bug. ***

Comment 4 Adrian Likins 2012-03-29 20:36:53 UTC
commit 2b349d3120ba24d4021ed7794c28142caf184ecb
Author: Adrian Likins <alikins>
Date:   Fri Mar 23 16:27:19 2012 -0400

    806457: Fix deletion of productids with yum localinstall
    
    If we encounted a scenario where no repo's were considered
    "enabled" and no "active" repos, we would delete the productid.
    A fresh install running a "yum localinstall" would trigger
    it, since no repo's have been enabled.
    
    Check to verify we are not in this scenario before deleting
    productid's.
    
    Also, add some logging describe which productids are being
    deleted. Previously we had no longer for this.

Comment 7 John Sefler 2012-04-09 21:32:28 UTC
Before verifying a fixed subscription-manager, I want to demonstrate a failing subscription-manager....

Installed version of subscription-manager that fails:
[root@jsefler-r63-workstation ~]# rpm -q subscription-manager
subscription-manager-0.99.10-1.el6.x86_64


Steps to reproduce:
[root@jsefler-r63-workstation ~]# subscription-manager register --username qa
Password: 
The system has been registered with id: dbdeaf1e-4389-4ee9-a0e9-499707ea1d53 
[root@jsefler-r63-workstation ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.

repolist: 0
[root@jsefler-r63-workstation ~]# cat /var/lib/rhsm/productid.js 
{
  "71":"anaconda-RedHatEnterpriseLinux.x86_64"
}
[root@jsefler-r63-workstation ~]# ls /etc/pki/product/
71.pem
[root@jsefler-r63-workstation ~]# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:         	Red Hat Enterprise Linux Workstation
Version:              	6.3 Beta                 
Arch:                 	x86_64                   
Status:               	Not Subscribed           
Starts:               	None                     
Expires:              	None                     

[root@jsefler-r63-workstation ~]# 

^^^ WE ARE CLEANLY REGISTERED AND HAVE AN INSTALLED PRODUCT CERT FOR RHEL

[root@jsefler-r63-workstation ~]# wget -q  http://download.devel.redhat.com/brewroot/packages/zsh/4.3.10/5.el6/x86_64/zsh-4.3.10-5.el6.x86_64.rpm
[root@jsefler-r63-workstation ~]# yum -q -y localinstall zsh-4.3.10-5.el6.x86_64.rpm

Warning: RPMDB altered outside of yum.
[root@jsefler-r63-workstation ~]# rpm -q zsh
zsh-4.3.10-5.el6.x86_64
[root@jsefler-r63-workstation ~]# 

^^^ WE HAVE RUN A LOCAL INSTALL OF AN RPM WITHOUT HAVING ANY ACTIVE REPOS

[root@jsefler-r63-workstation ~]# cat /var/lib/rhsm/productid.js 
{}
[root@jsefler-r63-workstation ~]# ls /etc/pki/product/
[root@jsefler-r63-workstation ~]# subscription-manager list --installed
No installed products to list
[root@jsefler-r63-workstation ~]# 

^^^ OUR RHEL PRODUCT CERT (71.pem) IS GONE.  THAT'S THE BUG.

Comment 8 John Sefler 2012-04-09 21:51:07 UTC
Verifying Version....
[root@jsefler-r63-workstation ~]# rpm -q subscription-manager
subscription-manager-0.99.13-1.el6.x86_64


[root@jsefler-r63-workstation ~]# subscription-manager register --username qa
Password: 
The system has been registered with id: 18c1ad10-831a-45bf-bfff-08f361902b39 
[root@jsefler-r63-workstation ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
repolist: 0
[root@jsefler-r63-workstation ~]# cat /var/lib/rhsm/productid.js
{
  "71":"anaconda-RedHatEnterpriseLinux.x86_64"
}
[root@jsefler-r63-workstation ~]# ls /etc/pki/product/
71.pem
[root@jsefler-r63-workstation ~]# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:         	Red Hat Enterprise Linux Workstation
Product ID:           	71                       
Version:              	6.3 Beta                 
Arch:                 	x86_64                   
Status:               	Not Subscribed           
Starts:               	                         
Expires:              	                         

[root@jsefler-r63-workstation ~]# rpm -q zsh
package zsh is not installed
[root@jsefler-r63-workstation ~]# wget -q http://download.devel.redhat.com/brewroot/packages/zsh/4.3.10/5.el6/x86_64/zsh-4.3.10-5.el6.x86_64.rpm
[root@jsefler-r63-workstation ~]# yum -q -y localinstall zsh-4.3.10-5.el6.x86_64.rpm
Warning: RPMDB altered outside of yum.
[root@jsefler-r63-workstation ~]# rpm -q zsh
zsh-4.3.10-5.el6.x86_64

^^^ A YUM LOCAL INSTALL OF ZSH WAS SUCCESSFUL AS EXPECTED

[root@jsefler-r63-workstation ~]# cat /var/lib/rhsm/productid.js 
{
  "71":"anaconda-RedHatEnterpriseLinux.x86_64"
}
[root@jsefler-r63-workstation ~]# ls /etc/pki/product/
71.pem
[root@jsefler-r63-workstation ~]# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:         	Red Hat Enterprise Linux Workstation
Product ID:           	71                       
Version:              	6.3 Beta                 
Arch:                 	x86_64                   
Status:               	Not Subscribed           
Starts:               	                         
Expires:              	                         

^^^ WITHOUT ANY ENABLED REPOS, THE YUM LOCAL INSTALL OF A PACKAGE DID NOT REMOVE OUR INSTALLED PRODUCT CERT (71.pem).  FIX VERIFIED!

[root@jsefler-r63-workstation ~]# yum -q -y remove zsh
[root@jsefler-r63-workstation ~]# rpm -q zsh
package zsh is not installed
[root@jsefler-r63-workstation ~]# cat /var/lib/rhsm/productid.js 
{
  "71":"anaconda-RedHatEnterpriseLinux.x86_64"
}
[root@jsefler-r63-workstation ~]# ls /etc/pki/product/
71.pem
[root@jsefler-r63-workstation ~]# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:         	Red Hat Enterprise Linux Workstation
Product ID:           	71                       
Version:              	6.3 Beta                 
Arch:                 	x86_64                   
Status:               	Not Subscribed           
Starts:               	                         
Expires:              	                         

[root@jsefler-r63-workstation ~]# 

^^^ EVEN AFTER YUM REMOVING THE PACKAGE, THE PRODUCT CERT REMAINS INSTALLED.


Moving to VERIFIED