Panu Matilainen 7bcd4c
From 3cb955b77f07c70ba01d765aa6377908847608f5 Mon Sep 17 00:00:00 2001
Panu Matilainen 7bcd4c
Message-Id: <3cb955b77f07c70ba01d765aa6377908847608f5.1606726599.git.pmatilai@redhat.com>
Panu Matilainen 7bcd4c
In-Reply-To: <fd054a40b2ba005571455d749de0423975e77651.1606726599.git.pmatilai@redhat.com>
Panu Matilainen 7bcd4c
References: <fd054a40b2ba005571455d749de0423975e77651.1606726599.git.pmatilai@redhat.com>
Panu Matilainen 7bcd4c
From: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 7bcd4c
Date: Mon, 23 Nov 2020 13:46:14 +0200
Panu Matilainen 7bcd4c
Subject: [PATCH 2/2] Only attempt loading the keyring once the rpmdb is open
Panu Matilainen 7bcd4c
Panu Matilainen 7bcd4c
When we do lazy rpmdb open in rpmtsInitIterator(), we also do a lazy
Panu Matilainen 7bcd4c
keyring open. Except that since the keyring typically lives in the rpmdb,
Panu Matilainen 7bcd4c
we PROBABLY should try open the database first. One of those "WTF I've
Panu Matilainen 7bcd4c
been smoking" moments, lol.
Panu Matilainen 7bcd4c
Panu Matilainen 7bcd4c
Prevents an ugly if mostly harmless double error anything we can't open
Panu Matilainen 7bcd4c
the database for one reason or another.
Panu Matilainen 7bcd4c
---
Panu Matilainen 7bcd4c
 lib/rpmts.c | 6 +++---
Panu Matilainen 7bcd4c
 1 file changed, 3 insertions(+), 3 deletions(-)
Panu Matilainen 7bcd4c
Panu Matilainen 7bcd4c
diff --git a/lib/rpmts.c b/lib/rpmts.c
Panu Matilainen 7bcd4c
index 9fa9cb0e2..8c8ae420a 100644
Panu Matilainen 7bcd4c
--- a/lib/rpmts.c
Panu Matilainen 7bcd4c
+++ b/lib/rpmts.c
Panu Matilainen 7bcd4c
@@ -177,12 +177,12 @@ rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
Panu Matilainen 7bcd4c
     if (ts == NULL)
Panu Matilainen 7bcd4c
 	return NULL;
Panu Matilainen 7bcd4c
 
Panu Matilainen 7bcd4c
-    if (ts && ts->keyring == NULL)
Panu Matilainen 7bcd4c
-	loadKeyring(ts);
Panu Matilainen 7bcd4c
-
Panu Matilainen 7bcd4c
     if (ts->rdb == NULL && rpmtsOpenDB(ts, ts->dbmode))
Panu Matilainen 7bcd4c
 	return NULL;
Panu Matilainen 7bcd4c
 
Panu Matilainen 7bcd4c
+    if (ts->keyring == NULL)
Panu Matilainen 7bcd4c
+	loadKeyring(ts);
Panu Matilainen 7bcd4c
+
Panu Matilainen 7bcd4c
     /* Parse out "N(EVR)" tokens from a label key if present */
Panu Matilainen 7bcd4c
     if (rpmtag == RPMDBI_LABEL && keyp != NULL && strchr(keyp, '(')) {
Panu Matilainen 7bcd4c
 	const char *se, *s = keyp;
Panu Matilainen 7bcd4c
-- 
Panu Matilainen 7bcd4c
2.28.0
Panu Matilainen 7bcd4c