Skip to content

Conversation

@benjamb
Copy link
Contributor

@benjamb benjamb commented Oct 22, 2025

Description

Backport of #7117 and #7355.

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

squat added 2 commits October 22, 2025 17:54
…mmunity#7117)

This commit addresses nix-community#5997
At the root, the gpg-agent SSH integration is not working on Darwin
because shells are started with `SSH_AUTH_SOCK` already set to something
like `/private/tmp/com.apple.launchd.ozLmoURHDC/Listeners`, which
prevents the hook from setting the variable to the gpg-agent's socket.

This commit fixes the issue using a different mechanism to detect if the
current shell has already had the `SSH_AUTH_SOCK` variable set to the
gpg-agent's socket, namely by checking for `gnupg_SSH_AUTH_SOCK_by` as
documented in
https://www.gnupg.org/documentation/manuals/gnupg/Agent-Examples.html#Agent-Examples.

This is essentially a simplified version of
nix-community#5901 that does not
attempt to migrate gpg-agent over to launchd.

Signed-off-by: squat <lserven@gmail.com>
…munity#7355)

nix-community#7117 (comment)
noted that nix-community#7117 broke compatibility with forwarding ssh-agents using
`ssh -A`/`ForwardAgent`. In order to continue supporting the fix for
the issue raised in nix-community#5997 and address the compatibility problem
mentioned by @euank, this commit introduces the solution described in
nix-community#7117 (comment).

The code now checks the following:
1. is this shell part of an SSH connection and is `SSH_AUTH_SOCK` set?
   if so, assume the socket variable was set by sshd to point at a
   forwarded socket; bail out to skip setting `SSH_AUTH_SOCK".
1. is the current process a child of `gpg-agent --daemon`? if so, then
   bail out to skip setting `SSH_AUTH_SOCK`.
1. if we got this far, then set `SSH_AUTH_SOCK`.

I've tested this fix locally and can confirm that both nix-community#5997 as well as
the regression are fixed.

Signed-off-by: squat <lserven@gmail.com>
@benjamb benjamb changed the base branch from master to release-25.05 October 22, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants