Let scdaemon exit when no reader is available

NIIBE Yutaka gniibe at fsij.org
Wed Nov 21 02:37:29 CET 2012


Hello,

In June, I talked about how scdaemon should handle card
insertion/removal and card reader insertion/removal.  Let me talk it
again.

Currently, a card is detected by scdaemon when user tries to use it at
first.  Next, when the card is removed, it is detected by scdaemon.
Then, scdameon keeps polling, and the insertion will be detected.

In my opinion, it is no problem for scdaemon not to poll to detect
card insertion or card reader insertion after removal.  I mean, it is
OK for user that scdaemon detects it when he tries to use the card
again.  It's just like the first use of a card.

The reason why I propose the change of scdaemon's behavior is that
some people (including me) don't expect its polling for insertion, but
expect its finish of execution.

Here is a patch which let scdaemon exit when it detects removal of a
card reader.  It is to discuss the issue of scdaemon keeps polling
(for insertion) after removal of a card reader.  It is not yet to
handle card removal.

Note that this patch is not enough to fix the bug reported in Debian:

   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=687250

The patch only works when scdaemon uses internal ccid driver and
there is no PC/SC service.

This patch is a bit stronger proposal than the one in June.  The
version in June was just to stop opening card reader by
scd_update_reader_status_file and it doesn't let scdaemon finish its
execution.  I think that this one is better not to waste computer
resource.

diff --git a/scd/command.c b/scd/command.c
index 17da5b7..64b1d5f 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -2430,4 +2430,6 @@ scd_update_reader_status_file (void)
   if (err)
     log_error ("failed to release status_file_update lock: %s\n",
 	       strerror (err));
+  if (reader_disabled)
+    scd_exit (1);
 }





More information about the Gnupg-devel mailing list