aboutsummaryrefslogtreecommitdiffstats
path: root/agent/call-daemon.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-06-27 06:26:25 +0000
committerNIIBE Yutaka <[email protected]>2024-06-27 06:26:25 +0000
commit5d980802acb3e385c6d2a10e8b3ae95d362da953 (patch)
treef41f6e35c890117994f250a62d1659db0b79ab0f /agent/call-daemon.c
parentscd: Restrict use of DEVINFO --watch command for socket connection. (diff)
downloadgnupg-5d980802acb3e385c6d2a10e8b3ae95d362da953.tar.gz
gnupg-5d980802acb3e385c6d2a10e8b3ae95d362da953.zip
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 <[email protected]>
Diffstat (limited to 'agent/call-daemon.c')
-rw-r--r--agent/call-daemon.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/agent/call-daemon.c b/agent/call-daemon.c
index 337bee3c2..cf5a0c85f 100644
--- a/agent/call-daemon.c
+++ b/agent/call-daemon.c
@@ -211,7 +211,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;
@@ -243,6 +243,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)
@@ -275,7 +276,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;
@@ -466,6 +467,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);
@@ -482,6 +484,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;
}