Add key to transaction keyring on rpmtsImportPubkey() (rhbz#457360)
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 8 Aug 2008 06:57:41 +0000 (09:57 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 8 Aug 2008 06:57:41 +0000 (09:57 +0300)
- still not 100% identical to pre-keyring behavior but enough for the
  common case
- only add keys we don't already have (rhbz#68290)

lib/rpmts.c

index 410b66d..88298e5 100644 (file)
@@ -475,9 +475,12 @@ rpmRC rpmtsImportPubkey(const rpmts ts, const unsigned char * pkt, size_t pktlen
     Header h = headerNew();
     rpmRC rc = RPMRC_FAIL;             /* assume failure */
     rpmPubkey pubkey = NULL;
+    rpmKeyring keyring = rpmtsGetKeyring(ts, 1);
 
     if ((pubkey = rpmPubkeyNew(pkt, pktlen)) == NULL)
        goto exit;
+    if (rpmKeyringAddKey(keyring, pubkey) != 0)
+       goto exit;
     if (makePubkeyHeader(ts, pubkey, h) != 0) 
        goto exit;
 
@@ -492,6 +495,7 @@ exit:
     /* Clean up. */
     headerFree(h);
     rpmPubkeyFree(pubkey);
+    rpmKeyringFree(keyring);
     return rc;
 }