Page MenuHome GnuPG

scd: "card error" after usb reader plug/unplug cycle, needs hard restart
Closed, ResolvedPublic

Description

SCD fails to access card after a unplug/replug cycle of usb reader on Debian
Etch/amd64 (pcsc-lite v1.3.2) with SCR3310, NetKey v3.0:

marc@angua:~$ gpg-connect-agent

scd serialno

S SERIALNO 89490173300008094100 0
OK

scd getinfo reader_list

D 04E6:5116:X:0%0A
OK

reader unplugged

scd getinfo reader_list

ERR 100663354 No data <SCD>

  1. ok
  2. reader re-plugged

scd getinfo reader_list

D 04E6:5116:X:0%0A
OK

ok

scd serialno

ERR 100663404 Card error <SCD>

NOT ok

scd restart

OK

scd serialno

ERR 100663404 Card error <SCD>

  1. NOT ok
  2. scdaemon manually killed

scd serialno

S SERIALNO 89490173300008094100 0
OK

ahhh... :)

getinfo version

D 2.0.13-svn5059
OK

scd getinfo version

D 2.0.13-svn5059
OK

bye

OK closing connection

Event Timeline

marc added projects: scd, Bug Report, gpg4win.
marc added a subscriber: werner.
marc added a subscriber: marc.

We should eventually do something about it. The problem is that you remove the
device and after plugging it in it is considered by the OS as a new device.
This also depends on the Os used and whether PC/SC, ctAPI or the internalCCID
driver is used.

We should eventually do soemthing about it. In the meantime you may use

gpgconf --reload scdaemon

or the Assuan command

SCD KILLSCD

don't do it automagically, better ask the user.

More info:

  • scd killscd works when in the replug-without-hibernate case, for hibernate, a restart of pcscd is needed (probably not a scd problem).
  • when I don't issue any commands to scd while the reader is unplugged, I can re-plug it anywhere (same or different usb port) and scd recognises this as a USABLE->ACTIVE->NOCARD->USABLE transition chain
  • when I issue a SERIALNO command while the reader is unplugged, I get "Card Error" back (sitenote: shouldn't that be a ERR_NO_CARD_READER?) and that one sticks until a KILLSCD.
  • this is not the case for other commands (tested: GETINFO version).

So it seems that the new usb address is not what's disturbing scd (otherwise
re-plugging itself would cause the sticky error). Rather, it seems like the
SERIALNO error code on unplugged reader is somehow sticking with the scd
instance until killed.

FWIW: I consider this an honest-to-$GOD bug, not a missing feature. Esp. in the
light of the above new data.

This looks pretty much like a pc/sc problem. Please shutdown pcscd and use the
internal CCID driver. With PC/SC we don't have any control over the USB - we
don't even know what this is.

Let me confirm. Does this bus still exist in recent version of gpg 1.4 and/or
2.0, 2.1?

I confirmed that this is fixed in 2.0 and 2.1.