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 2024-08-10 19:05:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/pcsc-lite (Old) and /work/SRC/openSUSE:Factory/.pcsc-lite.new.7232 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "pcsc-lite" Sat Aug 10 19:05:49 2024 rev:104 rq:1192521 version:2.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/pcsc-lite/pcsc-lite.changes 2024-06-17 19:28:24.599873589 +0200 +++ /work/SRC/openSUSE:Factory/.pcsc-lite.new.7232/pcsc-lite.changes 2024-08-10 19:05:51.320936942 +0200 @@ -1,0 +2,11 @@ +Sun Aug 4 05:00:35 UTC 2024 - Axel Braun <axel.braun@gmx.de> + +- version 2.3.0 + - SCardGetStatusChange(): add the number of reader events + - Add Appstream metainfo announcing HW support + - meson: specify minimum meson version to use + - fix formats under musl libc + - Send libpcsclite.so logs to stderr instead of stdout + - Some other minor improvements + +------------------------------------------------------------------- Old: ---- pcsc-lite-2.2.3.tar.xz pcsc-lite-2.2.3.tar.xz.asc New: ---- pcsc-lite-2.3.0.tar.xz pcsc-lite-2.3.0.tar.xz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ pcsc-lite.spec ++++++ --- /var/tmp/diff_new_pack.K45rJJ/_old 2024-08-10 19:05:52.276976638 +0200 +++ /var/tmp/diff_new_pack.K45rJJ/_new 2024-08-10 19:05:52.280976804 +0200 @@ -26,7 +26,7 @@ %define PKG_USER scard %define PKG_GROUP scard Name: pcsc-lite -Version: 2.2.3 +Version: 2.3.0 Release: 0 Summary: PC/SC Smart Cards Library License: BSD-3-Clause AND GPL-3.0-or-later @@ -192,6 +192,7 @@ %{_libdir}/libpcsclite.so %{_libdir}/libpcsclite_real.so %{_datadir}/polkit-1/actions/org.debian.pcsc-lite.policy +%{_datadir}/metainfo/fr.apdu.pcsclite.metainfo.xml %files -n libpcsclite1 %defattr(-,root,root) ++++++ pcsc-lite-2.2.3.tar.xz -> pcsc-lite-2.3.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/.github/workflows/build_meson.yml new/pcsc-lite-2.3.0/.github/workflows/build_meson.yml --- old/pcsc-lite-2.2.3/.github/workflows/build_meson.yml 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/.github/workflows/build_meson.yml 2024-08-03 16:39:59.000000000 +0200 @@ -24,6 +24,7 @@ sudo apt install \ autoconf-archive \ debhelper-compat \ + doxygen \ dpkg-dev \ flex \ libpolkit-gobject-1-dev \ @@ -45,6 +46,9 @@ meson dist + # doxygen + meson compile doc + meson setup --reconfigure -Dlibsystemd=false -Dlibudev=false -Dpolkit=false meson compile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/ChangeLog new/pcsc-lite-2.3.0/ChangeLog --- old/pcsc-lite-2.2.3/ChangeLog 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/ChangeLog 2024-08-03 16:39:59.000000000 +0200 @@ -1,3 +1,12 @@ +2.3.0: Ludovic Rousseau +3 August 2024 +- SCardGetStatusChange(): add the number of reader events +- Add Appstream metainfo announcing HW support +- meson: specify minimum meson version to use +- fix formats under musl libc +- Send libpcsclite.so logs to stderr instead of stdout +- Some other minor improvements + 2.2.3: Ludovic Rousseau 26 May 2024 - meson: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP_Events.py new/pcsc-lite-2.3.0/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP_Events.py --- old/pcsc-lite-2.2.3/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP_Events.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pcsc-lite-2.3.0/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP_Events.py 2024-08-03 16:39:59.000000000 +0200 @@ -0,0 +1,112 @@ +#! /usr/bin/env python3 + +# SCardGetStatusChange_PnP_Events.py: Unit test for PnP events +# Copyright (C) 2024 Ludovic Rousseau +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +from smartcard.scard import (SCARD_STATE_UNAWARE, SCARD_STATE_IGNORE, + SCARD_STATE_CHANGED, SCARD_STATE_UNKNOWN, + SCARD_STATE_UNAVAILABLE, SCARD_STATE_EMPTY, + SCARD_STATE_PRESENT, SCARD_STATE_ATRMATCH, + SCARD_STATE_EXCLUSIVE, SCARD_STATE_INUSE, + SCARD_STATE_MUTE, SCARD_STATE_UNPOWERED, + SCardEstablishContext, + SCardGetStatusChange, + SCardListReaders, + SCardGetErrorMessage, + SCardReleaseContext, + SCARD_SCOPE_USER) +from smartcard.util import toHexString +import time + +RED = "\033[0;31m" +BLUE = "\033[0;34m" +NORMAL = "\033[00m" + + +def scardstate2text(cardstate): + state = list() + states_dict = { + SCARD_STATE_UNAWARE: "SCARD_STATE_UNAWARE", + SCARD_STATE_IGNORE: "SCARD_STATE_IGNORE", + SCARD_STATE_CHANGED: "SCARD_STATE_CHANGED", + SCARD_STATE_UNKNOWN: "SCARD_STATE_UNKNOWN", + SCARD_STATE_UNAVAILABLE: " SCARD_STATE_UNAVAILABLE", + SCARD_STATE_EMPTY: "SCARD_STATE_EMPTY", + SCARD_STATE_PRESENT: "SCARD_STATE_PRESENT", + SCARD_STATE_ATRMATCH: "SCARD_STATE_ATRMATCH", + SCARD_STATE_EXCLUSIVE: "SCARD_STATE_EXCLUSIVE", + SCARD_STATE_INUSE: "SCARD_STATE_INUSE", + SCARD_STATE_MUTE: "SCARD_STATE_MUTE", + SCARD_STATE_UNPOWERED: "SCARD_STATE_UNPOWERED"} + for s in states_dict.keys(): + if (cardstate & s): + state.append(states_dict[s]) + return state + + +def dumpStates(states): + for state in states: + readername, eventstate, atr = state + print("readername:", readername) + print("eventstate:", scardstate2text(eventstate)) + print("eventstate hw:", eventstate // (2 ** 16)) + print("atr:", toHexString(atr)) + readerstates[readername] = (readername, eventstate) + + +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) + +# initialise the states of the readers +readerstates = {} + +# List the available readers +hresult, readers = SCardListReaders(hcontext, []) +for reader in readers: + readerstates[reader] = (reader, SCARD_STATE_UNAWARE) + +# Add the PnP special reader +reader = "\\\\?PnP?\\Notification" +readerstates[reader] = (reader, SCARD_STATE_UNAWARE) + +print("values:", readerstates.values()) + +# Get the initial states +hresult, states = SCardGetStatusChange(hcontext, 0, + list(readerstates.values())) +dumpStates(states) + +print("Connect a reader within the next 5 seconds") +time.sleep(5) + +before = time.time() +# wait 1 second. SCardGetStatusChange() should return immediately +hresult, states = SCardGetStatusChange(hcontext, 1_000, + list(readerstates.values())) +print(SCardGetErrorMessage(hresult)) +duration = time.time() - before +dumpStates(states) + +print("Duration:", duration) +if duration < 0.5: + print(BLUE, "===========> OK", NORMAL) +else: + print(RED, "===========> FAILED", NORMAL) +print() + +hresult = SCardReleaseContext(hcontext) +print(SCardGetErrorMessage(hresult)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/clang-analyze.sh new/pcsc-lite-2.3.0/clang-analyze.sh --- old/pcsc-lite-2.2.3/clang-analyze.sh 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/clang-analyze.sh 2024-08-03 16:39:59.000000000 +0200 @@ -3,13 +3,11 @@ set -e # do not use configfile.c since it is a lex file from configfile.l -if [ $# -lt 1 ] -then - files=$(ls -1 src/*.c | grep -v configfile | grep -v tokenparser) -else - files="$@" -fi -inc="-I. -Isrc -Isrc/PCSC -I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include " -opt="--analyze " +pcscd_files="src/atrhandler.c src/auth.c src/debuglog.c src/dyn_unix.c src/eventhandler.c src/hotplug_generic.c src/hotplug_libudev.c src/hotplug_libusb.c src/ifdwrapper.c src/pcscdaemon.c src/prothandler.c src/readerfactory.c src/simclist.c src/sys_unix.c src/utils.c src/winscard.c src/winscard_msg.c src/winscard_msg_srv.c src/winscard_svc.c" +lib_files="src/debug.c src/winscard_clnt.c src/sys_unix.c src/utils.c src/winscard_msg.c" -clang $inc $opt $files +inc="-Ibuilddir -Isrc -Isrc/PCSC -I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/polkit-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include" +opt="--analyze" + +clang $inc -DPCSCD $opt $pcscd_files +clang $inc $opt $lib_files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/configure.ac new/pcsc-lite-2.3.0/configure.ac --- old/pcsc-lite-2.2.3/configure.ac 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/configure.ac 2024-08-03 16:39:59.000000000 +0200 @@ -49,7 +49,10 @@ AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_LEX([noyywrap]) -AS_IF([test $LEX = ":"], [AC_MSG_ERROR([no lex or flex found])]) +AS_IF([test $LEX = ":"], [ + AM_MISSING_PROG(MISSINGLEX, [flex]) + LEX=$MISSINGLEX] +) PKG_PROG_PKG_CONFIG AM_PROG_CC_C_O AM_PROG_AR @@ -281,7 +284,7 @@ PCSCLITE_FEATURES="${PCSCLITE_FEATURES} polkit"], [use_polkit=no AC_MSG_ERROR([[ -*** +*** *** polkit >= $POLKIT_MINIMUM was not found. Access control will be disabled. *** You may get it from http://www.freedesktop.org/software/polkit/ *** ]]) @@ -440,4 +443,3 @@ src/spy/Makefile ]) AC_OUTPUT - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/etc/fr.apdu.pcsclite.metainfo.xml new/pcsc-lite-2.3.0/etc/fr.apdu.pcsclite.metainfo.xml --- old/pcsc-lite-2.2.3/etc/fr.apdu.pcsclite.metainfo.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/pcsc-lite-2.3.0/etc/fr.apdu.pcsclite.metainfo.xml 2024-08-03 16:39:59.000000000 +0200 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component> + <id>fr.apdu.pcsclite</id> + <metadata_license>MIT</metadata_license> + <name>pcscd</name> + <summary>Middleware to access a smart card using PC/SC</summary> + <description> + <p>The purpose of PC/SC Lite is to provide a Windows(R) SCard + interface in a very small form factor for communicating to smart + cards and smart cards readers.</p> + + <p>The PC/SC daemon is used to dynamically allocate/deallocate + reader drivers at runtime and manage connections to the + readers.</p> + </description> + <developer id="fr.apdu.pcsclite"> + <name>PCSC-lite project</name> + </developer> + <url type="homepage">https://pcsclite.apdu.fr/</url> + <provides> + <modalias>usb:*ic0Bisc00ip*</modalias> + </provides> +</component> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/meson.build new/pcsc-lite-2.3.0/meson.build --- old/pcsc-lite-2.2.3/meson.build 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/meson.build 2024-08-03 16:39:59.000000000 +0200 @@ -10,7 +10,8 @@ # meson setup --reconfigure --wipe project('pcsc-lite', 'c', - version : '2.2.3') + meson_version : '>=0.58.0', + version : '2.3.0') # for config.h conf_data = configuration_data({ @@ -227,7 +228,7 @@ 'src/PCSC/reader.h', 'src/PCSC/winscard.h', 'src/PCSC/wintypes.h'], - install_dir : 'include/PCSC') + install_dir : get_option('includedir') / 'PCSC') # data if get_option('polkit') @@ -235,6 +236,9 @@ install_dir : polkit_dep.get_variable('policydir')) endif +install_data('etc/fr.apdu.pcsclite.metainfo.xml', + install_dir : 'share/metainfo' + ) # generate config.h configure_file(output : 'config.h', configuration : conf_data) @@ -242,7 +246,7 @@ # generate from .in files configure_file(output : 'pcsclite.h', input : 'src/PCSC/pcsclite.h.in', - install_dir : join_paths(get_option('prefix'), 'include/PCSC'), + install_dir : get_option('prefix') / get_option('includedir') / 'PCSC', configuration : confgen_data) configure_file(output : 'pcscd.h', input : 'src/pcscd.h.in', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/meson.options new/pcsc-lite-2.3.0/meson.options --- old/pcsc-lite-2.2.3/meson.options 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/meson.options 2024-08-03 16:39:59.000000000 +0200 @@ -46,10 +46,10 @@ option('embedded', type : 'boolean', - value : 'false', + value : false, description : 'for embedded systems [limit RAM and CPU resources by disabling features (log)]') option('filter_names', type : 'boolean', - value : 'true', + value : true, description : 'reader filtering using PCSCLITE_FILTER_IGNORE_READER_NAMES and PCSCLITE_FILTER_EXTEND_READER_NAMES') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/debuglog.c new/pcsc-lite-2.3.0/src/debuglog.c --- old/pcsc-lite-2.2.3/src/debuglog.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/debuglog.c 2024-08-03 16:39:59.000000000 +0200 @@ -262,10 +262,10 @@ break; } -#ifdef __APPLE__ -#define THREAD_FORMAT "%p" -#else +#ifdef __GLIBC__ #define THREAD_FORMAT "%lu" +#else +#define THREAD_FORMAT "%p" #endif if (rv_text) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/libredirect.c new/pcsc-lite-2.3.0/src/libredirect.c --- old/pcsc-lite-2.2.3/src/libredirect.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/libredirect.c 2024-08-03 16:39:59.000000000 +0200 @@ -115,8 +115,8 @@ va_list args; va_start(args, fmt); - vprintf(fmt, args); - printf("\n"); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); va_end(args); } #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/readerfactory.c new/pcsc-lite-2.3.0/src/readerfactory.c --- old/pcsc-lite-2.2.3/src/readerfactory.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/readerfactory.c 2024-08-03 16:39:59.000000000 +0200 @@ -73,8 +73,8 @@ static int ConfigFileCRC = 0; #endif static pthread_mutex_t LockMutex = PTHREAD_MUTEX_INITIALIZER; +int16_t ReaderEvents = 1; -#define IDENTITY_SHIFT 16 static LONG removeReader(READER_CONTEXT * sReader); static int RDR_CLIHANDLES_seeker(const void *el, const void *key) @@ -400,6 +400,12 @@ } } + /* we have one more reader */ + ReaderEvents++; + /* wrap? */ + if (ReaderEvents < 0) + ReaderEvents = 1; + /* Call on the driver to see if there are multiple slots */ dwGetSize = sizeof(ucGetData); rv = IFDGetCapabilities((sReadersContexts[dwContext]), @@ -623,6 +629,12 @@ } } + /* we have one less reader */ + ReaderEvents++; + /* wrap? */ + if (ReaderEvents < 0) + ReaderEvents = 1; + return SCARD_S_SUCCESS; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/spy/libpcscspy.c new/pcsc-lite-2.3.0/src/spy/libpcscspy.c --- old/pcsc-lite-2.2.3/src/spy/libpcscspy.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/spy/libpcscspy.c 2024-08-03 16:39:59.000000000 +0200 @@ -102,8 +102,8 @@ va_list args; va_start(args, fmt); - vprintf(fmt, args); - printf("\n"); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); va_end(args); } #else @@ -121,7 +121,7 @@ if (Log_fd < 0) return; - snprintf(threadid, sizeof threadid, "%lX@", pthread_self()); + snprintf(threadid, sizeof threadid, "%lX@", (unsigned long)pthread_self()); pthread_mutex_lock(&Log_fd_mutex); r = write(Log_fd, threadid, strlen(threadid)); r = write(Log_fd, line, strlen(line)); @@ -150,7 +150,7 @@ printf("libpcsc-spy: Buffer is too small!\n"); return; } - snprintf(threadid, sizeof threadid, "%lX@", pthread_self()); + snprintf(threadid, sizeof threadid, "%lX@", (unsigned long)pthread_self()); pthread_mutex_lock(&Log_fd_mutex); r = write(Log_fd, threadid, strlen(threadid)); r = write(Log_fd, line, size); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/testpcsc.c new/pcsc-lite-2.3.0/src/testpcsc.c --- old/pcsc-lite-2.2.3/src/testpcsc.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/testpcsc.c 2024-08-03 16:39:59.000000000 +0200 @@ -188,7 +188,7 @@ mszReaders = calloc(dwReaders, sizeof(char)); rv = SCardListReaders(hContext, mszGroups, mszReaders, &dwReaders); #endif - test_rv(rv, hContext, DONT_PANIC); + test_rv(rv, hContext, PANIC); /* * Have to understand the multi-string here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/winscard_clnt.c new/pcsc-lite-2.3.0/src/winscard_clnt.c --- old/pcsc-lite-2.2.3/src/winscard_clnt.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/winscard_clnt.c 2024-08-03 16:39:59.000000000 +0200 @@ -251,14 +251,10 @@ if (profile_tty) { - if (rv != SCARD_S_SUCCESS) - fprintf(stderr, - COLOR_RED "RESULT %s " COLOR_MAGENTA "%ld " - COLOR_BLUE "0x%08lX %s" COLOR_NORMAL "\n", - f, d, rv, pcsc_stringify_error(rv)); - else - fprintf(stderr, COLOR_RED "RESULT %s " COLOR_MAGENTA "%ld" - COLOR_NORMAL "\n", f, d); + fprintf(stderr, + COLOR_RED "RESULT %s " COLOR_MAGENTA "%ld " + COLOR_BLUE "0x%08lX" COLOR_NORMAL "\n", + f, d, rv); } fprintf(profile_fd, "%s %ld\n", f, d); fflush(profile_fd); @@ -375,6 +371,7 @@ static LONG SCardGetSetAttrib(SCARDHANDLE hCard, int command, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen); +static LONG getReaderEvents(SCONTEXTMAP * currentContextMap, int *readerEvents); static LONG getReaderStates(SCONTEXTMAP * currentContextMap); static LONG getReaderStatesAndRegisterForEvents(SCONTEXTMAP * currentContextMap); static LONG unregisterFromEvents(SCONTEXTMAP * currentContextMap); @@ -1689,14 +1686,16 @@ SCONTEXTMAP * currentContextMap; int currentReaderCount = 0; LONG rv = SCARD_S_SUCCESS; + int pnp_reader = -1; PROFILE_START API_TRACE_IN("%ld %ld %d", hContext, dwTimeout, cReaders) #ifdef DO_TRACE for (j=0; j<cReaders; j++) { - API_TRACE_IN("[%d] %s %lX %lX", j, rgReaderStates[j].szReader, - rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState) + API_TRACE_IN("[%d] %s %lX %lX (%d)", j, rgReaderStates[j].szReader, + rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState, + rgReaderStates[j].cbAtr) } #endif @@ -1781,6 +1780,8 @@ (void)pthread_mutex_unlock(&readerStatesMutex); goto end; } + else + pnp_reader = j; } } (void)pthread_mutex_unlock(&readerStatesMutex); @@ -1792,6 +1793,33 @@ /* Now is where we start our event checking loop */ Log2(PCSC_LOG_DEBUG, "Event Loop Start, dwTimeout: %ld", dwTimeout); + /* index of the PnP readerin rgReaderStates[] */ + if (pnp_reader >= 0) + { + int readerEvents; + currReader = &rgReaderStates[pnp_reader]; + + /* PnP special reader */ + if (SCARD_S_SUCCESS == getReaderEvents(currentContextMap, &readerEvents)) + { + int previousReaderEvents = currReader->dwCurrentState >> 16; + + // store readerEvents in .dwEventState high word + currReader->dwEventState = (currReader->dwEventState & 0xFFFF) + (readerEvents << 16); + if ( + /* the value has changed since the last call */ + (previousReaderEvents != readerEvents) + /* backward compatibility: only if we had a non-null + * reader events value */ + && previousReaderEvents) + { + currReader->dwEventState |= SCARD_STATE_CHANGED; + rv = SCARD_S_SUCCESS; + dwBreakFlag = 1; + } + } + } + /* Get the initial reader count on the system */ for (j=0; j < PCSCLITE_MAX_READERS_CONTEXTS; j++) if (readerStates[j].readerName[0] != '\0') @@ -1841,9 +1869,17 @@ if (newReaderCount != currentReaderCount) { + int readerEvents; + Log1(PCSC_LOG_INFO, "Reader list changed"); currentReaderCount = newReaderCount; + if (SCARD_S_SUCCESS == getReaderEvents(currentContextMap, &readerEvents)) + { + // store readerEvents in .dwEventState high word + currReader->dwEventState = (currReader->dwEventState & 0xFFFF) + (readerEvents << 16); + } + currReader->dwEventState |= SCARD_STATE_CHANGED; dwBreakFlag = 1; } @@ -2168,8 +2204,9 @@ #ifdef DO_TRACE for (j=0; j<cReaders; j++) { - API_TRACE_OUT("[%d] %s %X %X", j, rgReaderStates[j].szReader, - rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState) + API_TRACE_OUT("[%d] %s %lX %lX (%d)", j, rgReaderStates[j].szReader, + rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState, + rgReaderStates[j].cbAtr) } #endif @@ -3561,6 +3598,26 @@ return SCARD_S_SUCCESS; } + +static LONG getReaderEvents(SCONTEXTMAP * currentContextMap, int *readerEvents) +{ + int32_t dwClientID = currentContextMap->dwClientID; + LONG rv; + struct get_reader_events get_reader_events = {0}; + + rv = MessageSendWithHeader(CMD_GET_READER_EVENTS, dwClientID, 0, NULL); + if (rv != SCARD_S_SUCCESS) + return rv; + + /* Read a message from the server */ + rv = MessageReceive(&get_reader_events, sizeof(get_reader_events), dwClientID); + if (rv != SCARD_S_SUCCESS) + return rv; + + *readerEvents = get_reader_events.readerEvents; + + return SCARD_S_SUCCESS; +} static LONG getReaderStates(SCONTEXTMAP * currentContextMap) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/winscard_msg.h new/pcsc-lite-2.3.0/src/winscard_msg.h --- old/pcsc-lite-2.2.3/src/winscard_msg.h 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/winscard_msg.h 2024-08-03 16:39:59.000000000 +0200 @@ -49,7 +49,7 @@ /** Major version of the current message protocol */ #define PROTOCOL_VERSION_MAJOR 4 /** Minor version of the current message protocol */ -#define PROTOCOL_VERSION_MINOR 4 +#define PROTOCOL_VERSION_MINOR 5 /** * @brief Information transmitted in \ref CMD_VERSION Messages. @@ -96,6 +96,7 @@ CMD_GET_READERS_STATE = 0x12, /**< get the readers state */ CMD_WAIT_READER_STATE_CHANGE = 0x13, /**< wait for a reader state change */ CMD_STOP_WAITING_READER_STATE_CHANGE = 0x14, /**< stop waiting for a reader state change */ + CMD_GET_READER_EVENTS = 0x15, /**< get the number of reader events */ CMD_ENUM_LAST }; @@ -270,6 +271,12 @@ uint32_t rv; }; + struct get_reader_events + { + uint32_t readerEvents; + uint32_t rv; + }; + /* * Now some function definitions */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pcsc-lite-2.2.3/src/winscard_svc.c new/pcsc-lite-2.3.0/src/winscard_svc.c --- old/pcsc-lite-2.2.3/src/winscard_svc.c 2024-05-26 17:08:15.000000000 +0200 +++ new/pcsc-lite-2.3.0/src/winscard_svc.c 2024-08-03 16:39:59.000000000 +0200 @@ -99,6 +99,7 @@ static void * ContextThread(LPVOID pdwIndex); extern READER_STATE readerStates[PCSCLITE_MAX_READERS_CONTEXTS]; +extern int16_t ReaderEvents; static int contextsListhContext_seeker(const void *el, const void *key) { @@ -322,6 +323,7 @@ "CMD_GET_READERS_STATE", "CMD_WAIT_READER_STATE_CHANGE", "CMD_STOP_WAITING_READER_STATE_CHANGE", /* 0x14 */ + "CMD_GET_READER_EVENTS", "NULL" }; #endif @@ -450,7 +452,7 @@ struct wait_reader_state_change waStr = { .timeOut = 0, - .rv = 0 + .rv = SCARD_S_SUCCESS }; LONG rv; @@ -467,6 +469,20 @@ } break; + case CMD_GET_READER_EVENTS: + { + /* nothing to read */ + + struct get_reader_events readerEvents = + { + .readerEvents = ReaderEvents, + .rv = SCARD_S_SUCCESS + }; + + WRITE_BODY(readerEvents); + } + break; + case SCARD_ESTABLISH_CONTEXT: { struct establish_struct esStr; @@ -849,7 +865,7 @@ struct wait_reader_state_change waStr = { .timeOut = 0, - .rv = 0 + .rv = SCARD_S_SUCCESS }; Log2(PCSC_LOG_DEBUG, "Signal client: %d", filedes);
participants (1)
-
Source-Sync