Article View: linux.gentoo.dev
Article #219[gentoo-dev] [PATCH] sec-keys.eclass: don't use gpg-agent when importing keys
From: Florian Schmaus
Date: Wed, 25 Nov 2026 08:40
Date: Wed, 25 Nov 2026 08:40
59 lines
4445 bytes
4445 bytes
When importing a key, gpg asks gpg-agent whether the matching secret key is
available, starting the agent if needed. The agent places its sockets in
GNUPGHOME. With a long PORTAGE_TMPDIR, CATEGORY or PF, those socket paths
exceed the sun_path limit (106 characters on Linux) and gpg-agent fails to
start, causing gpg --import to exit with an error even though all keys were
imported:
gpg: can't connect to the gpg-agent: IPC connect call failed
This made src_compile of sec-keys/openpgp-keys-apache-xmlgraphics-20260128
die when PORTAGE_TMPDIR was 13 characters longer than the default /var/tmp.
GNUPGHOME was then 90 characters long, so S.gpg-agent.extra (108) and
S.gpg-agent.browser (110) were too long. With such a PORTAGE_TMPDIR,
several other sec-keys packages have names long enough to run into this.
Fix this by avoiding gpg-agent in sec-keys.eclass. Public keys do not need
gpg-agent, so import with --no-autostart. In addition, turn S.gpg-agent
into an Assuan redirect to a path that cannot exist, as connecting to a too
long S.gpg-agent path fails with ENAMETOOLONG, which gpg reports as an
error despite --no-autostart.
Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
eclass/sec-keys.eclass | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/eclass/sec-keys.eclass b/eclass/sec-keys.eclass
index b53b7143bea6..ccad5a5bc787 100644
--- a/eclass/sec-keys.eclass
+++ b/eclass/sec-keys.eclass
@@ -128,8 +128,16 @@ sec-keys_src_compile() {
no-secmem-warning
EOF
+ # Disable the usage of gpg-agent. Public keys do not need gpg-agent,
+ # but gpg --import contacts it, and the agent fails if its socket path
+ # in GNUPGHOME is too long (e.g., because of a non-standard
+ # PORTAGE_TMPDIR). Fix this by invoking gpg with --no-autostart and
+ # redirect the socket to a path that cannot exist, so connecting fails
+ # cleanly rather than with "File name too long".
+ printf '%%Assuan%%\nsocket=/dev/null/S.gpg-agent\n' > "${GNUPGHOME}"/S.gpg-agent || die
+
pushd "${DISTDIR}" >/dev/null || die
- gpg --import ${A} || die
+ gpg --no-autostart --import ${A} || die
popd >/dev/null || die
local line imported_keys=() found=0
@@ -184,7 +192,7 @@ sec-keys_src_test() {
for key in "${SEC_KEYS_VALIDPGPKEYS[@]}"; do
if [[ ${key##*:} = *github* ]]; then
name=${key#*:}; name=${name%%:*}
- wget -qO- https://github.com/${name}.gpg | gpg --import
+ wget -qO- https://github.com/${name}.gpg | gpg --no-autostart --import
pipestatus || die
fi
done
--
2.56.1
Technical Details
Message-ID:
<O3gHM-e2g6-7@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod From: Florian Schmaus <flow@gentoo.org> Newsgroups: linux.gentoo.dev Subject: [gentoo-dev] [PATCH] sec-keys.eclass: don't use gpg-agent when importing keys Date: Wed, 25 Nov 2026 09:40:02 +0100 Message-ID: <O3gHM-e2g6-7@gated-at.bofh.it> X-Mailer: git-send-email 2.56.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 X-Developer-Signature: v=1; a=openpgp-sha256; l=2592; i=flow@gentoo.org; h=from:subject; bh=Momlw9hVUT91ZIrhsm9Ig65Sq3R5OMqlXlkDv+YdmFQ=; b=owGbwMvMwMWoZLn8xddWhSDG02pJDNlsc7brLH7CmVW9ND0j44f9FgGBV6umbKznKlC8e7OW5 4+FwCfRTsb1LAyMXAwzxRRZppeyzrdSvPMw+8nvdTCDWJlApkiLNDAAAQsDX25iXqmRjpGeqbah niGQoWMUD5HTY9DILC4uTS3STSsocsjLL0ksyczPK9bLL0jNK0gv0EvLTCvJyMgvKk4FGqGXl1p iaW5uamBq6WbsaGTo4uxqaObkauLm5OhqZGRs6WjuauFmamFqZGBqxMDFKQBzzek+9v8Rf+2fi7 61ftawTKH4+lp5my92h56Elc1JkZu5ra93w/Q5s5aa2j8/tNpz7+H9nLYzjQO+fda6sPvPwmk7V 2UzX5r+M9dyS5N6itTC+KLUnTb87KYHv81x0k9gv3xjJef9B8/Wxzo1+DDaBl379WZ1nOeWe9vj HWOzVROePTuk/+nP6f3C5z5d2bO6XetD9emNy1MWCUx4G1nuIvnzKvuV99MlEoX69VgKZ4mV/eO QF7v68F7QzpBpDRs2sWqtOsSidqBixSyjxFNf8q6EHlb5/mZie/hsjgmCZR9+3vLkc5+hkD/l2p 0bj1cX/CrYe1x9MkOdUYTlxmVLesx7H+posZx5tfEUS1Jc/O0XxlIMNwA= X-Developer-Key: i=flow@gentoo.org; a=openpgp; fpr=1357B01865B2503C18453D208CAC2A9678548E35 Content-Transfer-Encoding: 8bit Approved: robomod@news.nic.it Lines: 59 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Florian Schmaus <flow@gentoo.org> X-Original-Date: Wed, 25 Nov 2026 09:30:47 +0100 X-Original-Message-ID: <20261125083046.152350-2-flow@gentoo.org>