Using the Assuan protocol there is no obvious way to connect to an gpg-agent
that is not using the default home directory. The assuan protocol engine
connects to gpg-agent by default, but homedir must be the empty string.
Instead, the API expects the path to the socket as filename, but how to map from
home directory to socket location is not obvious, and should be hidden from the
user.
Description
Details
- Version
- master
Revisions and Commits
rM GPGME | |||
rM91e47d71652b gpgconf: Add more comments. | |||
rM9f24e6c9010e gpgconf: Add access to --list-dirs for non-default engine. |
Related Objects
Event Timeline
What about
gpgme_get_dirinfo ("agent-socket")
? For testing you can use
GNUPGHOME=/foo/bar gpgme/tests/t-engine-info 2>&1 | grep agent-info
What about gpgme_get_dirinfo ("agent-socket")?
I did not know about that, and that helps a bit, but has the downside that it
uses the GNUPGHOME from the process' environment.
I'm thinking about the following use case. I have created an ephemeral home
directory to contain the results or side-effects of some operation, and now I
want to talk to the agent that serves that particularly home directory. I
cannot use gpgme_get_dirinfo because that uses GNUPGHOME, and I don't want to
change the environment variable because that is a process-global thing and I
don't want to interfere with other threads.
Well, at least this works without changing the environment:
$ gpgconf --homedir /tmp/uiux/ --list-dirs | grep agent-socket agent-socket:/run/user/1000/gnupg/d.sazbxpsor1wn5xsqw4b4jf34/S.gpg-agent
We should add a new function gpgme_op_dirinfo(gpgme_ctx_t ctx, const char *what) that's implemented by GPGME_PROTOCOL_GPGCONF. That would mimic the way gpgconf works and allows setting the home_dir via the context.
Now you can do this:
char *result = NULL; gpgme_error_t err = gpgme_ctx_set_engine_info (ctx, GPGME_PROTOCOL_GPGCONF, NULL, "/tmp/foo"); fail_if_err (err); err = gpgme_op_conf_dir (ctx, "agent-socket", &result); fail_if_err (err);