Article View: linux.gentoo.dev
Article #135Re: [gentoo-dev] [PATCH] sec-keys.eclass: detect conflicting key name/remote mappings
From: Sam James
Date: Sat, 07 Nov 2026 05:30
Date: Sat, 07 Nov 2026 05:30
86 lines
4643 bytes
4643 bytes
--=-=-=
Content-Type: text/plain
Zhixu Liu <zhixu.liu@gmail.com> writes:
> Detect conflicting SEC_KEYS_VALIDPGPKEYS entries where the same
> name/remote pair maps to different OpenPGP fingerprints.
>
> For keyserver-based remotes (gentoo, openpgp and Ubuntu), the
> fingerprint is part of the download URL while the target filename
> is derived only from the key name and remote. So multiple
> fingerprints for the same name/remote pair would overwrite each
> other. Github downloads are keyed by user name only and
> can include multiple fingerprints, so the overwrite is harmless.
>
> Reject such configurations early with a descriptive error message.
>
Eli, any comments?
> Closes: https://bugs.gentoo.org/979441
> Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
> ---
> eclass/sec-keys.eclass | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/eclass/sec-keys.eclass b/eclass/sec-keys.eclass
> index b53b7143bea65..0f93183e560b2 100644
> --- a/eclass/sec-keys.eclass
> +++ b/eclass/sec-keys.eclass
> @@ -63,7 +63,8 @@ inherit eapi9-pipestatus edo
> # - manual -- do not add to SRC_URI, the ebuild will provide a custom
> # download location
> _sec_keys_set_globals() {
> - local key fingerprint name loc locations=() remote
> + local -A name_loc_fpr=()
> + local key key_id fingerprint name loc locations=() remote
>
> for key in "${SEC_KEYS_VALIDPGPKEYS[@]}"; do
> fingerprint=${key%%:*}
> @@ -80,6 +81,23 @@ _sec_keys_set_globals() {
> manual) continue;;
> *) die "${ECLASS}: unknown PGP key
> remote: ${loc}";;
> esac
> +
> + # github remote depends only on the user name.
> Other remotes include the
> + # fingerprint in the URL, so prevent multiple
> fingerprints from mapping
> + # to the same output file.
> + key_id="${name}:${loc}"
> + case ${loc} in
> + gentoo|openpgp|ubuntu)
> + if [[ -v "name_loc_fpr[${key_id}]" ]] &&
> + [[
> ${name_loc_fpr["${key_id}"]} != "${fingerprint}" ]]
> + then
> + die "${ECLASS}:
> ${key_id} maps to multiple fingerprints: " \
> +
> "${name_loc_fpr["${key_id}"]} and ${fingerprint}"
> + fi
> + name_loc_fpr["${key_id}"]=${fingerprint}
> + ;;
> + esac
> +
> SRC_URI+="
> ${remote} ->
> openpgp-keys-${name}-${loc}-${PV}.asc
> "
--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmrutbgbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkAXR
AP0TBK5c8H/GqlrVBgdn4Z20Ict7zmBfhP0gRbeV7tRBmQD/asG0EMyup5KHfvWA
FE2O82oYe6UhSmlJZSZWzyVAfwE=
=Cxl3
-----END PGP SIGNATURE-----
--=-=-=--
Technical Details
Message-ID:
<NWHa1-akRk-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodReferences:
<NOI3f-5QvG-3@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod From: Sam James <sam@gentoo.org> Newsgroups: linux.gentoo.dev Subject: Re: [gentoo-dev] [PATCH] sec-keys.eclass: detect conflicting key name/remote mappings Date: Sat, 07 Nov 2026 06:30:01 +0100 Message-ID: <NWHa1-akRk-1@gated-at.bofh.it> References: <NOI3f-5QvG-3@gated-at.bofh.it> Organization: Gentoo User-Agent: mu4e 1.14.4; emacs 31.1 List-ID: Gentoo Linux mail <gentoo-dev.gentoo.org> Reply-To: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Approved: robomod@news.nic.it Lines: 86 Sender: robomod@news.nic.it X-Original-Cc: Eli Schwartz <eschwartz@gentoo.org> X-Original-Date: Sat, 07 Nov 2026 05:23:04 +0000 X-Original-Message-ID: <875wy9tdtz.fsf@gentoo.org> X-Original-References: <CALMA0xYgyxBnx2OUE4xyKeM_JHaW_bVnx07-GeeEOUf_rsANqA@mail.gmail.com>