From 3d58329f67ba10a21ec0b2c9c8ede6e275a3607d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 21 Apr 2004 14:43:51 +0000 Subject: [PATCH] * call-scd.c (start_scd): Send event-signal option. Always check that the scdaemon is still running. * gpg-agent.c (handle_signal): Do not use SIGUSR{1,2} anymore for changing the verbosity. --- agent/ChangeLog | 8 ++++++++ agent/call-scd.c | 31 +++++++++++++++++++++++++++---- agent/gpg-agent.c | 10 +++------- doc/gpg-agent.texi | 16 +++++++--------- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/agent/ChangeLog b/agent/ChangeLog index 43bdb7ab5..f63ae88a1 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,11 @@ +2004-04-21 Werner Koch + + * call-scd.c (start_scd): Send event-signal option. Always check + that the scdaemon is still running. + + * gpg-agent.c (handle_signal): Do not use SIGUSR{1,2} anymore for + changing the verbosity. + 2004-04-16 Werner Koch * gpg-agent.c (main): Tell the logging code taht we are runnign diff --git a/agent/call-scd.c b/agent/call-scd.c index 0bb365ced..3c2bf9e2a 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #ifdef USE_GNU_PTH # include #endif @@ -51,8 +53,8 @@ static ASSUAN_CONTEXT scd_ctx = NULL; static pth_mutex_t scd_lock = PTH_MUTEX_INIT; #endif /* We need to keep track of the connection currently using the SCD. - For a pipe server this is all a NOP becuase the connection will - always have the conenction indicator -1. agent_reset_scd releases + For a pipe server this is all a NOP because the connection will + always have the connection indicator -1. agent_reset_scd releases the active connection; i.e. sets it back to -1, so that a new connection can start using the SCD. If we eventually allow multiple SCD session we will either make scdaemon multi-threaded or @@ -195,6 +197,8 @@ start_scd (ctrl_t ctrl) if (scd_ctx) { + pid_t pid; + /* If we are not the connection currently using the SCD, return an error. */ if (!active_connection) @@ -205,8 +209,19 @@ start_scd (ctrl_t ctrl) else if (ctrl->connection_fd != active_connection_fd) return unlock_scd (gpg_error (GPG_ERR_CONFLICT)); - /* Okay, we scdaemon already started and used by us. */ - return 0; + /* Okay, we already started the scdaemon and it is used by us.*/ + + /* We better do a sanity check now to see whether it has + accidently died. */ + pid = assuan_get_pid (scd_ctx); + if (pid != (pid_t)(-1) && pid + && ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) ) + { + assuan_disconnect (scd_ctx); + scd_ctx = NULL; + } + else + return 0; } if (opt.verbose) @@ -255,6 +270,14 @@ start_scd (ctrl_t ctrl) if (DBG_ASSUAN) log_debug ("connection to SCdaemon established\n"); + /* Tell the scdaemon that we want him to send us an event signal. */ + { + char buf[100]; + + sprintf (buf, "OPTION event-signal=%d", SIGUSR2); + assuan_transact (scd_ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); + } + return 0; } diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 18a456f19..9b8678823 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -1059,15 +1059,11 @@ handle_signal (int signo) break; case SIGUSR1: - if (opt.verbose < 5) - opt.verbose++; - log_info ("SIGUSR1 received - verbosity set to %d\n", opt.verbose); + log_info ("SIGUSR1 received - no action defined\n"); break; - + case SIGUSR2: - if (opt.verbose) - opt.verbose--; - log_info ("SIGUSR2 received - verbosity set to %d\n", opt.verbose ); + log_info ("SIGUSR2 received - checking smartcard status\n"); break; case SIGTERM: diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi index 92975fd11..e199109a4 100644 --- a/doc/gpg-agent.texi +++ b/doc/gpg-agent.texi @@ -312,15 +312,6 @@ implementation, which calls the scdaemon only once, it is not of much use. -@item SIGUSR1 -@cpindex SIGUSR1 -This signal increases the verbosity of the logging by one up to a value -of 5. - -@item SIGUSR2 -@cpindex SIGUSR2 -This signal decreases the verbosity of the logging by one. - @item SIGTERM @cpindex SIGTERM Shuts down the process but waits until all current requests are @@ -331,6 +322,13 @@ are still pending, a shutdown is forced. @cpindex SIGINT Shuts down the process immediately. + +@item SIGUSR1 +@itemx SIGUSR2 +@cpindex SIGUSR1 +@cpindex SIGUSR2 +These signals are used for internal purposes. + @end table @c