How should I detect if I've got a reader/smartcard combo?

Grant Olson kgo at grant-olson.net
Wed Jan 19 01:26:14 CET 2011


On 1/18/11 7:02 PM, NIIBE Yutaka wrote:
> 
> I think that I have something similar problem.  I am using a USB Token
> which I develop for myself.
> 
> My current solution was posted here:
>    http://lists.gnupg.org/pipermail/gnupg-devel/2010-November/025828.html
> 
> This is a patch to keep scdaemon running well.
> 

I did try your patch.  It didn't apply cleanly to the head of
STABLE-BRANCH-2.0 because of some changes.  It was easy enough to figure
out how to manually merge, but it didn't seem to work for me at all with
some manual tests.

> These days, I rather think another approach would be better.
> 
>    * scdaemon is going to exit when it detects reader unplugged
> 
>    * gpg-agent handles terminate of scdaemon
> 
>    * gpg-agent once again does "learn" when user accesses the card
> 

My fix does two things so far:

1) Closes the reader when the card is removed.  This works fine for a
combo device, but I don't think we want to do this all the time.

2) Keeps the reader slots marked as invalid if we can't initialize any
device.  Currently, if you run an operation without a card plugged in,
CCID intitialization fails.  Then PC/SC initialization fails, but it
still leaves a slot open with a bad configuration.  Because of this,
scdaemon no longer even tries to connect to CCID, and just complains it
can't find a card via the PC/SC driver.

There are two problems I still need to deal with.

1) Like I said, what do I do for a normal reader/card combo?  I don't
think we want to kill that when the card is removed.

2) Now that the slots are invalid after you yank out the card, scdaemon
polls for the hardware in an infinite loop.  It seems to me scdaemon
should try once and no more.  If it can't find hardware, it should wait
until gpg-agent requests another operation before trying to re-detect
the reader.

If I get issue two taken care of, I'll post a patch so you can see how
it works with Gnuk.

-- 
Grant

"I am gravely disappointed. Again you have made me unleash my dogs of war."



More information about the Gnupg-devel mailing list