Bug 1281593

Summary: [BACKPORT] read yum-fs vars
Product: Red Hat Enterprise Linux 7 Reporter: Pat Riehecky <riehecky>
Component: yumAssignee: Michal Domonkos <mdomonko>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: csieh, emrakova, james.antill, mdomonko, misterbonnie, vmukhame
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: yum-3.4.3-138.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1335516 (view as bug list) Environment:
Last Closed: 2016-11-04 05:30:20 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:
Bug Depends On: 1327561    
Bug Blocks:    
Attachments:
Description Flags
Patch to fix none

Description Pat Riehecky 2015-11-12 21:27:19 UTC
Description of problem:
Can upstream commit, 22271bf34e71bbfc75d0a59354fc0108e004f36c, which re-reads yum-fs vars be backported to yum

Version-Release number of selected component (if applicable):yum-3.4.3-125.el7


How reproducible:100%


Steps to Reproduce:
1.
2.
3.

Actual results:
yum fs vars are not read as expected

Expected results:
yum fs vars are read as expected

Additional info:
http://yum.baseurl.org/gitweb?p=yum.git;a=commit;h=22271bf34e71bbfc75d0a59354fc0108e004f36c

Comment 2 Pat Riehecky 2016-02-01 16:45:52 UTC
Created attachment 1120191 [details]
Patch to fix

The attached patch should resolve the issue

Comment 4 Michal Domonkos 2016-04-15 09:35:20 UTC
Hi Karel,

Previously, yum wouldn't expand fsvars used in include= lines in /etc/yum.conf or repo files.  That's what this commit is fixing.  Here's a reproducer:

# echo debuglevel=10 > /root/foo.conf
# echo foo > /etc/yum/vars/myvar
# echo 'include=/root/$myvar.conf' >> /etc/yum.conf
# yum repolist  # or whichever yum subcommand

Before the patch, yum would terminate with this error message:

CRITICAL:yum.cli:Config error: Error accessing file for config file:///root/$myvar.conf

After the patch, the command (yum repolist in this case) should succeed and the configuration from /root/foo.conf should be applied (being more verbose in this case).

Comment 5 Michal Domonkos 2016-04-15 09:51:27 UTC
Actually, there was a small typo in the original commit that got fixed subsequently in upstream:

diff --git a/yum/config.py b/yum/config.py
index 1b5a11d..8eab5bc 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -1061,7 +1061,7 @@ def readStartupConfig(configfile, root, releasever=None):
     confpp_obj = ConfigPreProcessor(configfile)

     yumvars = _getEnvVar()
-    _read_yumvars(yumvars, yumconf.installroot)
+    _read_yumvars(yumvars, startupconf.installroot)
     confpp_obj._vars = yumvars
     startupconf.yumvars = yumvars

So we should backport both commits, that is:

22271bf34e71bbfc75d0a59354fc0108e004f36c
1ccd91f4b195737d6bb1bdfabcbf3714de1d9b85

Apparently, Pat noticed the issue too and fixed that in a different way in the attached patch (thanks!):

@@ -1044,6 +1061,8 @@ def readStartupConfig(configfile, root, releasever=None):
     confpp_obj = ConfigPreProcessor(configfile)
 
     yumvars = _getEnvVar()
+    _read_yumvars(yumvars, '/')
+    _read_yumvars(yumvars, startupconf.installroot)
     confpp_obj._vars = yumvars
     startupconf.yumvars = yumvars

However, we should prefer the upstream fixup anyway, since reading yumvars from '/' is not desirable if the installroot is non-default.

Comment 11 errata-xmlrpc 2016-11-04 05:30:20 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://rhn.redhat.com/errata/RHBA-2016-2397.html