summaryrefslogtreecommitdiffstats
path: root/agent
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 /agent
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 'agent')
-rw-r--r--agent/command.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/agent/command.c b/agent/command.c
index f2d0389c7..20abb2882 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -2825,6 +2825,7 @@ static const char hlp_getinfo[] =
" std_env_names - List the names of the standard environment.\n"
" std_session_env - List the standard session environment.\n"
" std_startup_env - List the standard startup environment.\n"
+ " getenv NAME - Return value of envvar NAME.\n"
" connections - Return number of active connections.\n"
" jent_active - Returns OK if Libgcrypt's JENT is active.\n"
" restricted - Returns OK if the connection is in restricted mode.\n"
@@ -2961,6 +2962,23 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
}
}
+ else if (!strncmp (line, "getenv", 6)
+ && (line[6] == ' ' || line[6] == '\t' || !line[6]))
+ {
+ line += 6;
+ while (*line == ' ' || *line == '\t')
+ line++;
+ if (!*line)
+ rc = gpg_error (GPG_ERR_MISSING_VALUE);
+ else
+ {
+ const char *s = getenv (line);
+ if (!s)
+ rc = set_error (GPG_ERR_NOT_FOUND, "No such envvar");
+ else
+ rc = assuan_send_data (ctx, s, strlen (s));
+ }
+ }
else if (!strcmp (line, "connections"))
{
char numbuf[20];