Assuan: No obvious way to connect to gpg-agent with non-standard homedir
Closed, ResolvedPublic

Description

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.

justus set Version to master.Mar 27 2017, 5:29 PM
justus added projects: Bug Report, gpgme.
justus added a subscriber: justus.
werner added a subscriber: werner.Mar 27 2017, 6:49 PM

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.

I see. Let's get back to this after the release of 1.9

marcus added a subscriber: marcus.Aug 2 2017, 7:36 PM

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.

marcus moved this task from Backlog to For next release on the gpgme board.Aug 10 2017, 5:15 PM

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);
marcus closed this task as Resolved.Aug 15 2017, 7:56 PM
marcus claimed this task.