Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-26 Thread Ludovic Rousseau
2011/8/26 Viktor Tarasov :
> Le 26/08/2011 16:40, Ludovic Rousseau a écrit :
>>
>> 2011/8/25 Viktor Tarasov:
>>>
>>> In the OpenSC context the detached reader/token is unknown before the
>>> SCardGetStatusChange() called.
>>> In windows, XP or Vista, the ScardGetStatusChange called for unknown
>>> reader
>>> returns SCARD_E_NO_READERS_AVAILABLE.
>>>
>>> The last revision of pcsc-lite, in such a case, returns the
>>> SCARD_E_UNKNOWN_READER, which seems to be more appropriate to the
>>> situation.
>>
>> This is very strange. I do not have that on my Windows XP SP 3.
>> I compile and run the following program:
>>
>> // pcsc.cpp : main project file.
>>
>> #include "stdafx.h"
>> #include
>> #include
>>
>> using namespace System;
>>
>> int main(array  ^args)
>> {
>>        LONG rv;
>>        SCARDCONTEXT context;
>>        SCARD_READERSTATE readers[2];
>>
>>        rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL,
>> NULL,&context);
>>        printf("%08X\n", rv);
>>
>>        readers[0].szReader = L"foo";
>>        readers[1].szReader = L"bar";
>>        rv = SCardGetStatusChange(context, 100, readers, 2);
>>        printf("%08X\n", rv);
>>
>>        rv = SCardReleaseContext(context);
>>        printf("%08X\n", rv);
>>
>>     return 0;
>> }
>>
>> And I get as output:
>> 
>> 8019
>> 
>>
>> 8019 is SCARD_E_UNKNOWN_READER.
>> So I do not get SCARD_E_NO_READERS_AVAILABLE as you do.
>
> Ok,
> you have the SCARD_E_UNKNOWN_READER in the context of your test on 'your'
> Windows,
> I have SCARD_E_NO_READERS_AVAILABLE in the context of OpenSC on 'my' Windows
> .
>
> On 'my' Windows your Python test gives 'SCARD_E_NO_READERS_AVAILABLE' .
>
> I have no intention to perceive mysteries of Windows -- in any case both
> these errors has to be treated by OpenSC (as well as different behavior of
> the different pcsc-lite versions). And it's not complicated, because both
> these SCARD_E errors are translated by reader-pcsc.c into the same error
> SC_ERROR 'NO_READERS_FOUND'.
>
> For the OpenSC there is no difference between two SCARD_E errors and this
> difference has no impact onto the proposed solution for the bug with the
> detached token .
> Have you any comments for the proposed solution ?

No

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-26 Thread Viktor Tarasov
Le 26/08/2011 16:40, Ludovic Rousseau a écrit :
> 2011/8/25 Viktor Tarasov:
>> In the OpenSC context the detached reader/token is unknown before the
>> SCardGetStatusChange() called.
>> In windows, XP or Vista, the ScardGetStatusChange called for unknown reader
>> returns SCARD_E_NO_READERS_AVAILABLE.
>>
>> The last revision of pcsc-lite, in such a case, returns the
>> SCARD_E_UNKNOWN_READER, which seems to be more appropriate to the situation.
> This is very strange. I do not have that on my Windows XP SP 3.
> I compile and run the following program:
>
> // pcsc.cpp : main project file.
>
> #include "stdafx.h"
> #include
> #include
>
> using namespace System;
>
> int main(array  ^args)
> {
>   LONG rv;
>   SCARDCONTEXT context;
>   SCARD_READERSTATE readers[2];
>
>   rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL,&context);
>   printf("%08X\n", rv);
>
>   readers[0].szReader = L"foo";
>   readers[1].szReader = L"bar";
>   rv = SCardGetStatusChange(context, 100, readers, 2);
>   printf("%08X\n", rv);
>
>   rv = SCardReleaseContext(context);
>   printf("%08X\n", rv);
>
>  return 0;
> }
>
> And I get as output:
> 
> 8019
> 
>
> 8019 is SCARD_E_UNKNOWN_READER.
> So I do not get SCARD_E_NO_READERS_AVAILABLE as you do.

Ok,
you have the SCARD_E_UNKNOWN_READER in the context of your test on 'your' 
Windows,
I have SCARD_E_NO_READERS_AVAILABLE in the context of OpenSC on 'my' Windows .

On 'my' Windows your Python test gives 'SCARD_E_NO_READERS_AVAILABLE' .

I have no intention to perceive mysteries of Windows -- in any case both these 
errors has to be treated by OpenSC (as well as different behavior of the 
different pcsc-lite versions). And it's not complicated, because both these 
SCARD_E errors are 
translated by reader-pcsc.c into the same error SC_ERROR 'NO_READERS_FOUND'.

For the OpenSC there is no difference between two SCARD_E errors and this 
difference has no impact onto the proposed solution for the bug with the 
detached token .
Have you any comments for the proposed solution ?


> Bye

Kind regards,
Viktor.
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-26 Thread Ludovic Rousseau
2011/8/25 Viktor Tarasov :
> In the OpenSC context the detached reader/token is unknown before the
> SCardGetStatusChange() called.
> In windows, XP or Vista, the ScardGetStatusChange called for unknown reader
> returns SCARD_E_NO_READERS_AVAILABLE.
>
> The last revision of pcsc-lite, in such a case, returns the
> SCARD_E_UNKNOWN_READER, which seems to be more appropriate to the situation.

This is very strange. I do not have that on my Windows XP SP 3.
I compile and run the following program:

// pcsc.cpp : main project file.

#include "stdafx.h"
#include 
#include 

using namespace System;

int main(array ^args)
{
LONG rv;
SCARDCONTEXT context;
SCARD_READERSTATE readers[2];

rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &context);
printf("%08X\n", rv);

readers[0].szReader = L"foo";
readers[1].szReader = L"bar";
rv = SCardGetStatusChange(context, 100, readers, 2);
printf("%08X\n", rv);

rv = SCardReleaseContext(context);
printf("%08X\n", rv);

return 0;
}

And I get as output:

8019


8019 is SCARD_E_UNKNOWN_READER.
So I do not get SCARD_E_NO_READERS_AVAILABLE as you do.

Bye

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-25 Thread Viktor Tarasov
Le 11/08/2011 13:29, Ludovic Rousseau a écrit :
> 2011/8/11 Viktor Tarasov:
>> Le 08/08/2011 16:31, Ludovic Rousseau a écrit :
>>> 2011/7/19 Viktor Tarasov:
 Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
> 2011/7/10 Viktor Tarasov:
>> Hi,
> Hello,
>
>> there is patch proposal to treat properly the 'detach token(reader)'
>> event
>> and to remove the slots associated to the removed token.
>>
>> Tested in Linux and windows.
>> 'SCardGetStatusChange' have different behavior in Linux and Windows.
>> Needs to be studied and validated for Mac.
>>
>>
>>
>> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>   /* When token is hot-unplugged:
>* - in Linux (pcsc-lite)
>* -- SCardGetStatusChange returns OK;
>* -- current reader state is 'UNKNOWN';
>* -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>*
>* - in Windows (WinSCard):
>* -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>* -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>*
>* - FIXME: Mac?
>*/
>
> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
> same result as on GNU/Linux.
> On GNU/Linux : new state is 14 =>  ['Changed', 'Unknown',
> 'Unavailable']
> On Mac OS X : new state is 6 =>  ['Changed', 'Unknown]
>
> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
> when you use TWO readers in the SCardGetStatusChange() call?
 I do not completely follow.

 SCardGetStatusChange is called by refresh_attributes(sc_reader_t
 *reader).
 In this context there is only one reader.

 When this reader is unplugged in Windows the SCardGetStatusChange returns
 8010002E -- SCARD_E_NO_READERS_AVAILABLE.
 In Linux SCardGetStatusChange returns OK and properly sets a new reader
 status.
 Imho both have a reason.
>>> I can't reproduce the "problem" on my Windows XP using my Python sample.
>>>
>>> If SCardGetStatusChange() is called with a removed/unknown reader then
>>> Windows SCardGetStatusChange() returns with SCARD_E_UNKNOWN_READER. I
>>> just changed pcsc-lite in revision 5881 to also return
>>> SCARD_E_UNKNOWN_READER when called with unknown reader(s).
>>>
>>> If I unplug a reader while SCardGetStatusChange() is running I get
>>> SCARD_S_SUCCESS and the new reader state is ['Ignore', 'Changed',
>>> 'Unavailable']
>>>
>>> Viktor, are you using Windows XP? or a newer version?
>> I use WindowsXP SP2 in VM and pkcs11-tool from OpenSC to make the tests .
>> I will experiment with more debugs to get know the details of the calling
>> context .
> I used my Python sample test
> http://anonscm.debian.org/viewvc/pcsclite/trunk/PCSC/UnitaryTests/SCardGetStatusChange.py?view=markup
>
>> For you the 'normal' behavior of SCardGetStatusChange() is to return
>> SCARD_S_SUCCESS and appropriate reader status,
>> is it so?
> Yes. Unless the reader is unknown (has been removed) _before_
> SCardGetStatusChange() is called.


In the OpenSC context the detached reader/token is unknown before the 
SCardGetStatusChange() called.
In windows, XP or Vista, the ScardGetStatusChange called for unknown reader 
returns SCARD_E_NO_READERS_AVAILABLE.

The last revision of pcsc-lite, in such a case, returns the 
SCARD_E_UNKNOWN_READER, which seems to be more appropriate to the situation.


> > From your log opensc-debug.win32.detach-unique-token.log I interpret it as:
> - OpenSC gets a card removed event
> 2011-07-22 11:34:45.763 'Aktiv Rutoken ECP 0' before=0x00010122 now=0x000B
> 2011-07-22 11:34:45.763 card removed event
>
> - OpenSC calls SCardGetStatusChange() and get SCARD_E_NO_READERS_AVAILABLE
> 2011-07-22 11:34:45.950 [opensc-pkcs11]
> reader-pcsc.c:361:pcsc_detect_card_presence: called
> 2011-07-22 11:34:45.950 Aktiv Rutoken ECP 0 check
> 2011-07-22 11:34:45.950 Aktiv Rutoken ECP 0:SCardGetStatusChange
> failed: 0x8010002e
> 2011-07-22 11:34:45.950 [opensc-pkcs11]
> reader-pcsc.c:365:pcsc_detect_card_presence: returning with: -1101 (No
> readers found)
>
> Since this is a token, a card removed event is also a reader removed event.
> So it is normal to get an error from SCardGetStatusChange(). pcsc-lite
> will return SCARD_E_UNKNOWN_READER instead of
> SCARD_E_NO_READERS_AVAILABLE returned by Windows XP.
> Windows XP also returns SCARD_E_UNKNOWN_READER (with my sample). So I
> guess my Python sample does not do exactly what OpenSC is doing.


In you sample the SCardGetStatusChange is called _before_ the reader is 
detached (and 'detach' event is waited for on the timeout of 
ScardGetStatusChange).

To reproduce the ""problem"" and approach the OpenSC context you probably need 
to introduce 'time.sleep()' into your script before SCardGetStatusChange
and withdraw the token during it.

Also the SCardGetStatusChange has to be called on one 

Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-11 Thread Ludovic Rousseau
2011/8/11 Viktor Tarasov :
> Le 08/08/2011 16:31, Ludovic Rousseau a écrit :
>>
>> 2011/7/19 Viktor Tarasov:
>>>
>>> Le 18/07/2011 14:52, Ludovic Rousseau a écrit :

 2011/7/10 Viktor Tarasov:
>
> Hi,

 Hello,

> there is patch proposal to treat properly the 'detach token(reader)'
> event
> and to remove the slots associated to the removed token.
>
> Tested in Linux and windows.
> 'SCardGetStatusChange' have different behavior in Linux and Windows.
> Needs to be studied and validated for Mac.
>
>
>
> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d

  /* When token is hot-unplugged:
   * - in Linux (pcsc-lite)
   * -- SCardGetStatusChange returns OK;
   * -- current reader state is 'UNKNOWN';
   * -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
   *
   * - in Windows (WinSCard):
   * -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
   * -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
   *
   * - FIXME: Mac?
   */

 I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
 same result as on GNU/Linux.
 On GNU/Linux : new state is 14 =>    ['Changed', 'Unknown',
 'Unavailable']
 On Mac OS X : new state is 6 =>    ['Changed', 'Unknown]

 On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
 when you use TWO readers in the SCardGetStatusChange() call?
>>>
>>> I do not completely follow.
>>>
>>> SCardGetStatusChange is called by refresh_attributes(sc_reader_t
>>> *reader).
>>> In this context there is only one reader.
>>>
>>> When this reader is unplugged in Windows the SCardGetStatusChange returns
>>> 8010002E -- SCARD_E_NO_READERS_AVAILABLE.
>>> In Linux SCardGetStatusChange returns OK and properly sets a new reader
>>> status.
>>> Imho both have a reason.
>>
>> I can't reproduce the "problem" on my Windows XP using my Python sample.
>>
>> If SCardGetStatusChange() is called with a removed/unknown reader then
>> Windows SCardGetStatusChange() returns with SCARD_E_UNKNOWN_READER. I
>> just changed pcsc-lite in revision 5881 to also return
>> SCARD_E_UNKNOWN_READER when called with unknown reader(s).
>>
>> If I unplug a reader while SCardGetStatusChange() is running I get
>> SCARD_S_SUCCESS and the new reader state is ['Ignore', 'Changed',
>> 'Unavailable']
>>
>> Viktor, are you using Windows XP? or a newer version?
>
> I use WindowsXP SP2 in VM and pkcs11-tool from OpenSC to make the tests .
> I will experiment with more debugs to get know the details of the calling
> context .

I used my Python sample test
http://anonscm.debian.org/viewvc/pcsclite/trunk/PCSC/UnitaryTests/SCardGetStatusChange.py?view=markup

> For you the 'normal' behavior of SCardGetStatusChange() is to return
> SCARD_S_SUCCESS and appropriate reader status,
> is it so?

Yes. Unless the reader is unknown (has been removed) _before_
SCardGetStatusChange() is called.

>From your log opensc-debug.win32.detach-unique-token.log I interpret it as:
- OpenSC gets a card removed event
2011-07-22 11:34:45.763 'Aktiv Rutoken ECP 0' before=0x00010122 now=0x000B
2011-07-22 11:34:45.763 card removed event

- OpenSC calls SCardGetStatusChange() and get SCARD_E_NO_READERS_AVAILABLE
2011-07-22 11:34:45.950 [opensc-pkcs11]
reader-pcsc.c:361:pcsc_detect_card_presence: called
2011-07-22 11:34:45.950 Aktiv Rutoken ECP 0 check
2011-07-22 11:34:45.950 Aktiv Rutoken ECP 0:SCardGetStatusChange
failed: 0x8010002e
2011-07-22 11:34:45.950 [opensc-pkcs11]
reader-pcsc.c:365:pcsc_detect_card_presence: returning with: -1101 (No
readers found)

Since this is a token, a card removed event is also a reader removed event.
So it is normal to get an error from SCardGetStatusChange(). pcsc-lite
will return SCARD_E_UNKNOWN_READER instead of
SCARD_E_NO_READERS_AVAILABLE returned by Windows XP.
Windows XP also returns SCARD_E_UNKNOWN_READER (with my sample). So I
guess my Python sample does not do exactly what OpenSC is doing.

I will do more testing and try to find in which cases Windows returns
SCARD_E_NO_READERS_AVAILABLE.

Bye

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-11 Thread Viktor Tarasov
Le 08/08/2011 16:31, Ludovic Rousseau a écrit :
> 2011/7/19 Viktor Tarasov:
>> Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
>>> 2011/7/10 Viktor Tarasov:
 Hi,
>>> Hello,
>>>
 there is patch proposal to treat properly the 'detach token(reader)'
 event
 and to remove the slots associated to the removed token.

 Tested in Linux and windows.
 'SCardGetStatusChange' have different behavior in Linux and Windows.
 Needs to be studied and validated for Mac.


 https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>>>   /* When token is hot-unplugged:
>>>* - in Linux (pcsc-lite)
>>>* -- SCardGetStatusChange returns OK;
>>>* -- current reader state is 'UNKNOWN';
>>>* -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>>>*
>>>* - in Windows (WinSCard):
>>>* -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>>>* -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>>>*
>>>* - FIXME: Mac?
>>>*/
>>>
>>> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
>>> same result as on GNU/Linux.
>>> On GNU/Linux : new state is 14 =>['Changed', 'Unknown', 'Unavailable']
>>> On Mac OS X : new state is 6 =>['Changed', 'Unknown]
>>>
>>> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
>>> when you use TWO readers in the SCardGetStatusChange() call?
>> I do not completely follow.
>>
>> SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
>> In this context there is only one reader.
>>
>> When this reader is unplugged in Windows the SCardGetStatusChange returns
>> 8010002E -- SCARD_E_NO_READERS_AVAILABLE.
>> In Linux SCardGetStatusChange returns OK and properly sets a new reader
>> status.
>> Imho both have a reason.
> I can't reproduce the "problem" on my Windows XP using my Python sample.
>
> If SCardGetStatusChange() is called with a removed/unknown reader then
> Windows SCardGetStatusChange() returns with SCARD_E_UNKNOWN_READER. I
> just changed pcsc-lite in revision 5881 to also return
> SCARD_E_UNKNOWN_READER when called with unknown reader(s).
>
> If I unplug a reader while SCardGetStatusChange() is running I get
> SCARD_S_SUCCESS and the new reader state is ['Ignore', 'Changed',
> 'Unavailable']
>
> Viktor, are you using Windows XP? or a newer version?

I use WindowsXP SP2 in VM and pkcs11-tool from OpenSC to make the tests .
I will experiment with more debugs to get know the details of the calling 
context .

For you the 'normal' behavior of SCardGetStatusChange() is to return 
SCARD_S_SUCCESS and appropriate reader status,
is it so?

> Bye

Kind regards,
Viktor.
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-08-08 Thread Ludovic Rousseau
2011/7/19 Viktor Tarasov :
> Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
>>
>> 2011/7/10 Viktor Tarasov:
>>>
>>> Hi,
>>
>> Hello,
>>
>>> there is patch proposal to treat properly the 'detach token(reader)'
>>> event
>>> and to remove the slots associated to the removed token.
>>>
>>> Tested in Linux and windows.
>>> 'SCardGetStatusChange' have different behavior in Linux and Windows.
>>> Needs to be studied and validated for Mac.
>>>
>>>
>>> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>>
>>  /* When token is hot-unplugged:
>>   * - in Linux (pcsc-lite)
>>   * -- SCardGetStatusChange returns OK;
>>   * -- current reader state is 'UNKNOWN';
>>   * -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>>   *
>>   * - in Windows (WinSCard):
>>   * -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>>   * -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>>   *
>>   * - FIXME: Mac?
>>   */
>>
>> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
>> same result as on GNU/Linux.
>> On GNU/Linux : new state is 14 =>  ['Changed', 'Unknown', 'Unavailable']
>> On Mac OS X : new state is 6 =>  ['Changed', 'Unknown]
>>
>> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
>> when you use TWO readers in the SCardGetStatusChange() call?
>
> I do not completely follow.
>
> SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
> In this context there is only one reader.
>
> When this reader is unplugged in Windows the SCardGetStatusChange returns
> 8010002E -- SCARD_E_NO_READERS_AVAILABLE.
> In Linux SCardGetStatusChange returns OK and properly sets a new reader
> status.
> Imho both have a reason.

I can't reproduce the "problem" on my Windows XP using my Python sample.

If SCardGetStatusChange() is called with a removed/unknown reader then
Windows SCardGetStatusChange() returns with SCARD_E_UNKNOWN_READER. I
just changed pcsc-lite in revision 5881 to also return
SCARD_E_UNKNOWN_READER when called with unknown reader(s).

If I unplug a reader while SCardGetStatusChange() is running I get
SCARD_S_SUCCESS and the new reader state is ['Ignore', 'Changed',
'Unavailable']

Viktor, are you using Windows XP? or a newer version?

Bye

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-22 Thread Ludovic Rousseau
2011/7/22 Viktor Tarasov :
> In attachment there are parts of the debug logs coming from the 'hot-plug'
> pkcs#11 tests.
> The logs are extracted around the test of C_WaitForSlotEvent(), slightly
> modified to allow blocking mode .
>
> For windows there are traces of two tests: detachment of unique and
> non-unique readers.
>
> What I could see is:
> - after an event happens the first SCardGetStatusChange returns OK in all
> cases;
> - on windows there is no difference in logs whether the reader was unique or
> not;
> - the difference between linux and windows appears on the second (?? rather
> non-first) SCardGetStatusChange(), called by refresh-attributes.
>
> I do not looked further.
> Tell me is you need more detailed logs.

Thanks for the analysis. I will have a closer look at pcsc-lite for
"non-first" SCardGetStatusChange() calls.

Bye

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-22 Thread Viktor Tarasov

Le 20/07/2011 19:30, Viktor Tarasov a écrit :

Le 20/07/2011 19:04, Ludovic Rousseau a écrit :

2011/7/19 Viktor Tarasov:

Le 18/07/2011 14:52, Ludovic Rousseau a écrit :

2011/7/10 Viktor Tarasov:

Hi,

Hello,


there is patch proposal to treat properly the 'detach token(reader)'
event
and to remove the slots associated to the removed token.

Tested in Linux and windows.
'SCardGetStatusChange' have different behavior in Linux and Windows.
Needs to be studied and validated for Mac.


https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d

  /* When token is hot-unplugged:
   * - in Linux (pcsc-lite)
   * -- SCardGetStatusChange returns OK;
   * -- current reader state is 'UNKNOWN';
   * -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
   *
   * - in Windows (WinSCard):
   * -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
   * -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
   *
   * - FIXME: Mac?
   */

I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
same result as on GNU/Linux.
On GNU/Linux : new state is 14 =>['Changed', 'Unknown', 'Unavailable']
On Mac OS X : new state is 6 =>['Changed', 'Unknown]

On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
when you use TWO readers in the SCardGetStatusChange() call?

I do not completely follow.

SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
In this context there is only one reader.

The question was about SCardGetStatusChange() on Windows in general
not just its use by OpenSC.

I will do the test myself.



I honestly tried to do it, installed Pyton on windows, tried to run your script.
It gave syntax error on 'print' command. I don't know Pyton and postponed 'C' 
test program until the weeked.
That's why such answer.



In attachment there are parts of the debug logs coming from the 'hot-plug' 
pkcs#11 tests.
The logs are extracted around the test of C_WaitForSlotEvent(), slightly 
modified to allow blocking mode .

For windows there are traces of two tests: detachment of unique and non-unique 
readers.

What I could see is:
- after an event happens the first SCardGetStatusChange returns OK in all cases;
- on windows there is no difference in logs whether the reader was unique or 
not;
- the difference between linux and windows appears on the second (?? rather 
non-first) SCardGetStatusChange(), called by refresh-attributes.

I do not looked further.
Tell me is you need more detailed logs.

Regards,
Viktor.


detach-token-logs.tgz
Description: application/compressed-tar
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-20 Thread Viktor Tarasov
Le 20/07/2011 19:04, Ludovic Rousseau a écrit :
> 2011/7/19 Viktor Tarasov:
>> Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
>>> 2011/7/10 Viktor Tarasov:
 Hi,
>>> Hello,
>>>
 there is patch proposal to treat properly the 'detach token(reader)'
 event
 and to remove the slots associated to the removed token.

 Tested in Linux and windows.
 'SCardGetStatusChange' have different behavior in Linux and Windows.
 Needs to be studied and validated for Mac.


 https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>>>   /* When token is hot-unplugged:
>>>* - in Linux (pcsc-lite)
>>>* -- SCardGetStatusChange returns OK;
>>>* -- current reader state is 'UNKNOWN';
>>>* -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>>>*
>>>* - in Windows (WinSCard):
>>>* -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>>>* -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>>>*
>>>* - FIXME: Mac?
>>>*/
>>>
>>> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
>>> same result as on GNU/Linux.
>>> On GNU/Linux : new state is 14 =>['Changed', 'Unknown', 'Unavailable']
>>> On Mac OS X : new state is 6 =>['Changed', 'Unknown]
>>>
>>> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
>>> when you use TWO readers in the SCardGetStatusChange() call?
>> I do not completely follow.
>>
>> SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
>> In this context there is only one reader.
> The question was about SCardGetStatusChange() on Windows in general
> not just its use by OpenSC.
>
> I will do the test myself.


I honestly tried to do it, installed Pyton on windows, tried to run your script.
It gave syntax error on 'print' command. I don't know Pyton and postponed 'C' 
test program until the weeked.
That's why such answer.


> Thanks
>

Regards,
Viktor.

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-20 Thread Ludovic Rousseau
2011/7/19 Viktor Tarasov :
> Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
>>
>> 2011/7/10 Viktor Tarasov:
>>>
>>> Hi,
>>
>> Hello,
>>
>>> there is patch proposal to treat properly the 'detach token(reader)'
>>> event
>>> and to remove the slots associated to the removed token.
>>>
>>> Tested in Linux and windows.
>>> 'SCardGetStatusChange' have different behavior in Linux and Windows.
>>> Needs to be studied and validated for Mac.
>>>
>>>
>>> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>>
>>  /* When token is hot-unplugged:
>>   * - in Linux (pcsc-lite)
>>   * -- SCardGetStatusChange returns OK;
>>   * -- current reader state is 'UNKNOWN';
>>   * -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>>   *
>>   * - in Windows (WinSCard):
>>   * -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>>   * -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>>   *
>>   * - FIXME: Mac?
>>   */
>>
>> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
>> same result as on GNU/Linux.
>> On GNU/Linux : new state is 14 =>  ['Changed', 'Unknown', 'Unavailable']
>> On Mac OS X : new state is 6 =>  ['Changed', 'Unknown]
>>
>> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
>> when you use TWO readers in the SCardGetStatusChange() call?
>
> I do not completely follow.
>
> SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
> In this context there is only one reader.

The question was about SCardGetStatusChange() on Windows in general
not just its use by OpenSC.

I will do the test myself.
Thanks

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-19 Thread Viktor Tarasov
Le 18/07/2011 14:52, Ludovic Rousseau a écrit :
> 2011/7/10 Viktor Tarasov:
>> Hi,
> Hello,
>
>> there is patch proposal to treat properly the 'detach token(reader)' event
>> and to remove the slots associated to the removed token.
>>
>> Tested in Linux and windows.
>> 'SCardGetStatusChange' have different behavior in Linux and Windows.
>> Needs to be studied and validated for Mac.
>>
>> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d
>   /* When token is hot-unplugged:
>* - in Linux (pcsc-lite)
>* -- SCardGetStatusChange returns OK;
>* -- current reader state is 'UNKNOWN';
>* -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
>*
>* - in Windows (WinSCard):
>* -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
>* -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
>*
>* - FIXME: Mac?
>*/
>
> I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
> same result as on GNU/Linux.
> On GNU/Linux : new state is 14 =>  ['Changed', 'Unknown', 'Unavailable']
> On Mac OS X : new state is 6 =>  ['Changed', 'Unknown]
>
> On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
> when you use TWO readers in the SCardGetStatusChange() call?

I do not completely follow.

SCardGetStatusChange is called by refresh_attributes(sc_reader_t *reader).
In this context there is only one reader.

When this reader is unplugged in Windows the SCardGetStatusChange returns 
8010002E -- SCARD_E_NO_READERS_AVAILABLE.
In Linux SCardGetStatusChange returns OK and properly sets a new reader status.
Imho both have a reason.

Finally it's not so important -- both situations are checked and, according to 
the results of your tests, nothing special has to be done for Mac.


> That
> would be very strange for me since at least 1 reader is still
> available.
>
> My sample program is available at [1] if you want to test it on Windows.
>
> Bye

Kind regards,
Viktor.

> [1] 
> http://anonscm.debian.org/viewvc/pcsclite/trunk/PCSC/UnitaryTests/SCardGetStatusChange.py?view=markup
>

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Patch: remove slots of detached reader(token)

2011-07-18 Thread Ludovic Rousseau
2011/7/10 Viktor Tarasov :
> Hi,

Hello,

> there is patch proposal to treat properly the 'detach token(reader)' event
> and to remove the slots associated to the removed token.
>
> Tested in Linux and windows.
> 'SCardGetStatusChange' have different behavior in Linux and Windows.
> Needs to be studied and validated for Mac.
>
> https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d

 /* When token is hot-unplugged:
  * - in Linux (pcsc-lite)
  * -- SCardGetStatusChange returns OK;
  * -- current reader state is 'UNKNOWN';
  * -- 'Refresh-attributes' returns 'SC_ERROR_READER_DETACHED'.
  *
  * - in Windows (WinSCard):
  * -- SCardGetStatusChange failes with SCARD_E_NO_READERS_AVAILABLE;
  * -- 'Refresh-attributes' returns 'SC_ERROR_NO_READERS_FOUND'.
  *
  * - FIXME: Mac?
  */

I just checked on Mac OS X 10.6.8 (Snow Leopard) and I have nearly the
same result as on GNU/Linux.
On GNU/Linux : new state is 14 => ['Changed', 'Unknown', 'Unavailable']
On Mac OS X : new state is 6 => ['Changed', 'Unknown]

On Windows, do you also get the error SCARD_E_NO_READERS_AVAILABLE
when you use TWO readers in the SCardGetStatusChange() call? That
would be very strange for me since at least 1 reader is still
available.

My sample program is available at [1] if you want to test it on Windows.

Bye

[1] 
http://anonscm.debian.org/viewvc/pcsclite/trunk/PCSC/UnitaryTests/SCardGetStatusChange.py?view=markup

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


[opensc-devel] Patch: remove slots of detached reader(token)

2011-07-10 Thread Viktor Tarasov
Hi,

there is patch proposal to treat properly the 'detach token(reader)' event
and to remove the slots associated to the removed token.

Tested in Linux and windows.
'SCardGetStatusChange' have different behavior in Linux and Windows.
Needs to be studied and validated for Mac.

https://github.com/viktorTarasov/OpenSC/commit/62bda63bd66c4849c0ca4303a9682fb6f6bacd7d

Kind regards,
Viktor.

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel