mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
c21267e1c7
commit
c8783b3a20
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user