diff options
author | Werner Koch <[email protected]> | 2019-11-25 10:39:56 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-11-25 10:39:56 +0000 |
commit | c8783b3a204b371d44b8953429652101cf2e4d1b (patch) | |
tree | e02a2d79309164193ab2a484c86f332b6989440c /agent/call-pinentry.c | |
parent | doc,dirmngr: Clarify --standard-resolver. (diff) | |
download | gnupg-c8783b3a204b371d44b8953429652101cf2e4d1b.tar.gz gnupg-c8783b3a204b371d44b8953429652101cf2e4d1b.zip |
agent: Improve --debug-pinentry diagnostics
* agent/call-pinentry.c (atfork_cb): Factor code out to ...
(atfork_core): new.
--
We convey certain envvars directly via the environment to Pinentry and
thus they don't show up in the Assuan logging. Because we better
don't call a logging function in an atfork handle, this patch splits
the code up and uses the same code to display what was done in at fork
after the connection has been established.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/call-pinentry.c')
-rw-r--r-- | agent/call-pinentry.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index cd862fb77..658be4611 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -191,6 +191,37 @@ unlock_pinentry (ctrl_t ctrl, gpg_error_t rc) } +/* Helper for at_fork_cb which can also be called by the parent to + * show shich envvars will be set. */ +static void +atfork_core (ctrl_t ctrl, int debug_mode) +{ + int iterator = 0; + const char *name, *assname, *value; + + while ((name = session_env_list_stdenvnames (&iterator, &assname))) + { + /* For all new envvars (!ASSNAME) and the two medium old ones + * which do have an assuan name but are conveyed using + * environment variables, update the environment of the forked + * process. */ + if (!assname + || !strcmp (name, "XAUTHORITY") + || !strcmp (name, "PINENTRY_USER_DATA")) + { + value = session_env_getenv (ctrl->session_env, name); + if (value) + { + if (debug_mode) + log_debug ("pinentry: atfork used setenv(%s,%s)\n",name,value); + else + gnupg_setenv (name, value, 1); + } + } + } +} + + /* To make sure we leave no secrets in our image after forking of the pinentry, we use this callback. */ static void @@ -200,26 +231,8 @@ atfork_cb (void *opaque, int where) if (!where) { - int iterator = 0; - const char *name, *assname, *value; - gcry_control (GCRYCTL_TERM_SECMEM); - - while ((name = session_env_list_stdenvnames (&iterator, &assname))) - { - /* For all new envvars (!ASSNAME) and the two medium old - ones which do have an assuan name but are conveyed using - environment variables, update the environment of the - forked process. */ - if (!assname - || !strcmp (name, "XAUTHORITY") - || !strcmp (name, "PINENTRY_USER_DATA")) - { - value = session_env_getenv (ctrl->session_env, name); - if (value) - gnupg_setenv (name, value, 1); - } - } + atfork_core (ctrl, 0); } } @@ -406,6 +419,9 @@ start_pinentry (ctrl_t ctrl) if (DBG_IPC) log_debug ("connection to PIN entry established\n"); + if (opt.debug_pinentry) + atfork_core (ctrl, 1); + value = session_env_getenv (ctrl->session_env, "PINENTRY_USER_DATA"); if (value != NULL) { |