On 25/11/2026 13.17, Sam James wrote:
> Florian Schmaus <fl…@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 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.
>>
>
> 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/4f248f2344b0e5aec40d1df4e7ae61a0d4c16e49/eclass/verify-sig.eclass#L197-L199
> Closes: https://bugs.gentoo.org/966274
>
>> Signed-off-by: Florian Schmaus <fl…@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=/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