gpg-agent support for GNUPGHOME and systemd
Ben Fiedler
debian at services.bfiedler.ch
Wed Aug 19 23:19:56 CEST 2020
On Wed Aug 19, 2020 at 10:10 PM, Ben Fiedler wrote:
> Relevant env vars:
> DBUS_SESSION_BUS_ADDRESS correctly set
> GNUPGHOME=${HOME}/.config/gnupg, set for both the systemd service and
> GPG_TTY=$(tty) set and exported in .zshrc
> SSH_AUTH_SOCK=${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh set and exported
> in .zprofile
Aha! I think I've found the issue: When GNUPGHOME is set
the gpg command line tools use different sockets:
% unset GNUPGHOME
% gpgconf --dry-run --create-socketdir
gpgconf: socketdir is '/run/user/1000/gnupg'
% export GNUPGHOME=$HOME/.config/gnupg
% gpgconf --dry-run --create-socketdir
gpgconf: socketdir is '/run/user/1000/gnupg/d.6oynbz4mc38pz8n5gyedka7a'
gpgconf: non-default homedir
This is pretty unexpected to me, why is this the case? And is there a
way to mitigate this behaviour?
A bit of background: The original "problem" I'm trying to solve is
uncluttering my homedir from `.appname` folders and trying to get as
much as possible to conform to the XDG directory specification. The Arch
wiki [1] recommends setting GNUPGHOME, which is probably not intended to
be used that way when using socket-based activation with systemd. I've
seen that the gpg project doesn't intend to support automatically
creating it's config in XDG_CONFIG_HOME, but would there be a way to
set the socket dir instead of using the pseudo-random location? The
result would be a systemd-socket-activation-compliant way of using
GNUPGHOME to set the GnuPG directory with minimal changes needed.
If someone can give me a few pointers I'd be glad to take a look at
implementing it myself.
Best,
Ben
[1]: https://wiki.archlinux.org/index.php/XDG_Base_Directory#Partial
More information about the Gnupg-users
mailing list