[Rpm-maint] [rpm-software-management/rpm] Handle subkeys in rpmKeyringModify (PR #3403)
Panu Matilainen
notifications at github.com
Thu Oct 24 13:27:49 UTC 2024
@pmatilai commented on this pull request.
> @@ -133,16 +133,32 @@ 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)) {
+ /* remove sub keys */
+ for (auto it = keyring->keys.begin(); it != keyring->keys.end();) {
+ if (it->second->primarykey == item->second) {
+ rpmPubkeyFree(it->second);
+ it = keyring->keys.erase(it);
+ } else {
+ ++it;
Oh but that's just the thing, this loop does "anything" because it's deleting items that it's looping on, so it's far from your average "loop all items" thing.
Actually the nicer way to do this would be std::remove_if() - there's so much stuff in the STL that we haven't even scratched the surface yet :smile:
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3403#discussion_r1814993413
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/pull/3403/review/2392520314 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20241024/90575dbe/attachment.html>
More information about the Rpm-maint
mailing list