diff options
-rw-r--r-- | agent/agent.h | 2 | ||||
-rw-r--r-- | agent/call-daemon.c | 12 | ||||
-rw-r--r-- | agent/call-scd.c | 2 | ||||
-rw-r--r-- | agent/call-tpm2d.c | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/agent/agent.h b/agent/agent.h index 06bc1e046..6a61f4829 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -690,7 +690,7 @@ gpg_error_t divert_writekey (ctrl_t ctrl, int force, const char *serialno, const char *keydata, size_t keydatalen); /*-- call-daemon.c --*/ -gpg_error_t daemon_start (enum daemon_type type, ctrl_t ctrl); +gpg_error_t daemon_start (enum daemon_type type, ctrl_t ctrl, int req_sock); assuan_context_t daemon_type_ctx (enum daemon_type type, ctrl_t ctrl); gpg_error_t daemon_unlock (enum daemon_type type, ctrl_t ctrl, gpg_error_t rc); void initialize_module_daemon (void); diff --git a/agent/call-daemon.c b/agent/call-daemon.c index 7753afe22..318d31e79 100644 --- a/agent/call-daemon.c +++ b/agent/call-daemon.c @@ -252,7 +252,7 @@ atfork_cb (void *opaque, int where) * caller must call unlock_daemon after this function has returned * success and the actual Assuan transaction been done. */ gpg_error_t -daemon_start (enum daemon_type type, ctrl_t ctrl) +daemon_start (enum daemon_type type, ctrl_t ctrl, int require_socket) { gpg_error_t err = 0; const char *pgmname; @@ -284,6 +284,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl) return gpg_error (GPG_ERR_INTERNAL); } + again: /* We need to serialize the access to scd_local_list and primary_scd_ctx. */ rc = npth_mutex_lock (&start_daemon_lock); if (rc) @@ -316,7 +317,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl) /* Check whether the pipe server has already been started and in this case either reuse a lingering pipe connection or establish a new socket based one. */ - if (g->primary_ctx && g->primary_ctx_reusable) + if (g->primary_ctx && g->primary_ctx_reusable && !require_socket) { ctx = g->primary_ctx; g->primary_ctx_reusable = 0; @@ -508,6 +509,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl) leave: xfree (abs_homedir); + abs_homedir = NULL; if (err) { rc = npth_mutex_unlock (&start_daemon_lock); @@ -524,6 +526,12 @@ daemon_start (enum daemon_type type, ctrl_t ctrl) rc = npth_mutex_unlock (&start_daemon_lock); if (rc) log_error ("failed to release the start_daemon lock: %s\n", strerror (rc)); + + if (require_socket && g->primary_ctx == ctx) + { + daemon_unlock (type, ctrl, 0); + goto again; + } } return err; } diff --git a/agent/call-scd.c b/agent/call-scd.c index ecc3150f3..918135854 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -94,7 +94,7 @@ struct inq_needpin_parm_s static int start_scd (ctrl_t ctrl) { - return daemon_start (DAEMON_SCD, ctrl); + return daemon_start (DAEMON_SCD, ctrl, 0); } diff --git a/agent/call-tpm2d.c b/agent/call-tpm2d.c index 1048c7d63..3f6ca7b52 100644 --- a/agent/call-tpm2d.c +++ b/agent/call-tpm2d.c @@ -16,7 +16,7 @@ static int start_tpm2d (ctrl_t ctrl) { - return daemon_start (DAEMON_TPM2D, ctrl); + return daemon_start (DAEMON_TPM2D, ctrl, 0); } static int |