GNOME Bugzilla – Bug 651826
GMimeGpgContext: provide a way to ask gpg to use the gpg-agent
Last modified: 2011-06-08 16:29:44 UTC
It would be nice to have something like g_mime_gpg_context_{set,get}_use_agent; this could be used to indicate that the calling process expects to be used in an environment with gpg-agent running.
Created attachment 189193 [details] [review] proposed (but untested) patch for adding use_agent flag This patch against gmime 2.4 is untested as i appear to be unable to build from source at the moment. I'm also not sure if it introduces an incompatible ABI change due to the modification of the _GMimeGpgContext struct (does the leading underscore mean it it's a private definition despite being in a public header file?) -- if it's an ABI bump, that's clearly a no-go for the stable branch. i'd be happy to see this on the 2.5 branch as well, of course. I note that one oddity here is that FALSE simply means "don't supply an additional --use-agent flag" -- so if the user still has use-agent set in ~/.gnupg/gpg.conf, they will still talk to the agent. The proposed patch has no way to indicate "supply --no-use-agent as an argument", which would actually allow the gmime invocation to explicitly prohibit gpg from talking to any running agent. I actually think this asymmetry is fine, since i don't see a good argument for avoiding talking to an agent if one is present (and the upcoming gpg 2.1 actually requires the use of an agent, so --no-use-agent would be crippling for any crypto invocation that needed access to secret credentials).
I agree about the --no-use-agent thing. As far as ABI breakage, yes, unfortunately it breaks ABI :( struct _GMimeGpgContext gets typedef'd to GMimeGpgContext, so it is public. I've modified the patch a bit. It was only setting use_agent for sign+encrypt but not sign nor decrypt, so I made it pass that option along for those modes as well. I also ported your patch to 2.5.x and committed it there.