On Fri, 14 Oct 2016 at 12:58:17 -0400, Daniel Kahn Gillmor wrote:
> Furthermore, it seems likely that this will be complex and difficult for
> most people to use, even moreso than saying "please exec 'gpgconf --kill
> gpg-agent' when you're done". It's also not a pattern i've seen
> elsewhere, which will likely limit its adoption.
If you like other people's patterns, have you considered borrowing the
"adverb" pattern from dbus-run-session, but with s/dbus-daemon/gpg-agent/
applied? Whether it addresses Ian's desired properties for dgit's
credentials handling or not (probably not), it's certainly a viable
model for running unit tests with a transient GPGHOME. I've found myself
wishing for this facility when dealing with Flatpak and OSTree; both of
those optionally sign the content you publish with them, and hence both
of those need some special gpg-agent handling if you're going to run
their unit tests without leaving stray processes.
dbus-run-session consists of: start a dbus-daemon --session; set the
environment for its other child to point to that dbus-daemon; run its
remaining argv as a child process; when the other child exits, terminate
the dbus-daemon and exit with the other child's exit status.
In particular, I've been encouraging dbus-run-session as a replacement
for unit tests' (ab)uses of dbus-launch, which is a complicated "do what
I mean" dbus-daemon-starter for X11, and as a result doesn't implement
any of its various purposes particularly well.