Skip to content

Commit

Permalink
Simplify rpmKeyringModify(RPMKEYRING_REPLACE)
Browse files Browse the repository at this point in the history
Implement as RPMKEYRING_DELETE + RPMKEYRING_ADD.

This will make it easier to handle the subkeys at the same time in the
next commit.

Related: 3350
  • Loading branch information
ffesti authored and pmatilai committed Oct 24, 2024
1 parent 09510e4 commit ad461ce
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rpmio/rpmkeyring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,11 @@ int rpmKeyringModify(rpmKeyring keyring, rpmPubkey key, rpmKeyringModifyMode mod
if (item->second->fp == key->fp)
break;
}
if (item != range.second && mode == RPMKEYRING_DELETE) {
if (item != range.second && (mode == RPMKEYRING_DELETE || mode == RPMKEYRING_REPLACE)) {
rpmPubkeyFree(item->second);
keyring->keys.erase(item);
rc = 0;
} else if (item != range.second && mode == RPMKEYRING_REPLACE) {
rpmPubkeyFree(item->second);
item->second = rpmPubkeyLink(key);
rc = 0;
} else if (item == range.second && (mode == RPMKEYRING_ADD || mode == RPMKEYRING_REPLACE) ) {
} else if ((item == range.second && mode == RPMKEYRING_ADD) || mode == RPMKEYRING_REPLACE) {
keyring->keys.insert({key->keyid, rpmPubkeyLink(key)});
rc = 0;
}
Expand Down

0 comments on commit ad461ce

Please sign in to comment.