mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
agent:daemon: Add an argument to specify requiring socket connection.
* agent/agent.h (daemon_start): Add REQ_SOCK argument. * agent/call-daemon.c (daemon_start): Support specifying a socket connection. * agent/call-scd.c (start_scd): Connection don't care. * agent/call-tpm2d.c (start_tpm2d): Likewise. -- GnuPG-bug-id: 7151 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org> (cherry picked from commit 5d980802acb3e385c6d2a10e8b3ae95d362da953)
This commit is contained in:
parent
59e785b543
commit
fd9872295b
@ -690,7 +690,7 @@ gpg_error_t divert_writekey (ctrl_t ctrl, int force, const char *serialno,
|
|||||||
const char *keydata, size_t keydatalen);
|
const char *keydata, size_t keydatalen);
|
||||||
|
|
||||||
/*-- call-daemon.c --*/
|
/*-- 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);
|
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);
|
gpg_error_t daemon_unlock (enum daemon_type type, ctrl_t ctrl, gpg_error_t rc);
|
||||||
void initialize_module_daemon (void);
|
void initialize_module_daemon (void);
|
||||||
|
@ -252,7 +252,7 @@ atfork_cb (void *opaque, int where)
|
|||||||
* caller must call unlock_daemon after this function has returned
|
* caller must call unlock_daemon after this function has returned
|
||||||
* success and the actual Assuan transaction been done. */
|
* success and the actual Assuan transaction been done. */
|
||||||
gpg_error_t
|
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;
|
gpg_error_t err = 0;
|
||||||
const char *pgmname;
|
const char *pgmname;
|
||||||
@ -284,6 +284,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl)
|
|||||||
return gpg_error (GPG_ERR_INTERNAL);
|
return gpg_error (GPG_ERR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
again:
|
||||||
/* We need to serialize the access to scd_local_list and primary_scd_ctx. */
|
/* We need to serialize the access to scd_local_list and primary_scd_ctx. */
|
||||||
rc = npth_mutex_lock (&start_daemon_lock);
|
rc = npth_mutex_lock (&start_daemon_lock);
|
||||||
if (rc)
|
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
|
/* Check whether the pipe server has already been started and in
|
||||||
this case either reuse a lingering pipe connection or establish a
|
this case either reuse a lingering pipe connection or establish a
|
||||||
new socket based one. */
|
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;
|
ctx = g->primary_ctx;
|
||||||
g->primary_ctx_reusable = 0;
|
g->primary_ctx_reusable = 0;
|
||||||
@ -508,6 +509,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl)
|
|||||||
|
|
||||||
leave:
|
leave:
|
||||||
xfree (abs_homedir);
|
xfree (abs_homedir);
|
||||||
|
abs_homedir = NULL;
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
rc = npth_mutex_unlock (&start_daemon_lock);
|
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);
|
rc = npth_mutex_unlock (&start_daemon_lock);
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error ("failed to release the start_daemon lock: %s\n", strerror (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;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ struct inq_needpin_parm_s
|
|||||||
static int
|
static int
|
||||||
start_scd (ctrl_t ctrl)
|
start_scd (ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
return daemon_start (DAEMON_SCD, ctrl);
|
return daemon_start (DAEMON_SCD, ctrl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
static int
|
static int
|
||||||
start_tpm2d (ctrl_t ctrl)
|
start_tpm2d (ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
return daemon_start (DAEMON_TPM2D, ctrl);
|
return daemon_start (DAEMON_TPM2D, ctrl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user