Don't return errors on trying to import duplicate keys

- On the principle of "no news is good news", if we already have the
  keys to be imported, then everything is ok. The former behavior is
  just confusing as witnessed in RhBug:462979
This commit is contained in:
Panu Matilainen 2010-06-01 10:15:10 +03:00
parent 099a45a5b9
commit ddec80b614
1 changed files with 14 additions and 8 deletions

View File

@ -430,19 +430,25 @@ rpmRC rpmtsImportPubkey(const rpmts ts, const unsigned char * pkt, size_t pktlen
rpmRC rc = RPMRC_FAIL; /* assume failure */
rpmPubkey pubkey = NULL;
rpmKeyring keyring = rpmtsGetKeyring(ts, 1);
int krc;
if ((pubkey = rpmPubkeyNew(pkt, pktlen)) == NULL)
goto exit;
if (rpmKeyringAddKey(keyring, pubkey) != 0)
goto exit;
if (makePubkeyHeader(ts, pubkey, h) != 0)
krc = rpmKeyringAddKey(keyring, pubkey);
if (krc < 0)
goto exit;
/* Add header to database. */
if (rpmtsOpenDB(ts, (O_RDWR|O_CREAT)))
goto exit;
if (rpmdbAdd(rpmtsGetRdb(ts), h) != 0)
goto exit;
/* If we dont already have the key, make a persistent record of it */
if (krc == 0) {
if (makePubkeyHeader(ts, pubkey, h) != 0)
goto exit;
/* Add header to database. */
if (rpmtsOpenDB(ts, (O_RDWR|O_CREAT)))
goto exit;
if (rpmdbAdd(rpmtsGetRdb(ts), h) != 0)
goto exit;
}
rc = RPMRC_OK;
exit: