Package: gnupg Version: 2.1.18-8~deb9u1 Severity: normal gpg(-agent) uses a different socketdir when a non-default homedir is specified depending on the environment:
If /run/user/<id> exists, it will use /run/user/<id>/gnupg/d.<hash>; otherwise it will fall back to <homedir>. XDG_RUNTIME_DIR is intentionally ignored... This does cause multiple instances of gpg-agent to be launched when first invoking `gpg` with no open login session (/run/user/<id> does not exist) and then again with an open login session open (which created /run/user/<id>). Only one gpg-agent will be able to access smartcards, the other will just give an error. If both `gpg` invocations happened outside a login session, usually XDG_RUNTIME_DIR wouldn't be set and gpg would always use the same socket location (unless also invoked from within a session with XDG_RUNTIME_DIR set). Or one could set XDG_RUNTIME_DIR to a fixed location before invoking gpg (or unset it), but gpg ignores that variable. In addition it would be nice if there was an option to explicitly configure a socket directory to allow using supervision for gpg-agent's with a non-default homedir (and not having to rely on implementation details like d.${hash} which might change). Ansgar