Support multiple versions of the internal protocol: fix Flatpak issues
The server (pcscd) end the client (libpcsclite.so.1) communicate over a socket using an internal protocol. The protocol version major.minor is defined in https://salsa.debian.org/rousseau/PCSC/-/blob/master/src/winscard_msg.h#L49 If the server is contacted by a client that does not use the correct protocol the communication is aborted. ``` $ journalctl --unit=pcscd [...] févr. 11 18:55:07 debian pcscd[3715]: 00000006 winscard_svc.c:361:ContextThread() Received command: CMD_VERSION from client 8 févr. 11 18:55:07 debian pcscd[3715]: 00000004 winscard_svc.c:373:ContextThread() Client is protocol version 4:3 févr. 11 18:55:07 debian pcscd[3715]: 00000001 winscard_svc.c:382:ContextThread() Communication protocol mismatch! févr. 11 18:55:07 debian pcscd[3715]: 00000002 winscard_svc.c:384:ContextThread() Client protocol is 4:3 févr. 11 18:55:07 debian pcscd[3715]: 00000001 winscard_svc.c:386:ContextThread() Server protocol is 4:4 févr. 11 18:55:07 debian pcscd[3715]: 00000002 winscard_svc.c:396:ContextThread() CMD_VERSION rv=0x8010001E for client 8 ``` This problem happens when pcscd is coming from a GNU/Linux distribution and libpcsclite.so.1 comes from somewhere else, like an application packaged using Flatpak. The problem has been reported in 2022 for Fedora in [Support of more than 16 smartcard readers breaks flatpak interoperability](https://bugzilla.redhat.com/show_bug.cgi?id=2054826) and in 2020 for Red Hat Enterprise Linux 8 [flatpak smart card support socket=pcsc for smart cards doesn't seem to work on RHEL 8.3](https://bugzilla.redhat.com/show_bug.cgi?id=1906652). And also in other places like [flatpak](https://github.com/flatpak/flatpak/issues). See my blog article [Accessing smart cards from inside a flatpak sandbox](https://ludovicrousseau.blogspot.com/2022/02/accessing-smart-cards-from-inside.html) for more details It should be possible to update pcsc-lite so that the server can accept older protocol clients, or that the client accept/adapt to older protocol server (maybe the more common request related to Flatpak).
issue