🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.gentoo.dev
Article #222

Re: [gentoo-dev] [PATCH] sec-keys.eclass: don't use gpg-agent when importing keys

#222
From: Sam James
Date: Thu, 26 Nov 2026 12:30
111 lines
5413 bytes
--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Florian Schmaus <flow@gentoo.org> writes:

> On 25/11/2026 13.17, Sam James wrote:
>> Florian Schmaus <flow@gentoo.org> writes:
>>=20
>>> When importing a key, gpg asks gpg-agent whether the matching secret ke=
y is
>>> available, starting the agent if needed. The agent places its sockets in
>>> GNUPGHOME.  With a long PORTAGE_TMPDIR, CATEGORY or PF, those socket pa=
ths
>>> 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-20260=
128
>>> 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.
>>>
>> Should we do something similar in verify-sig too btw?
>
> verify-sig seems to have a workaround in place for this:
> https://codeberg.org/gentoo/gentoo/src/commit/4f248f2344b0e5aec40d1df4e7a=
e61a0d4c16e49/eclass/verify-sig.eclass#L197-L199

I know, I even mentioned it on the bug ;)

I'm wondering if it could be dropped in favour of this.

>
>
>> Closes: https://bugs.gentoo.org/966274
>>=20
>>> 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".
>> The last sentence isn't necessary for a comment, it just belongs in
>> the
>> commit message.
>
> Will do when merging once Eli gives his ack.
>
>
>>> +	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
>>>     	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 --imp=
ort
>>>   			pipestatus || die
>>>   		fi
>>>   	done

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmsIJf0bFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkIvt
APsF/gi8FEB+XYI7mToOvdQECSmKyespwKBEn/2YNHBd8QEA/2IsFeXloeOQ0xKs
NpuW8bdww/flO1kBePYT7IKN+gU=
=OWLj
-----END PGP SIGNATURE-----
--=-=-=--
Technical Details
Message-ID: <O3GLT-egq2-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
References: <O3gHM-e2g6-7@gated-at.bofh.it> <O3k8F-e46S-1@gated-at.bofh.it> <O3D1D-eenk-1@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: Thu, 26 Nov 2026 13:30:01 +0100
Message-ID: <O3GLT-egq2-1@gated-at.bofh.it>
References: <O3gHM-e2g6-7@gated-at.bofh.it> <O3k8F-e46S-1@gated-at.bofh.it> <O3D1D-eenk-1@gated-at.bofh.it>
X-Original-To: gentoo-dev@lists.gentoo.org
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: 111
Sender: robomod@news.nic.it
X-Original-Cc: Eli Schwartz <eschwartz@gentoo.org>
X-Original-Date: Thu, 26 Nov 2026 12:28:44 +0000
X-Original-Message-ID: <87y0afu683.fsf@gentoo.org>
X-Original-References: <20261125083046.152350-2-flow@gentoo.org>
	<877bi1umu1.fsf@gentoo.org>
	<b38077d9-148d-4d37-a2ea-9cd7109b773f@gentoo.org>