Skip to content

Commit 8eadf44

Browse files
ppisarpkratoch
authored andcommitted
Stop importing subkeys to RPM >= 5.99.90
It was reported that rpmKeyringAddKey() fails to import separate subkeys in RPM 6 with rpm-sequoia <https://bugzilla.redhat.com/show_bug.cgi?id=2372978>. Observed in packagekit and microdnf with rpm-libs-5.99.92-1.fc44.x86_64 and rpm-sequoia-1.9.0-2.fc43.x86_64: packagekitd[1862782]: failed to add subkeys for /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-10-primary to rpmdb packagekitd[1862782]: failed to add subkeys for /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-13-secondary to rpmdb packagekitd[1862782]: failed to add subkeys for /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-14-secondary to rpmdb The failure comes from librpm's rpmKeyringAddKey() → rpmKeyringModify() → rpmPubkeyMerge() → pgpPubkeyMerge() when adding the first subkey of the keyfile into a keyring by libdnf in dnf_keyring_add_public_key() at libdnf/dnf-keyring.cpp:137. pgpPubkeyMerge() is implemented in rpm-sequoia. It was confirme by RPM developers that RPM started to automatically add subkeys to a keyring when the primary key is added and that it does not expect standalone subkeys any more. This change happended in 5.99.90. This patch stops passing standalone subkeys to rpmKeyringAddKey() on RPM >= 5.99.90. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2372978
1 parent 6a127ae commit 8eadf44

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ pkg_check_modules(LIBMODULEMD REQUIRED modulemd-2.0>=2.11.2)
6767
pkg_check_modules(REPO REQUIRED librepo>=1.18.0)
6868
include_directories(${REPO_INCLUDE_DIRS})
6969
link_directories(${REPO_LIBRARY_DIRS})
70+
7071
pkg_check_modules(RPM REQUIRED rpm>=4.15.0)
72+
if (RPM_VERSION VERSION_GREATER_EQUAL "5.99.90")
73+
add_definitions(-DRPM_AUTOADDS_SUBKEYS)
74+
endif()
75+
7176
pkg_check_modules(SMARTCOLS REQUIRED smartcols)
7277
pkg_check_modules(SQLite3 REQUIRED sqlite3)
7378

libdnf.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ BuildRequires: libubsan
9696
Requires: libmodulemd%{?_isa} >= %{libmodulemd_version}
9797
Requires: libsolv%{?_isa} >= %{libsolv_version}
9898
Requires: librepo%{?_isa} >= %{librepo_version}
99+
%if 0%{?fedora} >= 43 || 0%{?rhel} >= 11
100+
Requires: rpm-libs%{?_isa} >= 5.99.90
101+
%endif
99102

100103
%if %{without python2}
101104
# Obsoleted from here so we can track the fast growing version easily.

libdnf/dnf-keyring.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ dnf_keyring_add_public_key(rpmKeyring keyring,
131131
goto out;
132132
}
133133

134+
#ifndef RPM_AUTOADDS_SUBKEYS
135+
/* RPM before 5.99.90 required adding subkeys explicitly.
136+
* RPM >= 5.99.90 processes subkeys automatically with a primary key and
137+
* fails on processing standalone subkeys in rpmKeyringAddKey(). */
134138
subkeys = rpmGetSubkeys(pubkey, &nsubkeys);
135139
for (int i = 0; i < nsubkeys; i++) {
136140
rpmPubkey subkey = subkeys[i];
@@ -144,6 +148,7 @@ dnf_keyring_add_public_key(rpmKeyring keyring,
144148
goto out;
145149
}
146150
}
151+
#endif
147152

148153
/* success */
149154
g_debug("added missing public key %s to rpmdb", filename);

0 commit comments

Comments
 (0)