From 2c982dcf86c61a900383c5254f1b10648d933258 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 11 Nov 2010 15:07:37 +0000 Subject: [PATCH] Fix bug where scdaemon kills a non-daemon gpg-agent. --- NEWS | 3 +++ agent/ChangeLog | 6 ++++++ agent/agent.h | 3 +++ agent/call-scd.c | 17 +++++++++-------- agent/gpg-agent.c | 4 ++++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index a10ac3eed..1fd3a1019 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ Noteworthy changes in version 2.1.0beta2 (unreleased) * TMPDIR is now also honored when creating a socket using --no-standard-socket and with symcryptrun's temp files. + * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in + non-daemon mode. + Noteworthy changes in version 2.1.0beta1 (2010-10-26) ----------------------------------------------------- diff --git a/agent/ChangeLog b/agent/ChangeLog index f41a09607..289b42f6f 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,9 @@ +2010-11-11 Werner Koch + + * agent.h (opt): Add field SIGUSR2_ENABLED. + * gpg-agent.c (handle_connections): Set that flag. + * call-scd.c (start_scd): Enable events depending on this flag. + 2010-10-27 Werner Koch * gpg-agent.c (create_socket_name): Use TMPDIR. Change callers. diff --git a/agent/agent.h b/agent/agent.h index 2700d8a91..7716bb0c2 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -58,6 +58,9 @@ struct /* True if we are listening on the standard socket. */ int use_standard_socket; + /* True if we handle sigusr2. */ + int sigusr2_enabled; + /* Environment setting gathered at program start or changed using the Assuan command UPDATESTARTUPTTY. */ session_env_t startup_env; diff --git a/agent/call-scd.c b/agent/call-scd.c index 43e01981f..34d5254bd 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -399,17 +399,18 @@ start_scd (ctrl_t ctrl) /* Tell the scdaemon we want him to send us an event signal. We don't support this for W32CE. */ #ifndef HAVE_W32CE_SYSTEM - { - char buf[100]; - + if (opt.sigusr2_enabled) + { + char buf[100]; + #ifdef HAVE_W32_SYSTEM - snprintf (buf, sizeof buf, "OPTION event-signal=%lx", - (unsigned long)get_agent_scd_notify_event ()); + snprintf (buf, sizeof buf, "OPTION event-signal=%lx", + (unsigned long)get_agent_scd_notify_event ()); #else - snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); + snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); #endif - assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); - } + assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); + } #endif /*HAVE_W32CE_SYSTEM*/ primary_scd_ctx = ctx; diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 8d0000f70..f4732fde3 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -1894,6 +1894,10 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh) #endif time_ev = NULL; + /* Set a flag to tell call-scd.c that it may enable event + notifications. */ + opt.sigusr2_enabled = 1; + FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); nfd = FD2INT (listen_fd);