Fwd: card removal detection problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: card removal detection problem

Murat Baran


---------- Forwarded message ----------
From: Murat Baran <[hidden email]>
Date: Fri, Aug 20, 2010 at 9:46 AM
Subject: card removal detection problem
To: [hidden email]


Hi,

i am using opensc, pcsc-lite on linux.
For card detection i am using sc_detect_card_presence()
in a task. Between two fuction calls if i remove and insert
the card, the funtion returns SC_SLOT_CARD_PRESENT.
So i miss the removal.
As i debug, i saw that pcsc detects the removal and the
following condition in refresh_slot_attributes()

 if (pslot->reader_state.
dwEventState & SCARD_STATE_CHANGED)

becomes true.
But later refresh_slot_attributes() removes it from the flags.
I could not see a way that SCARD_STATE_CHANGED is set
in that function.
Am i wrong?
How can i detect that removal?

Thanks

Murat Baran


_______________________________________________
opensc-user mailing list
[hidden email]
http://www.opensc-project.org/mailman/listinfo/opensc-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: card removal detection problem

Martin Paljak-2

On Aug 24, 2010, at 10:44 AM, Murat Baran wrote:
> becomes true.
> But later refresh_slot_attributes() removes it from the flags.
> I could not see a way that SCARD_STATE_CHANGED is set
> in that function.
> Am i wrong?
> How can i detect that removal?

Looking at the code it seems that you have found a bug in reader-pcsc.c. Will investigate.


--
Martin Paljak
@martinpaljak.net
+3725156495

_______________________________________________
opensc-user mailing list
[hidden email]
http://www.opensc-project.org/mailman/listinfo/opensc-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: card removal detection problem

Martin Paljak-2
In reply to this post by Murat Baran
Hello,
On Tue, Aug 24, 2010 at 10:44, Murat Baran <[hidden email]> wrote:

> Hi,
>
> i am using opensc, pcsc-lite on linux.
> For card detection i am using sc_detect_card_presence()
> in a task. Between two fuction calls if i remove and insert
> the card, the funtion returns SC_SLOT_CARD_PRESENT.
> So i miss the removal.
> As i debug, i saw that pcsc detects the removal and the
> following condition in refresh_slot_attributes()
>
>  if (pslot->reader_state.
> dwEventState & SCARD_STATE_CHANGED)
>
> becomes true.
> But later refresh_slot_attributes() removes it from the flags.
> I could not see a way that SCARD_STATE_CHANGED is set
> in that function.
> Am i wrong?
> How can i detect that removal?

In fact, it seems impossible to detect card changes with
SCardGetStatusChange unless a connection (with sc_connect_card()) has
been done beforehand.  If a card connection exists, the handler
validity is re-checked and you would get the flag. Otherwise not. What
are you trying to do with sc_detect_card_presence?

The flag and extra detection only make sense if a card with the same
ATR but different content is inserted. I think there could be a better
and more direct method for reliably detecting this situation.

I'd suggest to remove the SC_READER_CARD_CHANGED flag and make
sc_detect_card_presence do what the name suggests, with 0 meaning "no"
and 1 meaning "yes". Any extra flags can be checked from reader->flags
for special purposes.
_______________________________________________
opensc-user mailing list
[hidden email]
http://www.opensc-project.org/mailman/listinfo/opensc-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: card removal detection problem

Martin Paljak-2
On Tue, Oct 5, 2010 at 16:17, Martin Paljak <[hidden email]> wrote:

> Hello,
> On Tue, Aug 24, 2010 at 10:44, Murat Baran <[hidden email]> wrote:
>> Hi,
>>
>> i am using opensc, pcsc-lite on linux.
>> For card detection i am using sc_detect_card_presence()
>> in a task. Between two fuction calls if i remove and insert
>> the card, the funtion returns SC_SLOT_CARD_PRESENT.
>> So i miss the removal.
>> As i debug, i saw that pcsc detects the removal and the
>> following condition in refresh_slot_attributes()
>>
>>  if (pslot->reader_state.
>> dwEventState & SCARD_STATE_CHANGED)
>>
>> becomes true.
>> But later refresh_slot_attributes() removes it from the flags.
>> I could not see a way that SCARD_STATE_CHANGED is set
>> in that function.
>> Am i wrong?
>> How can i detect that removal?

The problem should be fixed OpenSC SVN snapshot (r4798+), together
with a recent snapshot of pcsc-lite(r5278+).
_______________________________________________
opensc-user mailing list
[hidden email]
http://www.opensc-project.org/mailman/listinfo/opensc-user