summaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2011-01-25 22:03:16 +0100
committerWerner Koch <wk@gnupg.org>2011-01-25 22:03:16 +0100
commit576de6e539646f021dafff8d4e3327c115a51ad4 (patch)
tree6f0f0d6043a7dce6291f9b5e3c38c424f171efb0 /scd
parentDetect non operational readers. (diff)
downloadgnupg2-576de6e539646f021dafff8d4e3327c115a51ad4.tar.xz
gnupg2-576de6e539646f021dafff8d4e3327c115a51ad4.zip
Fixed problem with unplugging card readers.
From Grant Olsons's mail to gnupg-devel@: This is three-quarters NIIBE and one-quarter me, but I though it would be easier to have a single complete patch that applies to STABLE-BRANCH-2-0 than two patches floating around. This is basically NIIBE Yatuka's patch here: http://lists.gnupg.org/pipermail/gnupg-devel/2010-November/025828.html Plus another check that closes down the reader explicitly if we get a SW_HOST_NO_READER error, so that an unplugged reader doesn't hold onto the first slot, preventing us from getting to the active plugged reader.
Diffstat (limited to 'scd')
-rw-r--r--scd/ChangeLog7
-rw-r--r--scd/command.c12
2 files changed, 18 insertions, 1 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog
index d1e942a62..c9f92b428 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2011-01-25 Werner Koch <wk@g10code.com>
From 2.0 branch, 2010-03-17:
diff --git a/scd/command.c b/scd/command.c
index 36aff9762..a44378d43 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");
@@ -2190,6 +2198,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;
}