Fix for plugable reader-card combos
authorWerner Koch <wk@gnupg.org>
Wed, 26 Jan 2011 07:57:38 +0000 (07:57 +0000)
committerWerner Koch <wk@gnupg.org>
Wed, 26 Jan 2011 07:57:38 +0000 (07:57 +0000)
Makefile.am
patches/gnupg2-2.0.17/01-scd-reader-removal.patch [new file with mode: 0755]

index c0c545a..e2f5741 100644 (file)
@@ -66,6 +66,7 @@ EXTRA_DIST = autogen.sh README.SVN ONEWS \
        patches/gnupg2-2.0.16/04-gpgtar-2.patch \
        patches/gnupg2-2.0.16/05-err-codes.patch \
        patches/gnupg2-2.0.16/06-reread-agent.patch \
+        patches/gnupg2-2.0.17/01-scd-reader-removal.patch \
        patches/dirmngr-1.0.3/01-ldaphttp.patch \
        patches/dirmngr-1.1.0/01-mmap.patch \
        patches/gpgol-0.9.91/01-gpgme.patch \
diff --git a/patches/gnupg2-2.0.17/01-scd-reader-removal.patch b/patches/gnupg2-2.0.17/01-scd-reader-removal.patch
new file mode 100755 (executable)
index 0000000..3456a07
--- /dev/null
@@ -0,0 +1,49 @@
+#! /bin/sh
+patch -p1 -f $* < $0
+exit $?
+
+2011-01-25  NIIBE Yutaka <gniibe@fsij.org>,
+           Grant Olson <kgo@grant-olson.net>  (wk)
+
+       * command.c (do_reset, get_reader_slot)
+       (update_reader_status_file): Fix handling of the VALID flag for
+       unplugged readers. 
+
+diff --git a/scd/command.c b/scd/command.c
+index e2cd1f5..28bc4df 100644
+--- a/scd/command.c
++++ b/scd/command.c
+@@ -309,7 +309,7 @@ do_reset (ctrl_t ctrl, int send_reset)
+     {
+       if (apdu_reset (slot)) 
+         {
+-          slot_table[slot].reset_failed = 1;
++          slot_table[slot].valid = 0;
+         }
+       application_notify_card_reset (slot);
+     }
+@@ -401,6 +401,14 @@ get_reader_slot (void)
+     {
+       int no_service_flag;
+       ss->slot = apdu_open_reader (opt.reader_port, &no_service_flag);
++
++      /* If we still don't have a slot, we have no readers.
++       Invalidate for now until a reader is attached. */
++      if(ss->slot == -1)
++      {
++        ss->valid = 0;
++      }
++
+       if (no_service_flag)
+         {
+           log_info ("no card services - disabling scdaemon\n");
+@@ -2192,6 +2200,8 @@ update_reader_status_file (int set_card_removed_flag)
+       if (sw_apdu == SW_HOST_NO_READER)
+         {
+           /* Most likely the _reader_ has been unplugged.  */
++        apdu_close_reader (ss->slot);
++        ss->valid = 0;
+           status = 0;
+           changed = ss->changed;
+         }
+