Permit key imports even if signature checking is disabled (RhBug:856225)
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 17 Sep 2012 07:48:05 +0000 (10:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 17 Sep 2012 07:56:29 +0000 (10:56 +0300)
- Since commit 290fcbbe6b3ca2fb1d5e4a7269a32a94f8a1563a, key imports
  on transaction sets where signature checking is disabled would fail
  due to keyring not getting loaded at all. A regression of sorts,
  in other words. As a minimal fix, temporarily enable sigcheck vsflags
  during keyring loading.

lib/rpmts.c

index 7653844..a34edf9 100644 (file)
@@ -451,9 +451,15 @@ rpmRC rpmtsImportPubkey(const rpmts ts, const unsigned char * pkt, size_t pktlen
     Header h = NULL;
     rpmRC rc = RPMRC_FAIL;             /* assume failure */
     rpmPubkey pubkey = NULL;
-    rpmKeyring keyring = rpmtsGetKeyring(ts, 1);
+    rpmVSFlags oflags = rpmtsVSFlags(ts);
+    rpmKeyring keyring;
     int krc;
 
+    /* XXX keyring wont load if sigcheck disabled, force it temporarily */
+    rpmtsSetVSFlags(ts, (oflags & ~_RPMVSF_NOSIGNATURES));
+    keyring = rpmtsGetKeyring(ts, 1);
+    rpmtsSetVSFlags(ts, oflags);
+
     if ((pubkey = rpmPubkeyNew(pkt, pktlen)) == NULL)
        goto exit;
     krc = rpmKeyringAddKey(keyring, pubkey);