🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.gentoo.dev
Article #215

[gentoo-dev] [PATCH] sec-keys.eclass: detect conflicting key name/remote mappings

#215
From: zhixu.liu
Date: Sun, 22 Nov 2026 16:20
57 lines
4119 bytes
From: "Z. Liu" <zhixu.liu@gmail.com>

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.

Closes: https://bugs.gentoo.org/979441
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>

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
 			"
-- 
2.49.1
Technical Details
Message-ID: <O2isi-dv3y-17@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: zhixu.liu@gmail.com
Newsgroups: linux.gentoo.dev
Subject: [gentoo-dev] [PATCH] sec-keys.eclass: detect conflicting key name/remote mappings
Date: Sun, 22 Nov 2026 17:20:02 +0100
Message-ID: <O2isi-dv3y-17@gated-at.bofh.it>
X-Original-To: gentoo-dev@lists.gentoo.org
X-Gm-Message-State: APuU4Z/y0lUGRjiI/ggfWT9KWjqqAMmO5IBIwvkEBAoeU4I672JpwwMF
	KZ+OftBVDsxtiShNhV+QbIMvgfqI9y/mRj6KYzTEO6OsYWwmQYmmdVtYX6YDYg==
X-Gm-Gg: AZFdTZd4STqghDy4+DG8KJVCuhL12dUk/ZLtAHb38d1AzgVXkmG4e2xjFNjkMpRwih5
	ctYzklEtc8WDnpslSIhb+wRgpLISET5f/fWkhJO2xp5puk7KaeIO2tJIXoGN44x8A+snZWtuOi4
	Z8p/kCxAH8Vt6JpXTnSbp1wC5Nu9MnC+xcjtwt+ZQ6syUfpd0cXz6wukj84aM7V75XvoHTxQk3R
	HUSdm45yAANoUtmsrEiUg+IymIfoqNv0Irtjie7qSeQjDWW6hc1j0FWo5mgjWxX8nWnnqCq40pL
	2sK3IgaKo7nV4dR8F0YhB1L665zg2crws5CS9fhel0ao0KXgNV3tz498jJJbT+RqoOnVwqJOdoY
	r48vFdr1kKod8Hjmj2HF3OsUtbpI4m6zFSKCLFH8ZQD/pBs8d5qmeIRXpLIhRAXqCztSjRClWcw
	w2TRVDBxPesEIAYJZoIa7cdLjnOx+lDpM0n1wB//SJLLim5gpypoNZe5VAYGsev40W1Lhc3Q1Sq
	uwfVfPQr5ObYj3MsgTQLmoC+CJAQyjMSlGxUJjoBQep2pAqVL93+Fa8FEVy35p1iUi4IGPGCs50
	rHmgGl4f0GDTjjmdebnH0tWEsHt2s+OmW/gdu2XAjuaDWZqQjtg3vYAGhdaMPtuh2vGbhCzKy5C
	jsf0/Mg/ARP8PeFFJ3xhZ1VYnFKofOhXY0j7nP771GQ==
X-Received: by 2002:a05:622a:5815:b0:54b:f7a6:5354 with SMTP id d75a77b69052e-55d76a27b40mr164914691cf.26.1795363867126;
        Sun, 22 Nov 2026 08:11:07 -0800 (PST)
X-Mailer: git-send-email 2.49.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-Transfer-Encoding: 8bit
Approved: robomod@news.nic.it
Lines: 57
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Cc: "Z. Liu" <zhixu.liu@gmail.com>
X-Original-Date: Mon, 23 Nov 2026 00:10:42 +0800
X-Original-Message-ID: <20261122161042.91481-1-zhixu.liu@gmail.com>