Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package pcsc-lite for openSUSE:Factory 
checked in at 2021-12-08 22:08:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/pcsc-lite (Old)
 and      /work/SRC/openSUSE:Factory/.pcsc-lite.new.31177 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "pcsc-lite"

Wed Dec  8 22:08:23 2021 rev:92 rq:935782 version:1.9.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/pcsc-lite/pcsc-lite.changes      2021-12-02 
02:19:42.785767423 +0100
+++ /work/SRC/openSUSE:Factory/.pcsc-lite.new.31177/pcsc-lite.changes   
2021-12-08 22:08:29.506849516 +0100
@@ -1,0 +2,10 @@
+Sat Dec  4 15:57:27 UTC 2021 - Axel Braun <[email protected]>
+
+- version 1.9.5
+  * pcscd: autoexit even if no client connects
+  * Fix variable substitution in systemd units
+  * fix potential race conditions with powerState handling
+  * Add and use tag TAG_IFD_DEVICE_REMOVED
+  * UnitaryTests: port code to Python 3
+
+-------------------------------------------------------------------

Old:
----
  pcsc-lite-1.9.4.tar.bz2
  pcsc-lite-1.9.4.tar.bz2.asc

New:
----
  pcsc-lite-1.9.5.tar.bz2
  pcsc-lite-1.9.5.tar.bz2.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ pcsc-lite.spec ++++++
--- /var/tmp/diff_new_pack.lIBtqn/_old  2021-12-08 22:08:30.170849828 +0100
+++ /var/tmp/diff_new_pack.lIBtqn/_new  2021-12-08 22:08:30.174849830 +0100
@@ -26,7 +26,7 @@
 %define PKG_USER       scard
 %define PKG_GROUP      scard
 Name:           pcsc-lite
-Version:        1.9.4
+Version:        1.9.5
 Release:        0
 Summary:        PC/SC Smart Cards Library
 License:        BSD-3-Clause AND GPL-3.0-or-later
@@ -46,8 +46,8 @@
 BuildRequires:  libtool
 BuildRequires:  pkgconfig
 BuildRequires:  readline-devel
-BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  sysuser-tools
+BuildRequires:  pkgconfig(libsystemd)
 Requires:       libpcsclite1 = %{version}
 Requires(post): %fillup_prereq
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ pcsc-lite-1.9.4.tar.bz2 -> pcsc-lite-1.9.5.tar.bz2 ++++++
++++ 1840 lines of diff (skipped)
++++    retrying with extended exclude list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/ChangeLog new/pcsc-lite-1.9.5/ChangeLog
--- old/pcsc-lite-1.9.4/ChangeLog       2021-10-01 18:00:00.000000000 +0200
+++ new/pcsc-lite-1.9.5/ChangeLog       2021-12-04 13:29:25.000000000 +0100
@@ -1,3 +1,11 @@
+1.9.5: Ludovic Rousseau
+4 December 2021
+- pcscd: autoexit even if no client connects
+- Fix variable substitution in systemd units
+- fix potential race conditions with powerState handling
+- Add and use tag TAG_IFD_DEVICE_REMOVED
+- UnitaryTests: port code to Python 3
+
 1.9.4: Ludovic Rousseau
 1 October 2021
 - fix a memory leak when libusb is used for hotplug (i.e. non-Linux
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/ChangeLog.git new/pcsc-lite-1.9.5/ChangeLog.git
--- old/pcsc-lite-1.9.4/ChangeLog.git   2021-10-01 18:01:27.000000000 +0200
+++ new/pcsc-lite-1.9.5/ChangeLog.git   2021-12-04 13:30:12.000000000 +0100
@@ -1,4 +1,503 @@
-commit baa02edd1fb47c18b6bb7dfe79b2b38390271ce6 (HEAD -> master, zotac/master)
+commit d92b5d4fad5dea95ce8d12fac07fe1eec2150ad1 (HEAD -> master)
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Dec 4 13:16:36 2021 +0100
+
+    Release 1.9.5
+    
+    Signed-off-by: Ludovic Rousseau <[email protected]>
+
+ ChangeLog    | 8 ++++++++
+ configure.ac | 2 +-
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+commit e098afc1bfe46acc74102a5e8d2b2cd14c785445
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Dec 4 13:26:26 2021 +0100
+
+    etc/: remove systemd unit files on clean
+    
+    Fix 'make distcheck'
+    ERROR: files left in build directory after distclean:
+    ./etc/pcscd.socket
+    ./etc/pcscd.service
+    make[1]: *** [Makefile:732 : distcleancheck] Erreur 1
+
+ etc/Makefile.am | 2 ++
+ 1 file changed, 2 insertions(+)
+
+commit 2f970328ec14b20fdef01e3816df6c88d00e3a90
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Dec 4 13:23:53 2021 +0100
+
+    etc/: add pcscd.{service,socket}.in in archive
+    
+    We must distribute the *.in files
+
+ etc/Makefile.am | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+commit 4b39499ac201116a90dee5151dcc7b5af6ac153d (origin/master, origin/HEAD, 
github/master)
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Dec 4 12:46:18 2021 +0100
+
+    Improve handling of files etc/pcscd.{service,socket}.in
+    
+    Use the same code template from 
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Installation-Directory-Variables.html#index-sysconfdir-1
+    
+    The substitution now also works if ./configure is called again with a
+    different --prefix= value.
+    
+    Thanks to Kirill Elagin for the initial patch
+    " [Pcsclite-muscle] Incorrect use of Autoconf to expand variables in
+    plaintext files "
+    
http://lists.infradead.org/pipermail/pcsclite-muscle/2021-December/001215.html
+    
+    Hello,
+    
+    First, here is a concrete instance of this issue. In pcsclite 1.9.2
+    `EnvironmentFile=` was added to the `etc/pcscd.service.in` file. If
+    you look at a machine that has this (or newer) version installed, you
+    will find in `/etc/systemd/system/pcscd.service` this line:
+    
+    ```
+    EnvironmentFile=-${prefix}/etc/default/pcscd
+    ```
+    
+    It results in the following error reported to the system journal:
+    
+    ```
+    systemd[1]: /etc/systemd/system/pcscd.service:9: EnvironmentFile= path
+    is not absolute, ignoring: ${prefix}/etc/default/pcscd
+    ```
+    
+    The root cause is that `AC_CONFIG_FILES` is used, arguably somewhat
+    incorrectly, to replace all kinds of variables in all kinds of files,
+    while it is meant to only list makefiles. Quite often, this is not a
+    problem, since those variables just get replaced by correct values and
+    that???s it, however some variables do not get expanded fully, for
+    example, the @sysconfdir@ variable used in `pcscd.service.in` is
+    replaced with literal `${prefix}/etc` by default as can be seen above.
+    
+    As [Autoconf 
documentation](https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Installation-Directory-Variables.html#Installation-Directory-Variables)
+    explains, this is done intentionally ??? literal `${prefix}` is used as
+    part of the replacement value since @sysconfdir@ is supposed to be
+    used only in makefiles where it will be processed by Make. The
+    documentation explicitly calls out this practice:
+    
+    ???A corollary is that you should not use these variables except in 
makefiles.???
+    
+    ???Similarly, you should not rely on AC_CONFIG_FILES to replace bindir
+    and friends in your shell scripts and other files.???
+    
+    Then it goes on to give an example of how a full replacement can be
+    achieved with the help of Make and sed, however I am not exactly sure
+    if this is a standard practice or if there is a better solution these
+    days.
+    
+    In addition to that, pcsc-lite (ab)uses `AC_CONFIG_FILES` to replace
+    variables in some other files too, however this does not cause
+    problems since, as far as I can tell, all of those variables are of
+    the kind that gets expanded fully ??? with one notable exception: the
+    variables used in `src/libpcsclite.pc.in` are also not being expanded
+    fully, so they remain in the generated file, however, luckily, .pc
+    files allow references to other variables defined in the same file and
+    due to a convenient coincidence the names of the variables used by
+    `./configure` and defined in the `libpcsclite.pc` match. I don???t know,
+    I mean, this still sounds a little fragile to me and I think it would
+    be better to switch to some more robust solution.
+    
+    Cheers,
+    Kirill
+
+ etc/Makefile.am | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+commit 88ec131029ba9648a63ca072004e90414d10647e
+Author: Kirill Elagin <[email protected]>
+Date:   Fri Dec 3 22:55:10 2021 -0500
+
+    Fix variable substitution in systemd units
+    
+    Before this change, Autoconf was used to subsitute variables, including
+    @sysconfdir@, in systemd unit files. This is not how Autoconf should be
+    used and had an unintended negative consequence: the @sysconfdir@
+    variable was not fully expanded, so literal `${prefix}/etc` was ending up
+    in the pcscd.service file, where it was invalid.
+    
+    Use sed to perform the subsitution from within the makefile where the
+    variables get expanded fully. This seems to be the standard approach
+    recommended by Autoconf documentation and used in various projects.
+    
+    Also, remove the `SCRIPT_IN_FILES` variable from the makefile, which was
+    not used and seems to be a copy-paste from some other project.
+
+ configure.ac    |  2 --
+ etc/Makefile.am | 12 ++++++++----
+ 2 files changed, 8 insertions(+), 6 deletions(-)
+
+commit e1b1590c7f32e0353404967f457643d122367772
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 27 16:32:31 2021 +0100
+
+    SCardDisconnect: Use RFGetPowerState
+    
+    The fix in 0cf804f99c588e7abc5cd42f42b9582df5e8fb17 was not complete.
+
+ src/winscard.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 0cf804f99c588e7abc5cd42f42b9582df5e8fb17
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 27 15:28:10 2021 +0100
+
+    Use RFGetPowerState & RFSetPowerState
+    
+    This will help fix potential race conditions.
+    
+    I was not able to generate a problem using ThreadSanitizer but that is
+    not a proof that the code is correct
+    https://clang.llvm.org/docs/ThreadSanitizer.html
+    
+    Thanks to andrei-datcu for the patch
+    "No data races in EHStatusHandlerThread #112"
+    https://github.com/LudovicRousseau/PCSC/pull/112
+
+ src/eventhandler.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+commit c6aba284be54b5d166f638511f916ad3f8f2f897
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 27 15:16:02 2021 +0100
+
+    SCardReconnect: use RFSetPowerState() and factorize code
+
+ src/winscard.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+commit 46ded0cf6afb0030cd83dae6cf071a48daee6a0f
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 27 15:05:16 2021 +0100
+
+    Add RFGetPowerState() & RFSetPowerState() functions
+    
+    These 2 functions get & set the card power state and guard the operation
+    between lock/unlock of the powerState_lock mutex.
+    
+    This will help fix potential race conditions
+    
+    Thanks to andrei-datcu for the patch
+    "No data races in EHStatusHandlerThread #112"
+    https://github.com/LudovicRousseau/PCSC/pull/112
+
+ src/readerfactory.c | 15 +++++++++++++++
+ src/readerfactory.h |  2 ++
+ 2 files changed, 17 insertions(+)
+
+commit 9b6b667260228b797ac5af5479bdf7a3045ae389
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 13 18:18:29 2021 +0100
+
+    Fix typo in comment
+
+ src/pcscdaemon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 6f55e47728bbe96100aee0cb4d405d1d32dbf14c
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 13 18:13:15 2021 +0100
+
+    pcscdaemon: autoexit even if no client connects
+    
+    pcscd will now auto exit even if no PC/SC client has connected.
+    The idea is to auto exit if pcscd is restarted after an upgrade or a new
+    driver installation. In that case pcscd is NOT strated by a new client
+    so the alarm is not set the client disconnect.
+    
+    If you use something like "service pcscd restart" to restart pcscd then
+    it will exit after 60 seconds (if no client uses it).
+
+ src/pcscdaemon.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+commit 7d3379ed4ed51b3fb7f5237bba6c26e2705995fa
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 13 17:58:07 2021 +0100
+
+    Fix typo in comment
+
+ src/pcscdaemon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit acd76b194b16776dcd3bb447ccfbbd4e0ce703c8
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sat Nov 13 17:57:19 2021 +0100
+
+    Fix typo in comment
+
+ src/pcscdaemon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit d81489a7b2f34d368e99b687466b01ad5939b50a
+Author: Ludovic Rousseau <[email protected]>
+Date:   Fri Nov 12 17:04:40 2021 +0100
+
+    c.sh: /lib is now a symbolic link to /usr/lib on GNU/Linux
+    
+    See 
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/
+
+ c.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 76d2f91b88857dc955c888da965ccda4145d236e
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 21:17:04 2021 +0100
+
+    transmit_card_removed: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'sleep' is not used.
+
+ UnitaryTests/transmit_card_removed.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 21792d6d83e1f1d62f8554aa715265909d63ce53
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:40:11 2021 +0100
+
+    SCardGetStatusChange: port to Python 3
+
+ .../SCardGetStatusChange/SCardGetStatusChange.py   | 32 +++++++++++-----------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+commit 5d253fb86a5f096e9885d06b2a1de3ce13fe9ef2
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:38:35 2021 +0100
+
+    SCardGetStatusChange: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'sys' is not used.
+
+ UnitaryTests/SCardGetStatusChange/SCardGetStatusChange.py | 1 -
+ 1 file changed, 1 deletion(-)
+
+commit 1dd791ea98c38636208c4cc4222f1025fc9f92ac
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:37:54 2021 +0100
+
+    SCardGetStatusChange_PnP: port to Python 3
+
+ .../SCardGetStatusChange_PnP.py                    | 36 +++++++++++-----------
+ 1 file changed, 18 insertions(+), 18 deletions(-)
+
+commit 9be58fdca0cf6e173ebb68717d690ca05a983e01
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:09:34 2021 +0100
+
+    SCardGetStatusChange_PnP: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'sys' is not used.
+
+ UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP.py | 2 --
+ 1 file changed, 2 deletions(-)
+
+commit 68cc8fb154d9c515b07b0ab0b3766d6a34b28211
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:08:33 2021 +0100
+
+    SCardGetStatusChange_loop: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'sys' is not used.
+
+ UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py | 1 -
+ 1 file changed, 1 deletion(-)
+
+commit 650bfac39f43e5608618919a8f03b49b6da4e9a9
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:05:43 2021 +0100
+
+    ThreadSafeConnect: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'SCardGetErrorMessage' is not used.
+
+ UnitaryTests/ThreadSafeConnect.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 390d49b45207614c5682a44f452fae89ba4c56ea
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:03:48 2021 +0100
+
+    SCardBeginTransaction_Reset: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'sleep' is not used.
+
+ UnitaryTests/SCardBeginTransaction_Reset.py | 1 -
+ 1 file changed, 1 deletion(-)
+
+commit 2dd7849c489a349665ac4f66b6b98e3426fb6cdc
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 19:02:40 2021 +0100
+
+    FEATURE_CCID_ESC_COMMAND_Gemalto_features: remove unused import
+    
+    Fix lgtm.com recommendation:
+    Import of 'PCSCv2_PART10_PROPERTY_wIdProduct' is not used.
+    Import of 'PCSCv2_PART10_PROPERTY_wIdVendor' is not used.
+
+ UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py | 1 -
+ 1 file changed, 1 deletion(-)
+
+commit b0ba6757ff14d716bbff3eed1f08b674f456857e
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Nov 7 18:58:33 2021 +0100
+
+    control_switch_interface: catch a specific exception
+    
+    Fix lgtm.com recommendation:
+    Except block directly handles BaseException.
+
+ UnitaryTests/control_switch_interface.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+commit abaab9636c4460fe3c82ac58881fee9e1a54b003
+Author: Ludovic Rousseau <[email protected]>
+Date:   Wed Nov 3 19:05:48 2021 +0100
+
+    SCardGetStatusChange_loop: handle KeyboardInterrupt
+    
+    Catch the KeyboardInterrupt exception and cleanly disconnect and exit
+
+ .../SCardGetStatusChange_loop.py                   | 37 +++++++++++-----------
+ 1 file changed, 19 insertions(+), 18 deletions(-)
+
+commit 9519ad6c89b260d6d4b0a7303da3186e7fd94566
+Author: Ludovic Rousseau <[email protected]>
+Date:   Wed Nov 3 19:04:20 2021 +0100
+
+    SCardGetStatusChange_loop: make the code more explicit
+    
+    Use True instead of 1
+
+ UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 2c613018f3d60c497593d8bc4a66d78e25990e47
+Author: Ludovic Rousseau <[email protected]>
+Date:   Wed Nov 3 18:22:42 2021 +0100
+
+    SCardGetStatusChange_loop: port to Python 3
+
+ .../SCardGetStatusChange_loop.py                   | 36 +++++++++++-----------
+ 1 file changed, 18 insertions(+), 18 deletions(-)
+
+commit d47c15727c37e1b5e63a0d5b29394b41f84d791d
+Author: Ludovic Rousseau <[email protected]>
+Date:   Wed Nov 3 18:16:10 2021 +0100
+
+    transmit_loop: handle KeyboardInterrupt
+    
+    Catch the KeyboardInterrupt exception and cleanly disconnect and exit
+
+ UnitaryTests/transmit_loop.py | 17 +++++++++--------
+ 1 file changed, 9 insertions(+), 8 deletions(-)
+
+commit 61cd3872bb8aba49ffa357722e753caec80db117
+Author: Ludovic Rousseau <[email protected]>
+Date:   Wed Nov 3 18:14:16 2021 +0100
+
+    transmit_loop: make the code more explicit
+    
+    Use True instead of 1
+
+ UnitaryTests/transmit_loop.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 91da0d5dd94b08fd5840c5c04e5a8b3b9e3b019a
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Oct 10 17:11:23 2021 +0200
+
+    Update README_INTERNALS.txt
+    
+    Remove now incorrect text.
+
+ src/README_INTERNALS.txt | 35 -----------------------------------
+ 1 file changed, 35 deletions(-)
+
+commit 6f8f170db3c88c59a5ddb5ae5319b921a901a6aa
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Oct 10 17:05:13 2021 +0200
+
+    Remove unmaintained hotplug_linux.c
+    
+    This hotplug mechanism should not be used anymore.
+    For example the directory "/proc/bus/usb" used to scan the USB bus does
+    not exist anymore on my Debian Bullseye system.
+
+ src/Makefile.am          |   1 -
+ src/README_INTERNALS.txt |   1 -
+ src/hotplug_linux.c      | 472 -----------------------------------------------
+ 3 files changed, 474 deletions(-)
+
+commit ed97272cf2d5f5e45e4af9b1bd86d529cadabbf1
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Oct 10 16:57:47 2021 +0200
+
+    Use REMOVE_READER_FLAG_REMOVED for the other hotplug variants
+    
+    - hotplug_libusb.c is used on non-Linux systems like *BSD
+    - hotplug_macosx.c is for macOS only but should not be used
+
+ src/hotplug_libusb.c | 2 +-
+ src/hotplug_macosx.c | 3 ++-
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+commit c5a47f7e713de9c70deb7382de13c91966684eed
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Oct 10 16:45:08 2021 +0200
+
+    Use TAG_IFD_DEVICE_REMOVED when the reader is removed
+    
+    When a USB reader is removed then use the new IFD Handler tag
+    TAG_IFD_DEVICE_REMOVED to signal the fact to the driver.
+    
+    RFRemoveReader() has a new "flags" parameter.
+    By default the value REMOVE_READER_NO_FLAG is used.
+    
+    When the libudev hotplug mechanism detects that a USB device has been
+    removed then RFRemoveReader() is called with REMOVE_READER_FLAG_REMOVED.
+    RFRemoveReader() will then use TAG_IFD_DEVICE_REMOVED to tell the
+    driver that the device has been removed and that no communication with
+    the device should occur.
+
+ src/hotplug_libudev.c |  2 +-
+ src/readerfactory.c   | 35 +++++++++++++++++++++++++++--------
+ src/readerfactory.h   |  5 ++++-
+ 3 files changed, 32 insertions(+), 10 deletions(-)
+
+commit ba516815edbd838fa8d0dc45691c8fec0d8c4fc3
+Author: Ludovic Rousseau <[email protected]>
+Date:   Sun Oct 10 16:37:16 2021 +0200
+
+    Add tag TAG_IFD_DEVICE_REMOVED
+    
+    This tag is used to tell the driver that the reader has been detected
+    removed. So the driver do not try to talk to the device since that will
+    fails.
+    
+    The idea is to avoid error messages in the logs like:
+    00000000 [140611055253248] ccid_usb.c:871:WriteUSB() write failed (1/12): 
-4 LIBUSB_ERROR_NO_DEVICE
+    00000692 [140611271165696] ccid_usb.c:871:WriteUSB() write failed (1/12): 
-4 LIBUSB_ERROR_NO_DEVICE
+    when the device is removed and pcscd tells the driver to close the
+    connection.
+
+ src/PCSC/ifdhandler.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+commit baa02edd1fb47c18b6bb7dfe79b2b38390271ce6 (tag: 1.9.4)
 Author: Ludovic Rousseau <[email protected]>
 Date:   Fri Oct 1 17:40:31 2021 +0200
 
@@ -38,7 +537,7 @@
  configure.ac | 2 --
  1 file changed, 2 deletions(-)
 
-commit a79e1d8409befc6ae0e6d77c0ff47a24f1bb31c3 (origin/master, origin/HEAD, 
github/master)
+commit a79e1d8409befc6ae0e6d77c0ff47a24f1bb31c3
 Author: Ludovic Rousseau <[email protected]>
 Date:   Fri Oct 1 16:51:49 2021 +0200
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/configure.ac new/pcsc-lite-1.9.5/configure.ac
--- old/pcsc-lite-1.9.4/configure.ac    2021-10-01 18:00:00.000000000 +0200
+++ new/pcsc-lite-1.9.5/configure.ac    2021-12-04 13:29:25.000000000 +0100
@@ -3,7 +3,7 @@
 
 AC_PREREQ([2.69])
 
-AC_INIT([pcsc-lite],[1.9.4])
+AC_INIT([pcsc-lite],[1.9.5])
 AC_CONFIG_SRCDIR(src/pcscdaemon.c)
 AM_INIT_AUTOMAKE(1.8 dist-bzip2 no-dist-gzip)
 AC_CONFIG_HEADERS([config.h])
@@ -461,8 +461,6 @@
 doc/reader.conf.5
 doc/example/Makefile
 etc/Makefile
-etc/pcscd.service
-etc/pcscd.socket
 src/Makefile
 src/libpcsclite.pc
 src/pcscd.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/etc/Makefile.am new/pcsc-lite-1.9.5/etc/Makefile.am
--- old/pcsc-lite-1.9.4/etc/Makefile.am 2020-08-05 13:01:28.000000000 +0200
+++ new/pcsc-lite-1.9.5/etc/Makefile.am 2021-12-04 13:28:28.000000000 +0100
@@ -1,9 +1,29 @@
 if HAVE_SYSTEMD
-SCRIPT_IN_FILES = \
+EXTRA_DIST = \
        pcscd.service.in \
        pcscd.socket.in
 
 systemdsystemunit_DATA = \
        pcscd.service \
        pcscd.socket
+
+CLEANFILES = $(systemdsystemunit_DATA)
+
+edit = sed \
+       -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
+       -e 's|@sbindir_exp[@]|$(sbindir_exp)|g' \
+       -e 's|@ipcdir[@]|$(ipcdir)|g'
+
+$(systemdsystemunit_DATA): Makefile
+       rm -f $@ [email protected]
+       srcdir=''; \
+         test -f ./[email protected] || srcdir=$(srcdir)/; \
+         $(edit) $${srcdir}[email protected] >[email protected]
+       chmod +x [email protected]
+       chmod a-w [email protected]
+       mv [email protected] $@
+
+pcscd.service: $(srcdir)/pcscd.service.in
+pcscd.socket: $(srcdir)/pcscd.socket.in
+
 endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/Makefile.am new/pcsc-lite-1.9.5/src/Makefile.am
--- old/pcsc-lite-1.9.4/src/Makefile.am 2020-08-05 13:01:32.000000000 +0200
+++ new/pcsc-lite-1.9.5/src/Makefile.am 2021-10-15 21:34:10.000000000 +0200
@@ -16,7 +16,6 @@
 USB_CONFIG = tokenparser.l \
        hotplug_libudev.c \
        hotplug_libusb.c \
-       hotplug_linux.c \
        hotplug_macosx.c
 endif
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/PCSC/ifdhandler.h 
new/pcsc-lite-1.9.5/src/PCSC/ifdhandler.h
--- old/pcsc-lite-1.9.4/src/PCSC/ifdhandler.h   2020-08-05 13:01:32.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/PCSC/ifdhandler.h   2021-10-15 21:34:10.000000000 
+0200
@@ -328,6 +328,7 @@
 #define TAG_IFD_POLLING_THREAD_KILLABLE 0x0FB1 /**< the polling thread can be 
killed */
 #define TAG_IFD_STOP_POLLING_THREAD     0x0FB2 /**< method used to stop the 
polling thread (instead of just pthread_kill()) */
 #define TAG_IFD_POLLING_THREAD_WITH_TIMEOUT 0x0FB3     /**< driver uses a 
polling thread with a timeout parameter */
+#define TAG_IFD_DEVICE_REMOVED          0x0FB4 /**< signals the reader has 
been removed*/
 
        /*
         * IFD Handler version number enummerations
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/PCSC/pcsclite.h new/pcsc-lite-1.9.5/src/PCSC/pcsclite.h
--- old/pcsc-lite-1.9.4/src/PCSC/pcsclite.h     2021-10-01 18:01:18.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/PCSC/pcsclite.h     2021-12-04 13:29:57.000000000 
+0100
@@ -279,7 +279,7 @@
 #define INFINITE                       0xFFFFFFFF      /**< Infinite timeout */
 #endif
 
-#define PCSCLITE_VERSION_NUMBER                "1.9.4" /**< Current version */
+#define PCSCLITE_VERSION_NUMBER                "1.9.5" /**< Current version */
 /** Maximum readers context (a slot is count as a reader) */
 #define PCSCLITE_MAX_READERS_CONTEXTS                  16
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/README_INTERNALS.txt 
new/pcsc-lite-1.9.5/src/README_INTERNALS.txt
--- old/pcsc-lite-1.9.4/src/README_INTERNALS.txt        2020-08-05 
13:01:32.000000000 +0200
+++ new/pcsc-lite-1.9.5/src/README_INTERNALS.txt        2021-10-15 
21:34:10.000000000 +0200
@@ -26,16 +26,12 @@
  eventhandler.c
  hotplug_generic.c
  hotplug_libusb.c
- hotplug_linux.c (this file is OS dependant)
  hotplug_macosx.c (this file is OS dependant)
  ifdwrapper.c
  pcscdaemon.c
- powermgt_generic.c
- powermgt_macosx.c (this file is OS dependant)
  prothandler.c
  readerfactory.c
  sys_unix.c (this file is OS dependant)
- thread_unix.c (this file is OS dependant)
  tokenparser.l
  winscard.c
  winscard_msg.c
@@ -49,7 +45,6 @@
  dyn_unix.c
  error.c
  sys_unix.c
- thread_unix.c
  winscard_clnt.c or winscard_scf.c
  winscard_msg.c
 
@@ -187,37 +182,6 @@
  => does not work
 
 
-Memory structures
------------------
-
-pcscd side:
-
-- pcscd open/creates a shared memory segment (EHInitializeEventStructures()
-  in eventhandler.c)
-- static PREADER_STATE readerStates[PCSCLITE_MAX_READERS_CONTEXTS]; is
-  an array of pointers on READER_STATE. Each entry readerStates[i]
-  points to a memory shared segment. It contains the state of each
-  readers.
-
-- reader contexts are also created and maintained
-- static PREADER_CONTEXT sReadersContexts[PCSCLITE_MAX_READERS_CONTEXTS];
-  is an array of pointers on READER_CONTEXT
-- the structure is allocated by RFAllocateReaderSpace() in
-  readerfactory.c
-- each READER_CONTEXT contains a pointer to a READER_STATE for the
-  context
-
-
-libpcsclite side:
-
-- the library open the shared memory segment (SCardEstablishContextTH()
-  in winscard_clnt.c)
-- each entry readerStates[i] gets a reference to the memory segment of
-  the server.
-
-The memory is READ ONLY on the library side.
-
-
 Inter-thread communication:
 ---------------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/eventhandler.c new/pcsc-lite-1.9.5/src/eventhandler.c
--- old/pcsc-lite-1.9.4/src/eventhandler.c      2020-08-08 17:53:19.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/eventhandler.c      2021-11-27 16:30:15.000000000 
+0100
@@ -285,7 +285,7 @@
                if (rv == IFD_SUCCESS)
                {
                        readerState = SCARD_PRESENT | SCARD_POWERED | 
SCARD_NEGOTIABLE;
-                       rContext->powerState = POWER_STATE_POWERED;
+                       RFSetPowerState(rContext, POWER_STATE_POWERED);
                        Log1(PCSC_LOG_DEBUG, "powerState: POWER_STATE_POWERED");
 
                        if (rContext->readerState->cardAtrLength > 0)
@@ -300,7 +300,7 @@
                else
                {
                        readerState = SCARD_PRESENT | SCARD_SWALLOWED;
-                       rContext->powerState = POWER_STATE_UNPOWERED;
+                       RFSetPowerState(rContext, POWER_STATE_UNPOWERED);
                        Log1(PCSC_LOG_DEBUG, "powerState: 
POWER_STATE_UNPOWERED");
                        Log3(PCSC_LOG_ERROR, "Error powering up card: %ld 
0x%04lX", rv, rv);
                }
@@ -383,7 +383,7 @@
                                rContext->readerState->cardAtrLength = 0;
                                rContext->readerState->cardProtocol = 
SCARD_PROTOCOL_UNDEFINED;
                                rContext->readerState->readerState = 
SCARD_PRESENT;
-                               rContext->powerState = POWER_STATE_UNPOWERED;
+                               RFSetPowerState(rContext, 
POWER_STATE_UNPOWERED);
                                Log1(PCSC_LOG_DEBUG, "powerState: 
POWER_STATE_UNPOWERED");
                                rv = IFD_SUCCESS;
                                Log1(PCSC_LOG_INFO, "Skip card power on");
@@ -402,13 +402,13 @@
                                if (rv == IFD_SUCCESS)
                                {
                                        rContext->readerState->readerState = 
SCARD_PRESENT | SCARD_POWERED | SCARD_NEGOTIABLE;
-                                       rContext->powerState = 
POWER_STATE_POWERED;
+                                       RFSetPowerState(rContext, 
POWER_STATE_POWERED);
                                        Log1(PCSC_LOG_DEBUG, "powerState: 
POWER_STATE_POWERED");
                                }
                                else
                                {
                                        rContext->readerState->readerState = 
SCARD_PRESENT | SCARD_SWALLOWED;
-                                       rContext->powerState = 
POWER_STATE_UNPOWERED;
+                                       RFSetPowerState(rContext, 
POWER_STATE_UNPOWERED);
                                        Log1(PCSC_LOG_DEBUG, "powerState: 
POWER_STATE_UNPOWERED");
                                        rContext->readerState->cardAtrLength = 
0;
                                }
@@ -456,7 +456,7 @@
                        int timeout;
 
 #ifndef DISABLE_ON_DEMAND_POWER_ON
-                       if (POWER_STATE_POWERED == rContext->powerState)
+                       if (POWER_STATE_POWERED == RFGetPowerState(rContext))
                                /* The card is powered but not yet used */
                                timeout = PCSCLITE_POWER_OFF_GRACE_PERIOD;
                        else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/hotplug_libudev.c 
new/pcsc-lite-1.9.5/src/hotplug_libudev.c
--- old/pcsc-lite-1.9.4/src/hotplug_libudev.c   2021-02-23 13:50:27.000000000 
+0100
+++ new/pcsc-lite-1.9.5/src/hotplug_libudev.c   2021-10-15 21:34:10.000000000 
+0200
@@ -367,7 +367,7 @@
                        Log4(PCSC_LOG_INFO, "Removing USB device[%d]: %s at 
%s", i,
                                readerTracker[i].fullName, 
readerTracker[i].devpath);
 
-                       RFRemoveReader(readerTracker[i].fullName, 
PCSCLITE_HP_BASE_PORT + i);
+                       RFRemoveReader(readerTracker[i].fullName, 
PCSCLITE_HP_BASE_PORT + i, REMOVE_READER_FLAG_REMOVED);
 
                        free(readerTracker[i].devpath);
                        readerTracker[i].devpath = NULL;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/hotplug_libusb.c 
new/pcsc-lite-1.9.5/src/hotplug_libusb.c
--- old/pcsc-lite-1.9.4/src/hotplug_libusb.c    2021-10-01 16:51:37.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/hotplug_libusb.c    2021-10-15 21:34:10.000000000 
+0200
@@ -762,7 +762,7 @@
                readerTracker[reader_index].bus_device);
 
        RFRemoveReader(readerTracker[reader_index].fullName,
-               PCSCLITE_HP_BASE_PORT + reader_index);
+               PCSCLITE_HP_BASE_PORT + reader_index, 
REMOVE_READER_FLAG_REMOVED);
        free(readerTracker[reader_index].fullName);
        readerTracker[reader_index].status = READER_ABSENT;
        readerTracker[reader_index].bus_device[0] = '\0';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/hotplug_linux.c new/pcsc-lite-1.9.5/src/hotplug_linux.c
--- old/pcsc-lite-1.9.4/src/hotplug_linux.c     2020-08-05 13:11:19.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/hotplug_linux.c     1970-01-01 01:00:00.000000000 
+0100
@@ -1,472 +0,0 @@
-/*
- * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
- *
- * Copyright (C) 2001-2003
- *  David Corcoran <[email protected]>
- * Copyright (C) 2002-2011
- *  Ludovic Rousseau <[email protected]>
- *
- * The USB code was based partly on Johannes Erdfelt
- * libusb code found at libusb.sourceforge.net
- *
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * @brief This provides a search API for hot pluggble devices.
- */
-
-#include "config.h"
-#include <string.h>
-
-#if defined(__linux__) && !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUDEV)
-#include <sys/types.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <time.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include "misc.h"
-#include "pcsclite.h"
-#include "pcscd.h"
-#include "debuglog.h"
-#include "parser.h"
-#include "readerfactory.h"
-#include "winscard_msg.h"
-#include "sys_generic.h"
-#include "hotplug.h"
-#include "utils.h"
-
-#undef DEBUG_HOTPLUG
-#define PCSCLITE_USB_PATH              "/proc/bus/usb"
-
-#define FALSE                  0
-#define TRUE                   1
-
-pthread_mutex_t usbNotifierMutex;
-
-struct usb_device_descriptor
-{
-       u_int8_t bLength;
-       u_int8_t bDescriptorType;
-       u_int16_t bcdUSB;
-       u_int8_t bDeviceClass;
-       u_int8_t bDeviceSubClass;
-       u_int8_t bDeviceProtocol;
-       u_int8_t bMaxPacketSize0;
-       u_int16_t idVendor;
-       u_int16_t idProduct;
-       u_int16_t bcdDevice;
-       u_int8_t iManufacturer;
-       u_int8_t iProduct;
-       u_int8_t iSerialNumber;
-       u_int8_t bNumConfigurations;
-}
-__attribute__ ((packed));
-
-static LONG HPAddHotPluggable(int, unsigned long);
-static LONG HPRemoveHotPluggable(int, unsigned long);
-static LONG HPReadBundleValues(void);
-static void HPEstablishUSBNotifications(void);
-
-static pthread_t usbNotifyThread;
-static int AraKiriHotPlug = FALSE;
-static int bundleSize = 0;
-
-/**
- * A list to keep track of 20 simultaneous readers
- */
-static struct _bundleTracker
-{
-       long  manuID;
-       long  productID;
-
-       struct _deviceNumber {
-               int  id;
-               char status;
-       } deviceNumber[PCSCLITE_MAX_READERS_CONTEXTS];
-
-       char *bundleName;
-       char *libraryPath;
-       char *readerName;
-}
-bundleTracker[PCSCLITE_MAX_READERS_CONTEXTS];
-
-static LONG HPReadBundleValues(void)
-{
-       LONG rv;
-       DIR *hpDir;
-       struct dirent *currFP = 0;
-       char fullPath[FILENAME_MAX];
-       char fullLibPath[FILENAME_MAX];
-       unsigned int listCount = 0;
-
-       hpDir = opendir(PCSCLITE_HP_DROPDIR);
-
-       if (hpDir == NULL)
-       {
-               Log1(PCSC_LOG_INFO,
-                       "Cannot open PC/SC drivers directory: " 
PCSCLITE_HP_DROPDIR);
-               Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd.");
-               return -1;
-       }
-
-#define GET_KEY(key, values) \
-       rv = LTPBundleFindValueWithKey(&plist, key, values); \
-       if (rv) \
-       { \
-               Log2(PCSC_LOG_ERROR, "Value/Key not defined for " key " in %s", 
\
-                       fullPath); \
-               continue; \
-       }
-
-       while ((currFP = readdir(hpDir)) != 0)
-       {
-               if (strstr(currFP->d_name, ".bundle") != 0)
-               {
-                       unsigned int alias;
-                       list_t plist, *values;
-                       list_t *manuIDs, *productIDs, *readerNames;
-                       char *libraryPath;
-
-                       /*
-                        * The bundle exists - let's form a full path name and 
get the
-                        * vendor and product ID's for this particular bundle
-                        */
-                       snprintf(fullPath, FILENAME_MAX, 
"%s/%s/Contents/Info.plist",
-                               PCSCLITE_HP_DROPDIR, currFP->d_name);
-                       fullPath[FILENAME_MAX - 1] = '\0';
-
-                       rv = bundleParse(fullPath, &plist);
-                       if (rv)
-                               continue;
-
-                       /* get CFBundleExecutable */
-                       GET_KEY(PCSCLITE_HP_LIBRKEY_NAME, &values)
-                       libraryPath = list_get_at(values, 0);
-                       (void)snprintf(fullLibPath, sizeof(fullLibPath),
-                               "%s/%s/Contents/%s/%s",
-                               PCSCLITE_HP_DROPDIR, currFP->d_name, PCSC_ARCH,
-                               libraryPath);
-                       fullLibPath[sizeof(fullLibPath) - 1] = '\0';
-
-                       GET_KEY(PCSCLITE_HP_CPCTKEY_NAME, &values)
-                       GET_KEY(PCSCLITE_HP_MANUKEY_NAME, &manuIDs)
-                       GET_KEY(PCSCLITE_HP_PRODKEY_NAME, &productIDs)
-                       GET_KEY(PCSCLITE_HP_NAMEKEY_NAME, &readerNames)
-
-                       /* while we find a nth ifdVendorID in Info.plist */
-                       for (alias=0; alias<list_size(manuIDs); alias++)
-                       {
-                               char *value;
-
-                               /* variables entries */
-                               value = list_get_at(manuIDs, alias);
-                               bundleTracker[listCount].manuID = strtol(value, 
NULL, 16);
-
-                               value = list_get_at(productIDs, alias);
-                               bundleTracker[listCount].productID = 
strtol(value, NULL, 16);
-
-                               bundleTracker[listCount].readerName = 
strdup(list_get_at(readerNames, alias));
-
-                               /* constant entries for a same driver */
-                               bundleTracker[listCount].bundleName = 
strdup(currFP->d_name);
-                               bundleTracker[listCount].libraryPath = 
strdup(fullLibPath);
-
-#ifdef DEBUG_HOTPLUG
-                               Log2(PCSC_LOG_INFO, "Found driver for: %s",
-                                       bundleTracker[listCount].readerName);
-#endif
-                               listCount++;
-
-                               if (listCount >= COUNT_OF(bundleTracker))
-                               {
-                                       Log2(PCSC_LOG_CRITICAL, "Too many 
readers declared. Maximum is %zd", COUNT_OF(bundleTracker));
-                                       goto end;
-                               }
-                       }
-                       bundleRelease(&plist);
-               }
-       }
-
-end:
-       bundleSize = listCount;
-
-       if (bundleSize == 0)
-       {
-               Log1(PCSC_LOG_INFO,
-                       "No bundle files in pcsc drivers directory: " 
PCSCLITE_HP_DROPDIR);
-               Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
-       }
-
-       closedir(hpDir);
-       return bundleSize;
-}
-
-static void HPEstablishUSBNotifications(void)
-{
-
-       int i, j, usbDeviceStatus;
-       DIR *dir, *dirB;
-       struct dirent *entry, *entryB;
-       int deviceNumber;
-       int suspectDeviceNumber;
-       char dirpath[FILENAME_MAX];
-       char filename[FILENAME_MAX * 2];
-       int fd, ret;
-       struct usb_device_descriptor usbDescriptor;
-
-       usbDeviceStatus = 0;
-       suspectDeviceNumber = 0;
-
-       while (1)
-       {
-               for (i = 0; i < bundleSize; i++)
-               {
-                       usbDeviceStatus     = 0;
-                       suspectDeviceNumber = 0;
-
-                       for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
-                               /* clear rollcall */
-                               bundleTracker[i].deviceNumber[j].status = 0;
-
-                       dir = NULL;
-                       dir = opendir(PCSCLITE_USB_PATH);
-                       if (dir == NULL)
-                       {
-                               Log1(PCSC_LOG_ERROR,
-                                       "Cannot open USB path directory: " 
PCSCLITE_USB_PATH);
-                               return;
-                       }
-
-                       entry = NULL;
-                       while ((entry = readdir(dir)) != 0)
-                       {
-
-                               /*
-                                * Skip anything starting with a
-                                */
-                               if (entry->d_name[0] == '.')
-                                       continue;
-                               if (!strchr("0123456789",
-                                               
entry->d_name[strlen(entry->d_name) - 1]))
-                               {
-                                       continue;
-                               }
-
-                               snprintf(dirpath, sizeof dirpath, "%s/%s",
-                                       PCSCLITE_USB_PATH, entry->d_name);
-
-                               dirB = opendir(dirpath);
-
-                               if (dirB == NULL)
-                               {
-                                       Log2(PCSC_LOG_ERROR,
-                                               "USB path seems to have 
disappeared %s", dirpath);
-                                       closedir(dir);
-                                       return;
-                               }
-
-                               while ((entryB = readdir(dirB)) != NULL)
-                               {
-                                       /*
-                                        * Skip anything starting with a
-                                        */
-                                       if (entryB->d_name[0] == '.')
-                                               continue;
-
-                                       /* Get the device number so we can 
distinguish
-                                          multiple readers */
-                                       snprintf(filename, sizeof filename, 
"%s/%s",
-                                               dirpath, entryB->d_name);
-                                       deviceNumber = atoi(entryB->d_name);
-
-                                       fd = open(filename, O_RDONLY);
-                                       if (fd < 0)
-                                               continue;
-
-                                       ret = read(fd, (void *) &usbDescriptor,
-                                               sizeof(usbDescriptor));
-
-                                       close(fd);
-
-                                       if (ret < 0)
-                                               continue;
-
-                                       /*
-                                        * Device is found and we don't know 
about it
-                                        */
-
-                                       if (usbDescriptor.idVendor == 
bundleTracker[i].manuID &&
-                                               usbDescriptor.idProduct == 
bundleTracker[i].productID &&
-                                               usbDescriptor.idVendor !=0 &&
-                                               usbDescriptor.idProduct != 0)
-                                       {
-                                               for (j=0; j < 
PCSCLITE_MAX_READERS_CONTEXTS; j++)
-                                               {
-                                                       if 
(bundleTracker[i].deviceNumber[j].id == deviceNumber &&
-                                                               
bundleTracker[i].deviceNumber[j].id != 0)
-                                                       {
-                                                               
bundleTracker[i].deviceNumber[j].status = 1; /* i'm here */
-                                                               break;
-                                                       }
-                                               }
-
-                                               if (j == 
PCSCLITE_MAX_READERS_CONTEXTS)
-                                               {
-                                                       usbDeviceStatus = 1;
-                                                       suspectDeviceNumber = 
deviceNumber;
-                                               }
-                                       }
-
-                               } /* End of while */
-
-                               closedir(dirB);
-
-                       } /* End of while */
-
-
-                       if (usbDeviceStatus == 1)
-                       {
-                               pthread_mutex_lock(&usbNotifierMutex);
-
-                               for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; 
j++)
-                               {
-                                       if (bundleTracker[i].deviceNumber[j].id 
== 0)
-                                               break;
-                               }
-
-                               if (j == PCSCLITE_MAX_READERS_CONTEXTS)
-                                       Log1(PCSC_LOG_ERROR,
-                                               "Too many identical readers 
plugged in");
-                               else
-                               {
-                                       HPAddHotPluggable(i, j+1);
-                                       bundleTracker[i].deviceNumber[j].id = 
suspectDeviceNumber;
-                               }
-
-                               pthread_mutex_unlock(&usbNotifierMutex);
-                       }
-                       else
-                               if (usbDeviceStatus == 0)
-                               {
-
-                                       for (j=0; j < 
PCSCLITE_MAX_READERS_CONTEXTS; j++)
-                                       {
-                                               if 
(bundleTracker[i].deviceNumber[j].id != 0 &&
-                                                       
bundleTracker[i].deviceNumber[j].status == 0)
-                                               {
-                                                       
pthread_mutex_lock(&usbNotifierMutex);
-                                                       HPRemoveHotPluggable(i, 
j+1);
-                                                       
bundleTracker[i].deviceNumber[j].id = 0;
-                                                       
pthread_mutex_unlock(&usbNotifierMutex);
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       /*
-                                        * Do nothing - no USB devices found
-                                        */
-                               }
-
-                       if (dir)
-                               closedir(dir);
-
-               }       /* End of for..loop */
-
-               SYS_Sleep(1);
-               if (AraKiriHotPlug)
-               {
-                       int retval;
-
-                       Log1(PCSC_LOG_INFO, "Hotplug stopped");
-                       pthread_exit(&retval);
-               }
-
-       }       /* End of while loop */
-}
-
-LONG HPSearchHotPluggables(void)
-{
-       int i, j;
-
-       for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
-       {
-               bundleTracker[i].productID  = 0;
-               bundleTracker[i].manuID     = 0;
-
-               for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++)
-                       bundleTracker[i].deviceNumber[j].id = 0;
-       }
-
-       if (HPReadBundleValues() > 0)
-               ThreadCreate(&usbNotifyThread, THREAD_ATTR_DETACHED,
-                       (PCSCLITE_THREAD_FUNCTION( )) 
HPEstablishUSBNotifications, 0);
-
-       return 0;
-}
-
-LONG HPStopHotPluggables(void)
-{
-       AraKiriHotPlug = TRUE;
-
-       return 0;
-}
-
-static LONG HPAddHotPluggable(int i, unsigned long usbAddr)
-{
-       /* NOTE: The deviceName is an empty string "" until someone implements
-        * the code to get it */
-       RFAddReader(bundleTracker[i].readerName, PCSCLITE_HP_BASE_PORT + 
usbAddr,
-               bundleTracker[i].libraryPath, "");
-
-       return 1;
-}      /* End of function */
-
-static LONG HPRemoveHotPluggable(int i, unsigned long usbAddr)
-{
-       RFRemoveReader(bundleTracker[i].readerName, PCSCLITE_HP_BASE_PORT + 
usbAddr);
-
-       return 1;
-}      /* End of function */
-
-/**
- * Sets up callbacks for device hotplug events.
- */
-ULONG HPRegisterForHotplugEvents(void)
-{
-       (void)pthread_mutex_init(&usbNotifierMutex, NULL);
-       return 0;
-}
-
-void HPReCheckSerialReaders(void)
-{
-}
-
-#endif /* __linux__ && !HAVE_LIBUSB */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/hotplug_macosx.c 
new/pcsc-lite-1.9.5/src/hotplug_macosx.c
--- old/pcsc-lite-1.9.4/src/hotplug_macosx.c    2020-08-05 13:01:32.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/hotplug_macosx.c    2021-10-15 21:34:10.000000000 
+0200
@@ -818,7 +818,8 @@
                if (!found)
                {
                        RFRemoveReader(a->m_driver->m_friendlyName,
-                               PCSCLITE_HP_BASE_PORT + a->m_address);
+                               PCSCLITE_HP_BASE_PORT + a->m_address,
+                               REMOVE_READER_FLAG_REMOVED);
                }
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/pcscd.h new/pcsc-lite-1.9.5/src/pcscd.h
--- old/pcsc-lite-1.9.4/src/pcscd.h     2021-10-01 18:01:18.000000000 +0200
+++ new/pcsc-lite-1.9.5/src/pcscd.h     2021-12-04 13:29:56.000000000 +0100
@@ -49,7 +49,7 @@
 
 #define PCSCLITE_CSOCK_NAME            PCSCLITE_IPC_DIR "/pcscd.comm"
 
-#define PCSCLITE_VERSION_NUMBER                "1.9.4" /**< Current version */
+#define PCSCLITE_VERSION_NUMBER                "1.9.5" /**< Current version */
 #define PCSCLITE_STATUS_POLL_RATE      400000          /**< Status polling 
rate */
 #define PCSCLITE_LOCK_POLL_RATE                100000          /**< Lock 
polling rate */
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/pcscdaemon.c new/pcsc-lite-1.9.5/src/pcscdaemon.c
--- old/pcsc-lite-1.9.4/src/pcscdaemon.c        2020-11-29 22:23:35.000000000 
+0100
+++ new/pcsc-lite-1.9.5/src/pcscdaemon.c        2021-11-13 18:18:01.000000000 
+0100
@@ -700,7 +700,7 @@
        }
 
        /*
-        * post initialistion
+        * post initialization
         */
        Init = FALSE;
 
@@ -738,7 +738,7 @@
 
        (void)signal(SIGPIPE, SIG_IGN);
        (void)signal(SIGHUP, SIG_IGN);  /* needed for Solaris. The signal is 
sent
-                                * when the shell is existed */
+                                * when the shell is exited */
 
 #if !defined(PCSCLITE_STATIC_DRIVER) && defined(USE_USB)
        /*
@@ -760,7 +760,7 @@
        RFWaitForReaderInit();
 #endif
 
-       /* initialisation succeeded */
+       /* initialization succeeded */
        if (pipefd[1] >= 0)
        {
                char buf = 0;
@@ -776,6 +776,13 @@
                pipefd[1] = -1;
        }
 
+       if (AutoExit)
+       {
+               Log2(PCSC_LOG_DEBUG, "Starting suicide alarm in %d seconds",
+                       TIME_BEFORE_SUICIDE);
+               alarm(TIME_BEFORE_SUICIDE);
+       }
+
        SVCServiceRunLoop();
 
        Log1(PCSC_LOG_ERROR, "SVCServiceRunLoop returned");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/readerfactory.c new/pcsc-lite-1.9.5/src/readerfactory.c
--- old/pcsc-lite-1.9.4/src/readerfactory.c     2021-01-02 16:20:35.000000000 
+0100
+++ new/pcsc-lite-1.9.5/src/readerfactory.c     2021-11-27 16:30:15.000000000 
+0100
@@ -378,7 +378,7 @@
 
                /* Cannot connect to reader. Exit gracefully */
                Log2(log_level, "%s init failed.", readerName);
-               (void)RFRemoveReader(readerName, port);
+               (void)RFRemoveReader(readerName, port, REMOVE_READER_NO_FLAG);
                return rv;
        }
 
@@ -404,7 +404,7 @@
                if (rv != SCARD_S_SUCCESS)
                {
                        Log2(PCSC_LOG_ERROR, "%s init failed.", readerName);
-                       (void)RFRemoveReader(readerName, port);
+                       (void)RFRemoveReader(readerName, port, 
REMOVE_READER_NO_FLAG);
                        return rv;
                }
        }
@@ -449,7 +449,7 @@
                if (i == PCSCLITE_MAX_READERS_CONTEXTS)
                {
                        /* No more slot left return */
-                       RFRemoveReader(readerName, port);
+                       RFRemoveReader(readerName, port, REMOVE_READER_NO_FLAG);
                        return SCARD_E_NO_MEMORY;
                }
 
@@ -548,7 +548,7 @@
                if (rv != SCARD_S_SUCCESS)
                {
                        /* Cannot connect to slot. Exit gracefully */
-                       (void)RFRemoveReader(readerName, port);
+                       (void)RFRemoveReader(readerName, port, 
REMOVE_READER_NO_FLAG);
                        return rv;
                }
 
@@ -571,7 +571,7 @@
                if (rv != SCARD_S_SUCCESS)
                {
                        Log2(PCSC_LOG_ERROR, "%s init failed.", readerName);
-                       (void)RFRemoveReader(readerName, port);
+                       (void)RFRemoveReader(readerName, port, 
REMOVE_READER_NO_FLAG);
                        return rv;
                }
        }
@@ -579,7 +579,7 @@
        return SCARD_S_SUCCESS;
 }
 
-LONG RFRemoveReader(const char *readerName, int port)
+LONG RFRemoveReader(const char *readerName, int port, int flags)
 {
        char lpcStripReader[MAX_READERNAME];
        int i;
@@ -610,6 +610,24 @@
                        if ((strncmp(readerName, lpcStripReader, MAX_READERNAME 
- sizeof(" 00 00")) == 0)
                                && (port == sReadersContexts[i]->port))
                        {
+                               if (flags & REMOVE_READER_FLAG_REMOVED)
+                               {
+                                       UCHAR tagValue[1];
+                                       DWORD valueLength;
+                                       LONG ret;
+
+                                       /* signal to the driver that the reader 
has been removed */
+                                       valueLength = sizeof(tagValue);
+                                       ret = 
IFDGetCapabilities(sReadersContexts[i],
+                                               TAG_IFD_DEVICE_REMOVED, 
&valueLength, tagValue);
+                                       if ((IFD_SUCCESS) == ret && (1 == 
tagValue[0]))
+                                       {
+                                               tagValue[0] = 1;
+                                               ret = 
IFDSetCapabilities(sReadersContexts[i],
+                                                       TAG_IFD_DEVICE_REMOVED, 
sizeof tagValue, tagValue);
+                                       }
+                               }
+
                                /* remove the reader */
                                UNREF_READER(sReadersContexts[i])
                        }
@@ -1375,7 +1393,8 @@
                        /* strip the 6 last char ' 00 00' */
                        lpcStripReader[strlen(lpcStripReader) - 6] = '\0';
 
-                       rv = RFRemoveReader(lpcStripReader, 
sReadersContexts[i]->port);
+                       rv = RFRemoveReader(lpcStripReader, 
sReadersContexts[i]->port,
+                               REMOVE_READER_NO_FLAG);
 
                        if (rv != SCARD_S_SUCCESS)
                                Log2(PCSC_LOG_ERROR, "RFRemoveReader error: 
0x%08lX", rv);
@@ -1542,7 +1561,7 @@
                                                Log2(PCSC_LOG_INFO, "Reader %s 
disappeared",
                                                        
reader_list[i].pcFriendlyname);
                                                
(void)RFRemoveReader(reader_list[i].pcFriendlyname,
-                                                       
reader_list[r].channelId);
+                                                       
reader_list[r].channelId, REMOVE_READER_NO_FLAG);
                                        }
                                }
                        }
@@ -1564,3 +1583,18 @@
 }
 #endif
 
+int RFGetPowerState(READER_CONTEXT * rContext)
+{
+       (void)pthread_mutex_lock(&rContext->powerState_lock);
+       int result = rContext->powerState;
+       (void)pthread_mutex_unlock(&rContext->powerState_lock);
+       return result;
+}
+
+void RFSetPowerState(READER_CONTEXT * rContext, int value)
+{
+       (void)pthread_mutex_lock(&rContext->powerState_lock);
+       rContext->powerState = value;
+       (void)pthread_mutex_unlock(&rContext->powerState_lock);
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/readerfactory.h new/pcsc-lite-1.9.5/src/readerfactory.h
--- old/pcsc-lite-1.9.4/src/readerfactory.h     2020-08-05 13:01:32.000000000 
+0200
+++ new/pcsc-lite-1.9.5/src/readerfactory.h     2021-11-27 16:30:15.000000000 
+0100
@@ -148,7 +148,7 @@
 
        LONG RFAllocateReaderSpace(unsigned int);
        LONG RFAddReader(const char *, int, const char *, const char *);
-       LONG RFRemoveReader(const char *, int);
+       LONG RFRemoveReader(const char *, int, int);
        LONG RFSetReaderName(READER_CONTEXT *, const char *, const char *, int);
        LONG RFReaderInfo(const char *, /*@out@*/ struct ReaderContext **);
        LONG RFReaderInfoById(SCARDHANDLE, /*@out@*/ struct ReaderContext **);
@@ -173,5 +173,10 @@
        void RFWaitForReaderInit(void);
        int RFStartSerialReaders(const char *readerconf);
        void RFReCheckReaderConf(void);
+       int RFGetPowerState(READER_CONTEXT *);
+       void RFSetPowerState(READER_CONTEXT *, int value);
+
+#define REMOVE_READER_NO_FLAG 0
+#define REMOVE_READER_FLAG_REMOVED 1
 
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/pcsc-lite-1.9.4/src/winscard.c new/pcsc-lite-1.9.5/src/winscard.c
--- old/pcsc-lite-1.9.4/src/winscard.c  2020-09-30 10:32:31.000000000 +0200
+++ new/pcsc-lite-1.9.5/src/winscard.c  2021-11-27 16:31:47.000000000 +0100
@@ -715,10 +715,8 @@
                        }
 
                        /* the card is now in use */
-                       (void)pthread_mutex_lock(&rContext->powerState_lock);
-                       rContext->powerState = POWER_STATE_IN_USE;
+                       RFSetPowerState(rContext, POWER_STATE_IN_USE);
                        Log1(PCSC_LOG_DEBUG, "powerState: POWER_STATE_IN_USE");
-                       (void)pthread_mutex_unlock(&rContext->powerState_lock);
                }
        }
 
@@ -900,7 +898,7 @@
                        /* SCARD_UNPOWER_CARD */
                        rv = IFDPowerICC(rContext, IFD_POWER_DOWN, NULL, NULL);
 
-                       rContext->powerState = POWER_STATE_UNPOWERED;
+                       RFSetPowerState(rContext, POWER_STATE_UNPOWERED);
                        Log1(PCSC_LOG_DEBUG, "powerState: 
POWER_STATE_UNPOWERED");
                }
 

Reply via email to