summaryrefslogtreecommitdiffstats
path: root/dirmngr/server.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-04-12 11:24:54 +0200
committerWerner Koch <wk@gnupg.org>2018-04-12 11:25:58 +0200
commitbbb5bfacc0d1f179cfec94fd32fee01a09df0f1d (patch)
tree94273654c0949729cd9de6e8f9fcf1b0761f31f3 /dirmngr/server.c
parentbuild: Update getswdb version check to 2.2 (diff)
downloadgnupg2-bbb5bfacc0d1f179cfec94fd32fee01a09df0f1d.tar.xz
gnupg2-bbb5bfacc0d1f179cfec94fd32fee01a09df0f1d.zip
agent,dirmngr: Add "getenv" to the getinfo command.
* agent/command.c (cmd_getinfo): Add sub-command getenv. * dirmngr/server.c (cmd_getinfo): Ditto. -- It is sometimes helpful to be able to inspect certain envvars in a running agent. For example "http_proxy". Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'dirmngr/server.c')
-rw-r--r--dirmngr/server.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/dirmngr/server.c b/dirmngr/server.c
index 60d980211..4315c4133 100644
--- a/dirmngr/server.c
+++ b/dirmngr/server.c
@@ -2489,7 +2489,8 @@ static const char hlp_getinfo[] =
"dnsinfo - Return info about the DNS resolver\n"
"socket_name - Return the name of the socket.\n"
"session_id - Return the current session_id.\n"
- "workqueue - Inspect the work queue\n";
+ "workqueue - Inspect the work queue\n"
+ "getenv NAME - Return value of envvar NAME\n";
static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
{
@@ -2557,6 +2558,23 @@ cmd_getinfo (assuan_context_t ctx, char *line)
workqueue_dump_queue (ctrl);
err = 0;
}
+ else if (!strncmp (line, "getenv", 6)
+ && (line[6] == ' ' || line[6] == '\t' || !line[6]))
+ {
+ line += 6;
+ while (*line == ' ' || *line == '\t')
+ line++;
+ if (!*line)
+ err = gpg_error (GPG_ERR_MISSING_VALUE);
+ else
+ {
+ const char *s = getenv (line);
+ if (!s)
+ err = set_error (GPG_ERR_NOT_FOUND, "No such envvar");
+ else
+ err = assuan_send_data (ctx, s, strlen (s));
+ }
+ }
else
err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");