From 0e824ec52939cd0bb8c5de6c487ae32247c869da Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 1 Nov 2026 18:09:37 +0100 Subject: [PATCH] Reset the rpm database path macro on any error The _dbpath macro set for fingerprinting an image is process global. It was only removed after a successful query, so an error left it set and later fingerprinting in the same process, which fancy_chroot does on every command, read the wrong database. --- imgutil/imgutil | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/imgutil/imgutil b/imgutil/imgutil index 36a2ada1..c9543786 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -1511,16 +1511,18 @@ def fingerprint_host_el(args, hostpath='/'): import rpm if dbpath: rpm.addMacro('_dbpath', dbpath) - ts = rpm.TransactionSet(hostpath) - rpms = ts.dbMatch('provides', 'system-release') - for inf in rpms: - if 'el8' not in inf.release and 'el7' not in inf.release and 'el9' not in inf.release and 'el10' not in inf.release: - continue - osname = inf.name - version = inf.version - release = inf.release - if dbpath: - rpm.delMacro('_dbpath') + try: + ts = rpm.TransactionSet(hostpath) + rpms = ts.dbMatch('provides', 'system-release') + for inf in rpms: + if 'el8' not in inf.release and 'el7' not in inf.release and 'el9' not in inf.release and 'el10' not in inf.release: + continue + osname = inf.name + version = inf.version + release = inf.release + finally: + if dbpath: + rpm.delMacro('_dbpath') except ImportError: try: rpmcmd = ['rpm', '--root', hostpath]