aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-11-25 10:39:56 +0000
committerWerner Koch <[email protected]>2019-11-25 10:41:02 +0000
commit96c4943a5bd070772d8be7bb7db8548840af5f8f (patch)
tree0013b48bb5de05926124459b7203f48cd46ae95d
parentdoc: Prepare a NEWS file for the next release. (diff)
downloadgnupg-96c4943a5bd070772d8be7bb7db8548840af5f8f.tar.gz
gnupg-96c4943a5bd070772d8be7bb7db8548840af5f8f.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]> (cherry picked from commit c8783b3a204b371d44b8953429652101cf2e4d1b)
-rw-r--r--agent/call-pinentry.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index aaf2af6ab..b0b5bcb92 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)
{