From ludovic.rousseau at gmail.com  Wed May 11 09:17:02 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Wed, 11 May 2022 18:17:02 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
Message-ID: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>

Hello,

I just released a new version of pcsc-lite 1.9.6.

Changes:
1.9.6: Ludovic Rousseau
11 May 2022
- do not fail reader removal in some specific cases (USB/Thunderbolt port)
- improve documentation regarding /etc/reader.conf.d/
- SCardGetStatusChange: speedup the case DISABLE_AUTO_POWER_ON
- configure:
  . add --disable-strict option
   By default the compiler arguments are now:
   -Wall -Wextra -Wno-unused-parameter -Werror ${CFLAGS}
  . fail if flex is not found
- fix different data races
- pcscdaemon: -v displays internal constants values:
  MAX_READERNAME & PCSCLITE_MAX_READERS_CONTEXTS
- Some other minor improvements

See my blog post for more details.

https://ludovicrousseau.blogspot.com/2022/05/new-version-of-pcsc-lite-196.html
https://pcsclite.apdu.fr/
https://github.com/LudovicRousseau/PCSC
https://salsa.debian.org/rousseau/PCSC

-- 
 Dr. Ludovic Rousseau


From axel.braun at gmx.de  Wed May 11 12:55:51 2022
From: axel.braun at gmx.de (Axel Braun)
Date: Wed, 11 May 2022 21:55:51 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
In-Reply-To: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
References: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
Message-ID: <2179945.72vocr9iq0@x1e>

Hi Ludovic,

Am Mittwoch, 11. Mai 2022, 18:17:02 CEST schrieb Ludovic Rousseau:

> I just released a new version of pcsc-lite 1.9.6.

Irun into the following error:

[   18s] libtool: link: (cd ".libs" && rm -f "libpcsclite.so" && ln -s
"libpcsclite.so.1.0.0" "libpcsclite.so")
[   18s] libtool: link: ( cd ".libs" && rm -f "libpcsclite.la" && ln -s "../
libpcsclite.la" "libpcsclite.la" )
[   18s] /usr/bin/bash ../libtool  --tag=CC   --mode=link gcc  -Wall -Wextra -
Wno-unused-parameter -Werror -Wall -fno-common -O2 -Wall -D_FORTIFY_SOURCE=2 -
fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-
clash-protection -Werror=return-type -flto=auto -g  -flto=auto -o testpcsc
testpcsc.o libpcsclite.la -lrt
[   18s] libtool: link: gcc -Wall -Wextra -Wno-unused-parameter -Werror -Wall
-fno-common -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-
tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-
type -flto=auto -g -flto=auto -o .libs/testpcsc testpcsc.o  ./.libs/
libpcsclite.so -lrt -pthread -Wl,-rpath -Wl,/usr/lib64
[   18s] pcscdaemon.c: In function 'main':
[   18s] winscard_msg_srv.c:259:25: error: 'dwClientID' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
[   18s]   259 |                         Log2(PCSC_LOG_ERROR,
[   18s]       |                         ^
[   18s] pcscdaemon.c:110:18: note: 'dwClientID' was declared here
[   18s]   110 |         uint32_t dwClientID;    /* Connection ID used to
reference the Client */
[   18s]       |                  ^
[   18s] lto1: all warnings being treated as errors

With the option --disable-strict the error is gone.

Is this what you recommend in that case?

Cheers
Axel




From ludovic.rousseau at gmail.com  Thu May 12 06:20:01 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Thu, 12 May 2022 15:20:01 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
In-Reply-To: <2179945.72vocr9iq0@x1e>
References: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
 <2179945.72vocr9iq0@x1e>
Message-ID: <CAGstE8A7UJach3DQQhETOe-h79hH8s+udBxT+W5ypXEyyBgesA@mail.gmail.com>

Le mer. 11 mai 2022 ? 23:04, Axel Braun <axel.braun at gmx.de> a ?crit :
> Hi Ludovic,

Hello,

> Am Mittwoch, 11. Mai 2022, 18:17:02 CEST schrieb Ludovic Rousseau:
>
> > I just released a new version of pcsc-lite 1.9.6.
>
> Irun into the following error:
>
> [   18s] libtool: link: (cd ".libs" && rm -f "libpcsclite.so" && ln -s
> "libpcsclite.so.1.0.0" "libpcsclite.so")
> [   18s] libtool: link: ( cd ".libs" && rm -f "libpcsclite.la" && ln -s "../
> libpcsclite.la" "libpcsclite.la" )
> [   18s] /usr/bin/bash ../libtool  --tag=CC   --mode=link gcc  -Wall -Wextra -
> Wno-unused-parameter -Werror -Wall -fno-common -O2 -Wall -D_FORTIFY_SOURCE=2 -
> fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-
> clash-protection -Werror=return-type -flto=auto -g  -flto=auto -o testpcsc
> testpcsc.o libpcsclite.la -lrt
> [   18s] libtool: link: gcc -Wall -Wextra -Wno-unused-parameter -Werror -Wall
> -fno-common -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-
> tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-
> type -flto=auto -g -flto=auto -o .libs/testpcsc testpcsc.o  ./.libs/
> libpcsclite.so -lrt -pthread -Wl,-rpath -Wl,/usr/lib64
> [   18s] pcscdaemon.c: In function 'main':
> [   18s] winscard_msg_srv.c:259:25: error: 'dwClientID' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> [   18s]   259 |                         Log2(PCSC_LOG_ERROR,
> [   18s]       |                         ^
> [   18s] pcscdaemon.c:110:18: note: 'dwClientID' was declared here
> [   18s]   110 |         uint32_t dwClientID;    /* Connection ID used to
> reference the Client */
> [   18s]       |                  ^
> [   18s] lto1: all warnings being treated as errors
>
> With the option --disable-strict the error is gone.
>
> Is this what you recommend in that case?

Yes. The error should just be a warning and ignored.

Can apply this patch and try again:
diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
index e07ade4..35649c3 100644
--- a/src/pcscdaemon.c
+++ b/src/pcscdaemon.c
@@ -107,7 +107,7 @@ static void SVCServiceRunLoop(void)
 {
     int rsp;
     LONG rv;
-    uint32_t dwClientID;    /* Connection ID used to reference the Client */
+    uint32_t dwClientID = 0;    /* Connection ID used to reference
the Client */

     while (TRUE)
     {



The problem is detected at the link stage, not compilation.
It is nice to see progress in the static analysis of our tools.

What version of OS and gcc do you use?

Bye

-- 
 Dr. Ludovic Rousseau


From axel.braun at gmx.de  Thu May 12 08:42:28 2022
From: axel.braun at gmx.de (Axel Braun)
Date: Thu, 12 May 2022 17:42:28 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
In-Reply-To: <CAGstE8A7UJach3DQQhETOe-h79hH8s+udBxT+W5ypXEyyBgesA@mail.gmail.com>
References: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
 <2179945.72vocr9iq0@x1e>
 <CAGstE8A7UJach3DQQhETOe-h79hH8s+udBxT+W5ypXEyyBgesA@mail.gmail.com>
Message-ID: <12362432.VsHLxoZxqI@x1e>

Hello Ludovic,

Am Donnerstag, 12. Mai 2022, 15:20:01 CEST schrieb Ludovic Rousseau:
> Le mer. 11 mai 2022 ? 23:04, Axel Braun <axel.braun at gmx.de> a ?crit :

> > With the option --disable-strict the error is gone.
> > 
> > Is this what you recommend in that case?
> 
> Yes. The error should just be a warning and ignored.

yes, the log stated that all warnings are treated as errors....
 
> Can apply this patch and try again:
> diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
> index e07ade4..35649c3 100644
> --- a/src/pcscdaemon.c
> +++ b/src/pcscdaemon.c
> @@ -107,7 +107,7 @@ static void SVCServiceRunLoop(void)
>  {
>      int rsp;
>      LONG rv;
> -    uint32_t dwClientID;    /* Connection ID used to reference the Client
> */ +    uint32_t dwClientID = 0;    /* Connection ID used to reference the
> Client */
> 
>      while (TRUE)
>      {
> 
> 
> 
> The problem is detected at the link stage, not compilation.

Yes, seen that in the log as well

The patch helped in fact for Tumbleweed, but failed to build for the Leap 
versions, so I reverted that

> It is nice to see progress in the static analysis of our tools.
> 
> What version of OS and gcc do you use?

I'm building for openSUSE Tumbleweed, current with gcc11, gcc12 is default 
compiler very soon (snapshot 20220510)

Cheers
Axel




From ludovic.rousseau at gmail.com  Thu May 12 12:53:36 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Thu, 12 May 2022 21:53:36 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
In-Reply-To: <12362432.VsHLxoZxqI@x1e>
References: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
 <2179945.72vocr9iq0@x1e>
 <CAGstE8A7UJach3DQQhETOe-h79hH8s+udBxT+W5ypXEyyBgesA@mail.gmail.com>
 <12362432.VsHLxoZxqI@x1e>
Message-ID: <CAGstE8BCjPCxkgAzj--K=A2VezwwuJh=TA+ksM8PTd76W8B=bw@mail.gmail.com>

Le jeu. 12 mai 2022 ? 17:43, Axel Braun <axel.braun at gmx.de> a ?crit :

> The patch helped in fact for Tumbleweed, but failed to build for the Leap
> versions, so I reverted that

I fixed the problem, and 2 other problems, in the current version.

You can get the latest source code from
https://salsa.debian.org/rousseau/PCSC
or
https://github.com/LudovicRousseau/PCSC

Thanks for the bug report.
I will make a new release soon.

Bye

-- 
 Dr. Ludovic Rousseau


From ludovic.rousseau at gmail.com  Fri May 13 04:32:31 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Fri, 13 May 2022 13:32:31 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.7
Message-ID: <CAGstE8CPedVMEd+rogdNRHdnfu1Q6OJo-YKxK07LpDdRFTZa8Q@mail.gmail.com>

Hello,

I just released a new version of pcsc-lite 1.9.7.

Changes:
1.9.7: Ludovic Rousseau
13 May 2022
- disable strict compilation by default
- fix 3 warnings

See my blog post for more details.

https://ludovicrousseau.blogspot.com/2022/05/new-version-of-pcsc-lite-197.html
https://pcsclite.apdu.fr/
https://github.com/LudovicRousseau/PCSC
https://salsa.debian.org/rousseau/PCSC

-- 
 Dr. Ludovic Rousseau


From ludovic.rousseau at gmail.com  Fri May 13 04:33:06 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Fri, 13 May 2022 13:33:06 +0200
Subject: [Pcsclite-muscle] New version of pcsc-lite: 1.9.6
In-Reply-To: <CAGstE8BCjPCxkgAzj--K=A2VezwwuJh=TA+ksM8PTd76W8B=bw@mail.gmail.com>
References: <CAGstE8C79CGAQOaXahkqv8siwp7Vf+FHMsPVd7cWABTteS1q0Q@mail.gmail.com>
 <2179945.72vocr9iq0@x1e>
 <CAGstE8A7UJach3DQQhETOe-h79hH8s+udBxT+W5ypXEyyBgesA@mail.gmail.com>
 <12362432.VsHLxoZxqI@x1e>
 <CAGstE8BCjPCxkgAzj--K=A2VezwwuJh=TA+ksM8PTd76W8B=bw@mail.gmail.com>
Message-ID: <CAGstE8AhEMidikzEkWR0c_SSC8mj+M63ym5VxkYDzxF=uJXEkQ@mail.gmail.com>

Fixed in pcsc-lite version 1.9.7
Thanks

Le jeu. 12 mai 2022 ? 21:53, Ludovic Rousseau
<ludovic.rousseau at gmail.com> a ?crit :
>
> Le jeu. 12 mai 2022 ? 17:43, Axel Braun <axel.braun at gmx.de> a ?crit :
>
> > The patch helped in fact for Tumbleweed, but failed to build for the Leap
> > versions, so I reverted that
>
> I fixed the problem, and 2 other problems, in the current version.
>
> You can get the latest source code from
> https://salsa.debian.org/rousseau/PCSC
> or
> https://github.com/LudovicRousseau/PCSC
>
> Thanks for the bug report.
> I will make a new release soon.
>
> Bye
>
> --
>  Dr. Ludovic Rousseau



-- 
 Dr. Ludovic Rousseau


From wiktor at metacode.biz  Thu May 19 04:56:48 2022
From: wiktor at metacode.biz (Wiktor Kwapisiewicz)
Date: Thu, 19 May 2022 13:56:48 +0200
Subject: [Pcsclite-muscle] Support for file-descriptor based devices in
 pcsclite
Message-ID: <ff932410-400c-42c1-615a-3a128898554f@metacode.biz>

Hello,

I'm trying to use pcsclite on Android (via Termux) and found out that 
the Android OS exposes USB devices via file descriptors (instead of 
regular files). It seems libusb can interact via these devices using two 
functions introduced in 2018 [0]:

     libusb_set_option(NULL, LIBUSB_OPTION_WEAK_AUTHORITY);
     // ...
     libusb_wrap_sys_device(context, (intptr_t) fd, &handle);

Example from [1]. The option name is also called 
LIBUSB_OPTION_NO_DEVICE_DISCOVERY in newer versions of libusb [2].

I did compile several small examples using libusb and 
libusb_wrap_sys_device and they worked fine with my tokens (Yubikeys). 
Now my question is whether support for 
LIBUSB_OPTION_WEAK_AUTHORITY/libusb_wrap_sys_device is something that 
could be considered for inclusion in pcsclite or is this out of scope?

The use-case I have in mind is using SSH and signing commits on Android 
phones. I'm already using pcsc-lite through openpgp-card crate for SSH 
and commit signing on my desktop and it works very well and I'm trying 
to replicate the setup on my tablet/phone.

Thank you for your time and have a nice day!

Kind regards,
Wiktor

[0]: https://sourceforge.net/p/libusb/mailman/message/36486446/

[1]: https://wiki.termux.com/wiki/Termux-usb

[2]: https://libusb.sourceforge.io/api-1.0/group__libusb__lib.html

[3]: https://crates.io/crates/openpgp-card


From ludovic.rousseau at gmail.com  Thu May 26 02:13:30 2022
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Thu, 26 May 2022 11:13:30 +0200
Subject: [Pcsclite-muscle] Support for file-descriptor based devices in
 pcsclite
In-Reply-To: <ff932410-400c-42c1-615a-3a128898554f@metacode.biz>
References: <ff932410-400c-42c1-615a-3a128898554f@metacode.biz>
Message-ID: <CAGstE8AD6Z0gSsm6kmWbjW_cgVt90+01NxdMxJ3V2MS5KH0Ppg@mail.gmail.com>

Le jeu. 19 mai 2022 ? 13:56, Wiktor Kwapisiewicz <wiktor at metacode.biz> a ?crit :
> Hello,

Hello,

Sorry for the delay. Your email was in my spam folder (gmail).

> I'm trying to use pcsclite on Android (via Termux) and found out that
> the Android OS exposes USB devices via file descriptors (instead of
> regular files). It seems libusb can interact via these devices using two
> functions introduced in 2018 [0]:
>
>      libusb_set_option(NULL, LIBUSB_OPTION_WEAK_AUTHORITY);
>      // ...
>      libusb_wrap_sys_device(context, (intptr_t) fd, &handle);
>
> Example from [1]. The option name is also called
> LIBUSB_OPTION_NO_DEVICE_DISCOVERY in newer versions of libusb [2].
>
> I did compile several small examples using libusb and
> libusb_wrap_sys_device and they worked fine with my tokens (Yubikeys).
> Now my question is whether support for
> LIBUSB_OPTION_WEAK_AUTHORITY/libusb_wrap_sys_device is something that
> could be considered for inclusion in pcsclite or is this out of scope?

Yes, I could consider something like that.

In fact I already have 2 issues opened for pcsc-lite and CCID with this idea.
"Open the device in pcscd and give the file descriptor to the driver"
https://salsa.debian.org/rousseau/PCSC/-/issues/20

"Use libusb_wrap_sys_device() and avoid rescanning the USB bus"
https://salsa.debian.org/rousseau/CCID/-/issues/11

This scheme could also be used on a "normal" computer and not only for Android.

I am waiting for your first patches.
Good idea.

> The use-case I have in mind is using SSH and signing commits on Android
> phones. I'm already using pcsc-lite through openpgp-card crate for SSH
> and commit signing on my desktop and it works very well and I'm trying
> to replicate the setup on my tablet/phone.

What smart card reader do you plan to use with your Android phone?

> Thank you for your time and have a nice day!

You too.
Bye

-- 
 Dr. Ludovic Rousseau


From wiktor at metacode.biz  Thu May 26 02:26:06 2022
From: wiktor at metacode.biz (Wiktor Kwapisiewicz)
Date: Thu, 26 May 2022 11:26:06 +0200
Subject: [Pcsclite-muscle] Support for file-descriptor based devices in
 pcsclite
In-Reply-To: <CAGstE8AD6Z0gSsm6kmWbjW_cgVt90+01NxdMxJ3V2MS5KH0Ppg@mail.gmail.com>
References: <ff932410-400c-42c1-615a-3a128898554f@metacode.biz>
 <CAGstE8AD6Z0gSsm6kmWbjW_cgVt90+01NxdMxJ3V2MS5KH0Ppg@mail.gmail.com>
Message-ID: <2bde2748-aab1-5abe-ed58-284f3dda8daf@metacode.biz>

Hi,

On 26.05.2022 11:13, Ludovic Rousseau wrote:
> Sorry for the delay. Your email was in my spam folder (gmail).

No worries, great to hear back from you!

>> I did compile several small examples using libusb and
>> libusb_wrap_sys_device and they worked fine with my tokens (Yubikeys).
>> Now my question is whether support for
>> LIBUSB_OPTION_WEAK_AUTHORITY/libusb_wrap_sys_device is something that
>> could be considered for inclusion in pcsclite or is this out of scope?
> 
> Yes, I could consider something like that.
> 
> In fact I already have 2 issues opened for pcsc-lite and CCID with this idea.
> "Open the device in pcscd and give the file descriptor to the driver"
> https://salsa.debian.org/rousseau/PCSC/-/issues/20
> 
> "Use libusb_wrap_sys_device() and avoid rescanning the USB bus"
> https://salsa.debian.org/rousseau/CCID/-/issues/11

Oh, I must've missed that issue tracker. I'll read them thoroughly.

> This scheme could also be used on a "normal" computer and not only for Android.

That'd be great for development too.

> I am waiting for your first patches.
> Good idea.

Thanks for the ack! It may take some time as I'm not familiar with the 
codebase but I hope I can ping this mailing list in case I have 
questions/problems.

> What smart card reader do you plan to use with your Android phone?

To be honest I started with my Yubikey 5C (as you know it's a smartcard 
reader+smartcard all in one package) as it fits nicely into phone's 
USB-C slot but I also have some other tokens and a physical Omnikey 3121 
reader. It all worked well on my Linux PC so I don't expect any 
surprises here. By the way thanks for a fantastic and robust piece of 
software!

For others scanning the mailing list and for cross-linking I've created 
the issue:
https://github.com/LudovicRousseau/PCSC/issues/130

Thanks for your time!

Kind regards,
Wiktor


