aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 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)
{