The plugin runs `gpgconf --list-options gpg-agent` on every shell start
to learn whether `enable-ssh-support` is set. On macOS with GnuPG 2.5.24
that one command takes about 600 ms.
The `ssh-support` style lets the user state the answer instead. With
`no` the plugin sets `GPG_TTY` and stops. That also skips the preexec
hook, which runs `gpg-connect-agent updatestartuptty` before every
command and is only needed for ssh support. With `yes` the plugin sets
`SSH_AUTH_SOCK` without asking.
Left unset, the plugin detects as before, so existing setups do not
change.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Always try and start gpg-agent, with --use-standard-socket it will try and use a standard socket directory. It won't start multiple agents if agent is already running. In addition, XDG_RUNTIME_DIR isn't always set
* ssh socket if broken if --daemon is run again, so onky start if we don't have a socket
* Removed unnecessary allocation of GPG_SSH_AUTH_SOCK
The gpg-agent plugin did not work for gpg versions above or equal to
2.1 because of the `--write-env-file` option deprecation. This new version
works fine and also enables the ssh-agent support only if it is enabled in the
gpg-agent config file.
If using the gpg-agent with --enable-ssh-support, the SSH_AUTH_SOCK and
SSH_AGENT_PID environment variables need to be exported once sourced
from GPG_ENV. Otherwise, we get no benefit from the persisting these
values to GPG_ENV; subsequent openned terminals don't see the existent
gpg-agent as a process for an SSH daemon.
The GPG_ENV file is sourced before doing the gpg-connect-agent check,
but this file (unlike the SSH_ENV file) doesn't export GPG_AGENT_INFO,
so the check always fails. This results in new gpg-agents continuously
being spawned.
All this commit does is put in the single export to fix the problem.
Don't just overwrite the environment. First check for a running agent (an
x-session might have one running). If no agent is found, source the
environment and check again using those settings. If again no agent is
found, start a new instance.