Article View: linux.gentoo.dev
Article #220Re: [gentoo-dev] [PATCH] sec-keys.eclass: don't use gpg-agent when importing keys
From: Sam James
Date: Wed, 25 Nov 2026 12:20
Date: Wed, 25 Nov 2026 12:20
93 lines
4664 bytes
4664 bytes
--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Florian Schmaus <flow@gentoo.org> writes:
> 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 we=
re
> 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/tm=
p.
> 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 ne=
ed
> 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 t=
oo
> long S.gpg-agent path fails with ENAMETOOLONG, which gpg reports as an
> error despite --no-autostart.
>
Should we do something similar in verify-sig too btw?
Closes: https://bugs.gentoo.org/966274
> 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
>=20=20
> + # 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".
The last sentence isn't necessary for a comment, it just belongs in the
commit message.
> + printf '%%Assuan%%\nsocket=3D/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
>=20=20
> local line imported_keys=3D() found=3D0
> @@ -184,7 +192,7 @@ sec-keys_src_test() {
> for key in "${SEC_KEYS_VALIDPGPKEYS[@]}"; do
> if [[ ${key##*:} =3D *github* ]]; then
> name=3D${key#*:}; name=3D${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
--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmsG0ecbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkKky
AP9uNCii3q26ZDbpc68z/QbqewitClQqTAq0Is9EES29lgEAk3ZHf/FI3/AlE47T
fMX4Uf4s6EiQHgRzAAI1SfXDEQc=
=bS6H
-----END PGP SIGNATURE-----
--=-=-=--
Technical Details
Message-ID:
<O3k8F-e46S-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodReferences:
<O3gHM-e2g6-7@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!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: don't use gpg-agent when importing keys Date: Wed, 25 Nov 2026 13:20:01 +0100 Message-ID: <O3k8F-e46S-1@gated-at.bofh.it> References: <O3gHM-e2g6-7@gated-at.bofh.it> Organization: Gentoo User-Agent: mu4e 1.14.4; emacs 32.0.50 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: 93 Sender: robomod@news.nic.it X-Original-Cc: Eli Schwartz <eschwartz@gentoo.org>, Florian Schmaus <flow@gentoo.org> X-Original-Date: Wed, 25 Nov 2026 12:17:42 +0000 X-Original-Message-ID: <877bi1umu1.fsf@gentoo.org> X-Original-References: <20261125083046.152350-2-flow@gentoo.org>