diff --git a/ChangeLog b/ChangeLog index 41ca214..805ab76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +1.9.2: Ludovic Rousseau +3 August 2021 +- improve NetBSD support +- pcsc-spy: version 1.1 + . add option -t|--thread + . x10 speed increase + . correctly exit at end-of-file + . remove, now useless, support of macOS +- systemd: + . use /etc/default/pcscd as EnvironmentFile + . use $PCSCD_ARGS to specify more arguments +- SetProtocol: Handle IFD_NOT_SUPPORTED from the driver +- hotplug_libudev.c: sanitize interface name +- pcsc_demo: change licence from GPLv3 to BSD +- use Python 3 for Python scripts (psc-spy, UnitaryTests) +- Some other minor improvements + + 1.9.1: Ludovic Rousseau 16 February 2021 - Do not (possibly) lock a reader if allocating hCard fails diff --git a/ChangeLog.git b/ChangeLog.git index 080e857..d07cfe3 100644 --- a/ChangeLog.git +++ b/ChangeLog.git @@ -1,4 +1,610 @@ -commit 7135021f5cefab900ddef89cdbfc9aef14671e6a (HEAD -> master, tag: 1.9.1, zotac/master, origin/master, origin/HEAD, github/master) +commit 7afcaf630e2ce6d3d8079c0e59d52653e9f0f811 (HEAD -> master, tag: 1.9.2, zotac/master, origin/master, origin/HEAD, github/master) +Author: Ludovic Rousseau +Date: Tue Aug 3 18:55:23 2021 +0200 + + Release 1.9.2 + + Signed-off-by: Ludovic Rousseau + + ChangeLog | 18 ++++++++++++++++++ + configure.ac | 2 +- + 2 files changed, 19 insertions(+), 1 deletion(-) + +commit c31884c1ce59688187ea2e2401173ad0ac29ec49 +Author: Ludovic Rousseau +Date: Tue Aug 3 18:07:56 2021 +0200 + + reader.h: use logical OR operator instead of bitwise OR operator + + The behavior should be the same but the code is cleaner now. + + Thanks to Godfrey Chung for the bug report + https://github.com/LudovicRousseau/PCSC/commit/1886e60798c0f2cb05a9c430d7c48691fe8edc11#commitcomment-54330043 + + src/PCSC/reader.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 0076d763174ee065d4b96483ea4709d1958cc3ae +Author: Ludovic Rousseau +Date: Sun Jul 11 18:50:47 2021 +0200 + + Create github issue template + + It should be easier for users to report the important information. + + .github/ISSUE_TEMPLATE.md | 29 +++++++++++++++++++++++++++++ + 1 file changed, 29 insertions(+) + +commit f94cb5eb8d54c1e7b3846a19a347c8130ee8d401 +Author: Ludovic Rousseau +Date: Sun Jul 4 12:51:32 2021 +0200 + + Makefile.am: no need to distribute m4 macros anymore + + - m4/ax_pthread.m4 is fetched from autoconf-archive + - m4/as-ac-expand.m4 is replaced by ax_recursive_eval.m4 from + autoconf-archive + + Makefile.am | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 2309de059191d7730edfa554d179dd52a67b0994 +Author: Ludovic Rousseau +Date: Sun Jul 4 12:40:47 2021 +0200 + + configure/ac: simplify usage of ${sbindir_exp} + + The variable is already expanded so not need to use "eval eval..." again + to expand it. + + configure.ac | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit afbe42b6d033b81ca2bb91d060b55cd482043be6 +Author: Ludovic Rousseau +Date: Sun Jul 4 12:36:53 2021 +0200 + + Use AX_RECURSIVE_EVAL() from autoconf-archive + + AS_AC_EXPAND() is not maintained upstream any more. + + We can now remove the useless file m4/as-ac-expand.m4 + + configure.ac | 6 +++--- + m4/as-ac-expand.m4 | 43 ------------------------------------------- + 2 files changed, 3 insertions(+), 46 deletions(-) + +commit 1b0a1bf496203d02f0dae39f2da1a5377bcc5c1b +Author: Ludovic Rousseau +Date: Sun Jul 4 12:32:14 2021 +0200 + + Use @PCSCLITE_CONFIG_DIR@ instead of @confdir_exp@ + + "PCSCLITE_CONFIG_DIR" is substituted (using AC_SUBST(PCSCLITE_CONFIG_DIR) in + configure.ac) but "confdir_exp" is not. + + doc/pcscd.8.in | 10 +++++----- + doc/reader.conf.5.in | 6 +++--- + src/libpcsclite.pc.in | 2 +- + 3 files changed, 9 insertions(+), 9 deletions(-) + +commit cd798fa2dfc12c2b2542616a4c42f43283ca1423 +Author: Ludovic Rousseau +Date: Sun Jul 4 12:09:09 2021 +0200 + + Use ax_pthread.m4 macro from autoconf-archive + + autoconf-archive package provides ax_pthread.m4 so we do not have to get + it from the PCSC repository. + + m4/ax_pthread.m4 | 309 ------------------------------------------------------- + 1 file changed, 309 deletions(-) + +commit 35d5ce40cfa377b97e86276b27342b43257dd931 +Author: Ludovic Rousseau +Date: Sun Jul 4 12:03:29 2021 +0200 + + Remove definition of unused localstatedir + + localstatedir use was removed in a707c88a79cf96ab97ba26e38dc8ea47aa4fb18f + "Remove etc directory completely" + + configure.ac | 1 - + 1 file changed, 1 deletion(-) + +commit 6928aa235821339a466d6dc759e177b538e9ac2b +Author: Ludovic Rousseau +Date: Sun Jul 4 11:59:21 2021 +0200 + + Remove definition os unused PCSCD_BINARY + + PCSCD_BINARY use was removed in 244664b6b31e723728d409dd178ed11722d83a84 + 10 years ago: "Remove pcscd autostart feature". + + configure.ac | 3 --- + 1 file changed, 3 deletions(-) + +commit 7730f6c54d7fb6a910d291e2d48c92d2a5abf688 +Author: Ludovic Rousseau +Date: Thu Jun 17 10:48:40 2021 +0200 + + SetProtocol: Handle IFD_NOT_SUPPORTED from the driver + + If the driver returns IFD_NOT_SUPPORTED from the function + IFDHSetProtocolParameters() it indicates the "command" is not supported. + It is different from IFD_PROTOCOL_NOT_SUPPORTED that indicates the + "prorocol" is not supported. + + The problem was with a ACR38U CCID and a memory card. The + SetParameters() fails but the card can still be used using the default + protocol. + + The behaviour is identical to what we had before the commit + 5d58577093f56dbcfbf754940f885ed8fcdba206. + + Thanks to Godfrey Chung for the bug report + "pcsc-lite 1.9.1: memory card connection failed #103" + https://github.com/LudovicRousseau/PCSC/issues/103 + + src/prothandler.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 6f9b6272d5b1f3a5df4d0d8750b48b651662b683 +Author: Ludovic Rousseau +Date: Tue Jun 1 22:04:40 2021 +0200 + + systemd: use $PCSCD_ARGS to specify more arguments + + You can define $PCSCD_ARGS in /etc/default/pcscd to add more arguments + to pcscd. + For exeample you can use: + PCSCD_ARGS=--debug + to get debug messaqes in the systemd journal. + + Use "journalctl --unit pcscd --follow" to see the logs. + + Fix https://salsa.debian.org/rousseau/PCSC/-/issues/14 + + etc/pcscd.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit de70032e4eff6c03d8e58f142e075205b64f0678 +Author: Ludovic Rousseau +Date: Tue Jun 1 21:43:02 2021 +0200 + + systemd: use /etc/default/pcscd as EnvironmentFile + + If you want to set environment variables to change the behavior of pcscd + you can use the file /etc/default/pcscd + + For example you can add in this file: + PCSCLITE_FILTER_IGNORE_READER_NAMES="Twin" + so that readers with "Twin" in the name will be ignored. + + See "Remove and/or customize PC/SC reader names" + https://ludovicrousseau.blogspot.com/2015/12/remove-andor-customize-pcsc-reader-names.html + + Thanks to Maurizio Avogadro for the idea + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989316 + + etc/pcscd.service.in | 1 + + 1 file changed, 1 insertion(+) + +commit 221da22ba3daa463d021a3b4ad7837bf32763184 +Author: Ludovic Rousseau +Date: Mon May 24 13:05:41 2021 +0200 + + pcsc-spy: update copyright date + + src/spy/pcsc-spy | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c6dd6e12f1d8d84119c88c9ccbdcd6a9c454a227 +Author: Ludovic Rousseau +Date: Mon May 24 13:03:10 2021 +0200 + + pcsc-spy: use an explicit SpyExit exception + + This exception is used to terminate the threads. + It is cleaner to catch a specific exception rather than parsing a + generic exception. + + src/spy/pcsc-spy | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit cfcd964497aa022530bab6851ac2cc28d59620f6 +Author: Ludovic Rousseau +Date: Sun May 23 16:33:53 2021 +0200 + + pcsc-spy: version 1.1 + + src/spy/pcsc-spy | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7b24899d079ba1f4934287161b94cff7fdbe7642 +Author: Ludovic Rousseau +Date: Sun May 23 16:32:34 2021 +0200 + + pcsc-spy.pod: use /usr/lib/x86_64-linux-gnu + + On Unix the libraries and now in /usr/lib/x86_64-linux-gnu (for an AMD64 + CPU) instead of in /usr/lib + + src/spy/pcsc-spy.pod | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d55c5e43b46b91da0db0304806b5fd5668b7295e +Author: Ludovic Rousseau +Date: Sun May 23 16:15:27 2021 +0200 + + pcsc-spy.pod: add [-v|--version] in synopsis + + src/spy/pcsc-spy.pod | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b4be7647566d8450dbf81b29a5626781966ced7b +Author: Ludovic Rousseau +Date: Sun May 23 16:14:01 2021 +0200 + + pcsc-spy.pod: document −t, −−thread argument + + src/spy/pcsc-spy.pod | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 8e3ce8492eb7146f9c379b39422edca51cf69c6d +Author: Ludovic Rousseau +Date: Sun May 23 16:06:46 2021 +0200 + + pcsc-spy: remove, now useless, support of macOS + + The wrapper is non-working on macOS. Maybe since the intergation of SIP + (System Integrity Protection) in macOS El Capitan in 2015. + + I now get: + SCardEstablishContext + i dwScope: SCARD_SCOPE_SYSTEM (0x00000002) + o hContext: 0x00000000 + => Service not available. (SCARD_E_NO_SERVICE [0x8010001D]) [0.000660] + SCardReleaseContext + i hContext: 0x00000000 + => Invalid handle. (SCARD_E_INVALID_HANDLE [0x80100003]) [0.000006] + + src/spy/Makefile.am | 7 ------- + src/spy/libpcscspy.c | 19 ------------------- + src/spy/pcsc-spy.pod | 18 ------------------ + 3 files changed, 44 deletions(-) + +commit 5d320fb48c6cdcbc6b2befa83c63d28aeae4dd73 +Author: Ludovic Rousseau +Date: Sun May 23 15:44:33 2021 +0200 + + pcsc-spy: correctly exit at end-of-file + + Catch the exception generated by an end-of-file. + The Python backtrace is no more displayed in the output. + + src/spy/pcsc-spy | 138 +++++++++++++++++++++++++++++-------------------------- + 1 file changed, 74 insertions(+), 64 deletions(-) + +commit c41e105ad771fc213c3c63773bf660d02724062a +Author: Ludovic Rousseau +Date: Fri May 21 18:34:18 2021 +0200 + + UT: use explicit variable names + + UnitaryTests/SCardBlockingBehaviourTest.py | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 2a04fd673e132cf11e1d6435f7820fe8647827f2 +Author: Ludovic Rousseau +Date: Fri May 21 18:29:44 2021 +0200 + + UT: fix typo in comment + + UnitaryTests/SCardBlockingBehaviourTest.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b8e105bda6e17b7c63498efe4fb2c291ea7956f0 +Author: Ludovic Rousseau +Date: Fri May 21 18:24:15 2021 +0200 + + UT: migrate from thread to threading module + + thread module is no more available in Python 3. + + UnitaryTests/SCardBlockingBehaviourTest.py | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 98cd761cd6be27148b1a312b6026355d5986b7e7 +Author: Ludovic Rousseau +Date: Wed May 19 17:37:15 2021 +0200 + + pcsc-spy: x10 speed increase + + Sleep for 0.001 second instead of 0.01 second. + It is enough to let the other thread empty its queue. + + src/spy/pcsc-spy | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e82e5ab14405240b54355cf397fcaaa4e4132f50 +Author: Ludovic Rousseau +Date: Wed May 19 17:36:20 2021 +0200 + + pcsc-spy: remove extra parenthesis + + src/spy/pcsc-spy | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c925b2c8c2bf8a4b32f2d89be35043b8d3c76e10 +Author: Ludovic Rousseau +Date: Fri May 14 22:23:01 2021 +0200 + + pcsc-spy: remove use of "from __future__" + + The code now uses Python 3 so no need to use "from __future__ import + print_function" any more. + + src/spy/pcsc-spy | 1 - + 1 file changed, 1 deletion(-) + +commit 757a7d7c5ffcc2af3a80cc5fad0b344647187323 +Author: Ludovic Rousseau +Date: Fri May 14 22:21:26 2021 +0200 + + UnitaryTests: remove use of "from __future__" + + The code now uses Python 3 so no need to use "from __future__ import + print_function" any more. + + UnitaryTests/CheckAutoPowerOff.py | 1 - + UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py | 1 - + UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py | 1 - + UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py | 1 - + UnitaryTests/MCT_ReaderDirect.py | 1 - + UnitaryTests/SCardBeginTransaction_Disconnect.py | 1 - + UnitaryTests/SCardBeginTransaction_ExclusiceMode.py | 1 - + UnitaryTests/SCardBeginTransaction_Reset.py | 1 - + UnitaryTests/SCardBeginTransaction_SharedMode.py | 1 - + UnitaryTests/SCardBeginTransaction_deadlock.py | 1 - + UnitaryTests/SCardBlockingBehaviourTest.py | 1 - + UnitaryTests/SCardCancel.py | 1 - + UnitaryTests/SCardCancel2.py | 1 - + UnitaryTests/SCardCancel3.py | 1 - + UnitaryTests/SCardConnect_DIRECT.py | 1 - + UnitaryTests/SCardConnect_DIRECT2.py | 1 - + UnitaryTests/SCardEndTransaction_extra_call.py | 1 - + UnitaryTests/SCardExclusiveBehaviour.py | 1 - + UnitaryTests/SCardGetAttrib.py | 1 - + UnitaryTests/SCardGetStatusChange.py | 1 - + UnitaryTests/SCardGetStatusChange2.py | 1 - + UnitaryTests/SCardReconnect.py | 1 - + UnitaryTests/SCardStatus.py | 1 - + UnitaryTests/SCard_fork.py | 1 - + UnitaryTests/ThreadSafe.py | 1 - + UnitaryTests/ThreadSafeConnect.py | 1 - + UnitaryTests/control_get_firmware.py | 1 - + UnitaryTests/control_switch_interface.py | 1 - + UnitaryTests/getAttrib.py | 1 - + UnitaryTests/reset_card.py | 1 - + UnitaryTests/stress_apdu.py | 1 - + UnitaryTests/stress_get_firmware.py | 1 - + UnitaryTests/transmit_loop.py | 1 - + 33 files changed, 33 deletions(-) + +commit 41b7f5378eeece3c1d68302131a5cae075607b59 +Author: Ludovic Rousseau +Date: Fri May 14 11:40:16 2021 +0200 + + UnitaryTests: use Python3 explicitely + + UnitaryTests/CheckAutoPowerOff.py | 2 +- + UnitaryTests/FEATURE_CCID_ESC_COMMAND_Gemalto_features.py | 2 +- + UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py | 2 +- + UnitaryTests/FEATURE_GET_TLV_PROPERTIES.py | 2 +- + UnitaryTests/MCT_ReaderDirect.py | 2 +- + UnitaryTests/SCardBeginTransaction_Disconnect.py | 2 +- + UnitaryTests/SCardBeginTransaction_ExclusiceMode.py | 2 +- + UnitaryTests/SCardBeginTransaction_Reset.py | 2 +- + UnitaryTests/SCardBeginTransaction_SharedMode.py | 2 +- + UnitaryTests/SCardBeginTransaction_deadlock.py | 2 +- + UnitaryTests/SCardBlockingBehaviourTest.py | 2 +- + UnitaryTests/SCardCancel.py | 2 +- + UnitaryTests/SCardCancel2.py | 2 +- + UnitaryTests/SCardCancel3.py | 2 +- + UnitaryTests/SCardConnect_DIRECT.py | 2 +- + UnitaryTests/SCardConnect_DIRECT2.py | 2 +- + UnitaryTests/SCardEndTransaction_extra_call.py | 2 +- + UnitaryTests/SCardExclusiveBehaviour.py | 2 +- + UnitaryTests/SCardGetAttrib.py | 2 +- + UnitaryTests/SCardGetStatusChange.py | 2 +- + UnitaryTests/SCardGetStatusChange/SCardGetStatusChange.py | 2 +- + UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_PnP.py | 2 +- + UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py | 2 +- + UnitaryTests/SCardGetStatusChange2.py | 2 +- + UnitaryTests/SCardReconnect.py | 2 +- + UnitaryTests/SCardStatus.py | 2 +- + UnitaryTests/SCard_fork.py | 2 +- + UnitaryTests/ThreadSafe.py | 2 +- + UnitaryTests/ThreadSafeConnect.py | 2 +- + UnitaryTests/control_get_firmware.py | 2 +- + UnitaryTests/control_switch_interface.py | 2 +- + UnitaryTests/getAttrib.py | 2 +- + UnitaryTests/reset_card.py | 2 +- + UnitaryTests/stress_apdu.py | 2 +- + UnitaryTests/stress_get_firmware.py | 2 +- + UnitaryTests/transmit_loop.py | 2 +- + 36 files changed, 36 insertions(+), 36 deletions(-) + +commit 0c5324877fb36b6bbbcb364f1d09f8b0aef87b91 +Author: Ludovic Rousseau +Date: Fri May 14 11:24:40 2021 +0200 + + pcsc-spy: use Python3 explicitely + + Fixes the error: + bash: pcsc-spy: /usr/bin/python: bad interpreter: No such file or directory + + src/spy/pcsc-spy | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d5fb30c12e91d13e29700ad7d1269065caca51e1 +Author: Ludovic Rousseau +Date: Fri May 14 11:19:49 2021 +0200 + + pcsc-spy: add option -t|--thread + + Displays the thread number to make it easier to track what the + different threads do without counting the indentation spaces. + + We now get something like: + [...] + (t1) SCardEstablishContext + (t1) i dwScope: SCARD_SCOPE_SYSTEM (0x00000002) + (t5) o szReader: Identive CLOUD 2700 F Smart Card Reader [CCID Interface] (53992021200613) 00 00 + (t5) o dwCurrentState: SCARD_STATE_CHANGED, SCARD_STATE_PRESENT (0x00000022) + (t5) o dwEventState: SCARD_STATE_PRESENT, SCARD_STATE_INUSE (0x00000120) + (t5) o Atr length: 0x00000018 (24) + (t5) o Atr: 3B BF 96 00 81 31 FE 5D 00 64 04 11 04 0F 31 C0 73 F7 01 D0 00 90 00 74 + (t5) => Command timeout. (SCARD_E_TIMEOUT [0x8010000A]) [0.004717] + (t1) o hContext: 0x1DBE37AA + (t1) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.001246] + (t5) SCardEndTransaction + (t5) i hCard: 0x46E0BDBB + (t5) i dwDisposition: SCARD_LEAVE_CARD (0x00000000) + (t4) SCardListReaders + (t4) i hContext: 0x1DBE37AA + (t4) i mszGroups: (null) + (t5) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000310] + (t4) o pcchReaders: 0x00000051 + [...] + + src/spy/pcsc-spy | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +commit b01f19fb9361a87cc4473dfb50ae73b0a6871671 +Author: Ludovic Rousseau +Date: Sun Mar 7 14:29:02 2021 +0100 + + pcsc_demo: change licence from GPLv3 to BSD + + Use the same licence as the main code of pcsc-lite so the sample can be + used by people who can't use GPL v3 code. + + Thanks to Fulup Ar Foll for the notice. + + doc/example/pcsc_demo.c | 36 +++++++++++++++++++++++------------- + 1 file changed, 23 insertions(+), 13 deletions(-) + +commit 88a99adaa694e4d58ea8c17c95771cccce7b0468 +Author: Ludovic Rousseau +Date: Sun Mar 7 13:53:48 2021 +0100 + + pcsc_demo: fix #include + + doc/example/pcsc_demo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c16f6f46de7160639727abc72db5c0d18c5f7cdd +Author: Ludovic Rousseau +Date: Sun Mar 7 13:51:26 2021 +0100 + + pcsc_demo: remove extra #include + + doc/example/pcsc_demo.c | 1 - + 1 file changed, 1 deletion(-) + +commit 4e870e10168e19a3ec6744aac81cfe3a875dae18 +Author: Ludovic Rousseau +Date: Sat Mar 6 22:30:50 2021 +0100 + + pcsc_demo: remove unused code + + No need to define TRUE or FALSE. + + doc/example/pcsc_demo.c | 5 ----- + 1 file changed, 5 deletions(-) + +commit b924630b1c3fdb8cbf484fb567728a03f19828ef +Author: Ludovic Rousseau +Date: Tue Feb 23 13:42:50 2021 +0100 + + hotplug_libudev.c: sanitize interface name + + If the USB reader reports an interface name that is not ASCII (or a + valid UTF-8) string then bad things can happen. + + For example the Gemalto IDBridge K3000 token has a strange byte in the + iInterface name. + iInterface: IDBridge K3000 ?5300029B + + And PySCard complains with: + > ./pySim-read.py -p 0 + Using PC/SC reader interface + Traceback (most recent call last): + File "/tmp/pysim/./pySim-read.py", line 90, in + sl.wait_for_card() + File "/tmp/pysim/pySim/transport/pcsc.py", line 49, in wait_for_card + cr.waitforcard() + File "/usr/lib/python3.9/site-packages/smartcard/CardRequest.py", line 69, in waitforcard + return self.pcsccardrequest.waitforcard() + File "/usr/lib/python3.9/site-packages/smartcard/pcsc/PCSCCardRequest.py", line 137, in waitforcard + hresult, newstates = SCardGetStatusChange( + File "/usr/lib/python3.9/site-packages/smartcard/scard/scard.py", line 614, in SCardGetStatusChange + return _scard.SCardGetStatusChange(hcontext, dwTimeout, readerstatelist) + UnicodeEncodeError: 'ascii' codec can't encode character '\uff20' in position 39: ordinal not in range(128) + + Non ASCII characters are now replaced with '.'. + + Thanks to Nikolaos Kakouros for the bug report + https://github.com/LudovicRousseau/pyscard/issues/106 + "Errors when running pysim with Gemalto IDBridge K3000 #106" + + src/hotplug_libudev.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit f5dae8ddfc6f09f9d00f12087f2cea0d305081e3 +Author: Ludovic Rousseau +Date: Tue Feb 16 22:39:23 2021 +0100 + + configure.ac: fix a bashism + + POSIX does not define "==" for string equality. Use "=" instead. + + Thanks to Greg Troxel for the FreeBSD patch. + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1886e60798c0f2cb05a9c430d7c48691fe8edc11 +Author: Ludovic Rousseau +Date: Tue Feb 16 22:28:25 2021 +0100 + + NetBSD: fix compilation issue + + Use pack(1) instead of pack(push, 1). + + Thanks to Greg Troxel for the patch. + + src/PCSC/reader.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 223e60f0006f24c782a56f20e950131eea17f43e +Author: Ludovic Rousseau +Date: Tue Feb 16 22:16:58 2021 +0100 + + utils: do not define only time_sub() in LIBPCSCLITE case + + Only the function time_sub() is used by both the libpcsclite and pcscd + parts. All the other functions are used only by the pcscd daemon. + + Thanks to Greg Troxel for the NetBSD patch. + + src/utils.c | 4 ++++ + src/utils.h | 14 +++++++++----- + 2 files changed, 13 insertions(+), 5 deletions(-) + +commit 7135021f5cefab900ddef89cdbfc9aef14671e6a (tag: 1.9.1) Author: Ludovic Rousseau Date: Tue Feb 16 17:24:35 2021 +0100 diff --git a/Makefile.am b/Makefile.am index e86c584..534def2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,9 +13,7 @@ EXTRA_DIST = \ bootstrap \ ChangeLog.git \ SECURITY \ - HELP \ - m4/ax_pthread.m4 \ - m4/as-ac-expand.m4 + HELP DISTCLEANFILES = ChangeLog.git diff --git a/Makefile.in b/Makefile.in index c1b49bd..cd81573 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,8 +89,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -317,7 +316,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir_exp = @confdir_exp@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -339,7 +337,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -localstatedir_exp = @localstatedir_exp@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -349,7 +346,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ -sbindir_exp = @sbindir_exp@ serialconfdir = @serialconfdir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -360,7 +356,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ usbdropdir = @usbdropdir@ -usbdropdir_exp = @usbdropdir_exp@ SUBDIRS = src etc doc ACLOCAL_AMFLAGS = -I m4 DISTCHECK_CONFIGURE_FLAGS = \ @@ -371,9 +366,7 @@ EXTRA_DIST = \ bootstrap \ ChangeLog.git \ SECURITY \ - HELP \ - m4/ax_pthread.m4 \ - m4/as-ac-expand.m4 + HELP DISTCLEANFILES = ChangeLog.git all: config.h diff --git a/aclocal.m4 b/aclocal.m4 index f1c5b9b..d8d3366 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -20,6 +20,549 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also to link with them as well. For example, you might link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threaded programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to +# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2011 Daniel Richard G. +# +# 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 3 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 24 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_SED]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on Tru64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then + ax_pthread_save_CC="$CC" + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) + if test "x$ax_pthread_ok" = "xno"; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + CC="$ax_pthread_save_CC" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 +# (Note: HP C rejects this with "bad form for `-t' option") +# -pthreads: Solaris/gcc (Note: HP C also rejects) +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads and +# -D_REENTRANT too), HP C (must be checked before -lpthread, which +# is present but should not be used directly; and before -mthreads, +# because the compiler interprets this as "-mt" + "-hreads") +# -mthreads: Mingw32/gcc, Lynx/gcc +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case $host_os in + + freebsd*) + + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) + # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) + + ax_pthread_flags="-kthread lthread $ax_pthread_flags" + ;; + + hpux*) + + # From the cc(1) man page: "[-mt] Sets various -D flags to enable + # multi-threading and also sets -lpthread." + + ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" + ;; + + openedition*) + + # IBM z/OS requires a feature-test macro to be defined in order to + # enable POSIX threads at all, so give the user a hint if this is + # not set. (We don't define these ourselves, as they can affect + # other portions of the system API in unpredictable ways.) + + AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], + [ +# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) + AX_PTHREAD_ZOS_MISSING +# endif + ], + [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) + ;; + + solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (N.B.: The stubs are missing + # pthread_cleanup_push, or rather a function called by this macro, + # so we could check for that, but who knows whether they'll stub + # that too in a future libc.) So we'll check first for the + # standard Solaris way of linking pthreads (-mt -lpthread). + + ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ;; +esac + +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) + +AS_IF([test "x$GCC" = "xyes"], + [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + +# The presence of a feature test macro requesting re-entrant function +# definitions is, on some systems, a strong hint that pthreads support is +# correctly enabled + +case $host_os in + darwin* | hpux* | linux* | osf* | solaris*) + ax_pthread_check_macro="_REENTRANT" + ;; + + aix*) + ax_pthread_check_macro="_THREAD_SAFE" + ;; + + *) + ax_pthread_check_macro="--" + ;; +esac +AS_IF([test "x$ax_pthread_check_macro" = "x--"], + [ax_pthread_check_cond=0], + [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) + +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + +ax_pthread_clang_warning=no + +# Clang needs special handling, because older versions handle the -pthread +# option in a rather... idiosyncratic way + +if test "x$ax_pthread_clang" = "xyes"; then + + # Clang takes -pthread; it has never supported any other flag + + # (Note 1: This will need to be revisited if a system that Clang + # supports has POSIX threads in a separate library. This tends not + # to be the way of modern systems, but it's conceivable.) + + # (Note 2: On some systems, notably Darwin, -pthread is not needed + # to get POSIX threads support; the API is always present and + # active. We could reasonably leave PTHREAD_CFLAGS empty. But + # -pthread does define _REENTRANT, and while the Darwin headers + # ignore this macro, third-party headers might not.) + + PTHREAD_CFLAGS="-pthread" + PTHREAD_LIBS= + + ax_pthread_ok=yes + + # However, older versions of Clang make a point of warning the user + # that, in an invocation where only linking and no compilation is + # taking place, the -pthread option has no effect ("argument unused + # during compilation"). They expect -pthread to be passed in only + # when source code is being compiled. + # + # Problem is, this is at odds with the way Automake and most other + # C build frameworks function, which is that the same flags used in + # compilation (CFLAGS) are also used in linking. Many systems + # supported by AX_PTHREAD require exactly this for POSIX threads + # support, and in fact it is often not straightforward to specify a + # flag that is used only in the compilation phase and not in + # linking. Such a scenario is extremely rare in practice. + # + # Even though use of the -pthread flag in linking would only print + # a warning, this can be a nuisance for well-run software projects + # that build with -Werror. So if the active version of Clang has + # this misfeature, we search for an option to squash it. + + AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown + # Create an alternate version of $ac_link that compiles and + # links in two steps (.c -> .o, .o -> exe) instead of one + # (.c -> exe), because the warning occurs only in the second + # step + ax_pthread_save_ac_link="$ac_link" + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' + ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" + ax_pthread_save_CFLAGS="$CFLAGS" + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do + AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" + ac_link="$ax_pthread_save_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [ac_link="$ax_pthread_2step_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [break]) + ]) + done + ac_link="$ax_pthread_save_ac_link" + CFLAGS="$ax_pthread_save_CFLAGS" + AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" + ]) + + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in + no | unknown) ;; + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; + esac + +fi # $ax_pthread_clang = yes + +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -mt,pthread) + AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) + PTHREAD_CFLAGS="-mt" + PTHREAD_LIBS="-lpthread" + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void routine(void *a) { a = 0; } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = "xyes"; then + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_CACHE_CHECK([for joinable pthread attribute], + [ax_cv_PTHREAD_JOINABLE_ATTR], + [ax_cv_PTHREAD_JOINABLE_ATTR=unknown + for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [int attr = $ax_pthread_attr; return attr /* ; */])], + [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], + []) + done + ]) + AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ + test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ + test "x$ax_pthread_joinable_attr_defined" != "xyes"], + [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], + [$ax_cv_PTHREAD_JOINABLE_ATTR], + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + ax_pthread_joinable_attr_defined=yes + ]) + + AC_CACHE_CHECK([whether more special flags are required for pthreads], + [ax_cv_PTHREAD_SPECIAL_FLAGS], + [ax_cv_PTHREAD_SPECIAL_FLAGS=no + case $host_os in + solaris*) + ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" + ;; + esac + ]) + AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ + test "x$ax_pthread_special_flags_added" != "xyes"], + [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" + ax_pthread_special_flags_added=yes]) + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + [ax_cv_PTHREAD_PRIO_INHERIT], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ + test "x$ax_pthread_prio_inherit_defined" != "xyes"], + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) + ax_pthread_prio_inherit_defined=yes + ]) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + # More AIX lossage: compile with *_r variant + if test "x$GCC" != "xyes"; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + ;; + esac + fi +fi + +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_CC]) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test "x$ax_pthread_ok" = "xyes"; then + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD + +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_recursive_eval.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_RECURSIVE_EVAL(VALUE, RESULT) +# +# DESCRIPTION +# +# Interpolate the VALUE in loop until it doesn't change, and set the +# result to $RESULT. WARNING: It's easy to get an infinite loop with some +# unsane input. +# +# LICENSE +# +# Copyright (c) 2008 Alexandre Duret-Lutz +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 1 + +AC_DEFUN([AX_RECURSIVE_EVAL], +[_lcl_receval="$1" +$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do + _lcl_receval_old="[$]_lcl_receval" + eval _lcl_receval="\"[$]_lcl_receval\"" + done + echo "[$]_lcl_receval")`]) + # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 12 (pkg-config-0.29.2) @@ -1520,8 +2063,6 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR -m4_include([m4/as-ac-expand.m4]) -m4_include([m4/ax_pthread.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) diff --git a/config.h.in b/config.h.in index 3cbf854..a0717f4 100644 --- a/config.h.in +++ b/config.h.in @@ -167,9 +167,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* pcscd filename */ -#undef PCSCD_BINARY - /* Enabled PC/SC lite features */ #undef PCSCLITE_FEATURES diff --git a/configure b/configure index 0b39150..d8bfea8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pcsc-lite 1.9.1. +# Generated by GNU Autoconf 2.69 for pcsc-lite 1.9.2. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pcsc-lite' PACKAGE_TARNAME='pcsc-lite' -PACKAGE_VERSION='1.9.1' -PACKAGE_STRING='pcsc-lite 1.9.1' +PACKAGE_VERSION='1.9.2' +PACKAGE_STRING='pcsc-lite 1.9.2' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -633,15 +633,11 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS PCSCLITE_CONFIG_DIR -localstatedir_exp -sbindir_exp -confdir_exp host_to_ccid_32 host_to_ccid_16 serialconfdir ipcdir usbdropdir -usbdropdir_exp HAVE_SYSTEMD_FALSE HAVE_SYSTEMD_TRUE systemdsystemunitdir @@ -681,12 +677,12 @@ ac_ct_DUMPBIN DUMPBIN LD FGREP -SED LIBTOOL PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC ax_pthread_config +SED ac_ct_AR AR PKG_CONFIG_LIBDIR @@ -1395,7 +1391,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pcsc-lite 1.9.1 to adapt to many kinds of systems. +\`configure' configures pcsc-lite 1.9.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1466,7 +1462,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pcsc-lite 1.9.1:";; + short | recursive ) echo "Configuration of pcsc-lite 1.9.2:";; esac cat <<\_ACEOF @@ -1618,7 +1614,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pcsc-lite configure 1.9.1 +pcsc-lite configure 1.9.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2094,7 +2090,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pcsc-lite $as_me 1.9.1, which was +It was created by pcsc-lite $as_me 1.9.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2953,7 +2949,7 @@ fi # Define the identity of the package. PACKAGE='pcsc-lite' - VERSION='1.9.1' + VERSION='1.9.2' cat >>confdefs.h <<_ACEOF @@ -5523,6 +5519,77 @@ esac # Special check for pthread support +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + + + ac_ext=c @@ -5534,19 +5601,23 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). +# requires special compiler flags (e.g. on Tru64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then + ax_pthread_save_CC="$CC" + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + if test "x$PTHREAD_CC" != "x"; then : + CC="$PTHREAD_CC" +fi CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 -$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS" >&5 +$as_echo_n "checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5572,12 +5643,13 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } - if test x"$ax_pthread_ok" = xno; then + if test "x$ax_pthread_ok" = "xno"; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" + CC="$ax_pthread_save_CC" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" fi # We must check for the threads library under a number of different @@ -5590,7 +5662,7 @@ fi # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. -ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: @@ -5599,51 +5671,257 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 +# (Note: HP C rejects this with "bad form for `-t' option") +# -pthreads: Solaris/gcc (Note: HP C also rejects) # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC +# doesn't hurt to check since this sometimes defines pthreads and +# -D_REENTRANT too), HP C (must be checked before -lpthread, which +# is present but should not be used directly; and before -mthreads, +# because the compiler interprets this as "-mt" + "-hreads") +# -mthreads: Mingw32/gcc, Lynx/gcc # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) -case ${host_os} in +case $host_os in + + freebsd*) + + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) + # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) + + ax_pthread_flags="-kthread lthread $ax_pthread_flags" + ;; + + hpux*) + + # From the cc(1) man page: "[-mt] Sets various -D flags to enable + # multi-threading and also sets -lpthread." + + ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" + ;; + + openedition*) + + # IBM z/OS requires a feature-test macro to be defined in order to + # enable POSIX threads at all, so give the user a hint if this is + # not set. (We don't define these ourselves, as they can affect + # other portions of the system API in unpredictable ways.) + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) + AX_PTHREAD_ZOS_MISSING +# endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "AX_PTHREAD_ZOS_MISSING" >/dev/null 2>&1; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&5 +$as_echo "$as_me: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&2;} +fi +rm -f conftest* + + ;; + solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: + # tests will erroneously succeed. (N.B.: The stubs are missing + # pthread_cleanup_push, or rather a function called by this macro, + # so we could check for that, but who knows whether they'll stub + # that too in a future libc.) So we'll check first for the + # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" - ;; - - darwin*) - ax_pthread_flags="-pthread $ax_pthread_flags" + ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" ;; esac -if test x"$ax_pthread_ok" = xno; then -for flag in $ax_pthread_flags; do +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) - case $flag in +if test "x$GCC" = "xyes"; then : + ax_pthread_flags="-pthread -pthreads $ax_pthread_flags" +fi + +# The presence of a feature test macro requesting re-entrant function +# definitions is, on some systems, a strong hint that pthreads support is +# correctly enabled + +case $host_os in + darwin* | hpux* | linux* | osf* | solaris*) + ax_pthread_check_macro="_REENTRANT" + ;; + + aix*) + ax_pthread_check_macro="_THREAD_SAFE" + ;; + + *) + ax_pthread_check_macro="--" + ;; +esac +if test "x$ax_pthread_check_macro" = "x--"; then : + ax_pthread_check_cond=0 +else + ax_pthread_check_cond="!defined($ax_pthread_check_macro)" +fi + +# Are we compiling with Clang? + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC is Clang" >&5 +$as_echo_n "checking whether $CC is Clang... " >&6; } +if ${ax_cv_PTHREAD_CLANG+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "AX_PTHREAD_CC_IS_CLANG" >/dev/null 2>&1; then : + ax_cv_PTHREAD_CLANG=yes +fi +rm -f conftest* + + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG" >&5 +$as_echo "$ax_cv_PTHREAD_CLANG" >&6; } +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + +ax_pthread_clang_warning=no + +# Clang needs special handling, because older versions handle the -pthread +# option in a rather... idiosyncratic way + +if test "x$ax_pthread_clang" = "xyes"; then + + # Clang takes -pthread; it has never supported any other flag + + # (Note 1: This will need to be revisited if a system that Clang + # supports has POSIX threads in a separate library. This tends not + # to be the way of modern systems, but it's conceivable.) + + # (Note 2: On some systems, notably Darwin, -pthread is not needed + # to get POSIX threads support; the API is always present and + # active. We could reasonably leave PTHREAD_CFLAGS empty. But + # -pthread does define _REENTRANT, and while the Darwin headers + # ignore this macro, third-party headers might not.) + + PTHREAD_CFLAGS="-pthread" + PTHREAD_LIBS= + + ax_pthread_ok=yes + + # However, older versions of Clang make a point of warning the user + # that, in an invocation where only linking and no compilation is + # taking place, the -pthread option has no effect ("argument unused + # during compilation"). They expect -pthread to be passed in only + # when source code is being compiled. + # + # Problem is, this is at odds with the way Automake and most other + # C build frameworks function, which is that the same flags used in + # compilation (CFLAGS) are also used in linking. Many systems + # supported by AX_PTHREAD require exactly this for POSIX threads + # support, and in fact it is often not straightforward to specify a + # flag that is used only in the compilation phase and not in + # linking. Such a scenario is extremely rare in practice. + # + # Even though use of the -pthread flag in linking would only print + # a warning, this can be a nuisance for well-run software projects + # that build with -Werror. So if the active version of Clang has + # this misfeature, we search for an option to squash it. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread" >&5 +$as_echo_n "checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread... " >&6; } +if ${ax_cv_PTHREAD_CLANG_NO_WARN_FLAG+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown + # Create an alternate version of $ac_link that compiles and + # links in two steps (.c -> .o, .o -> exe) instead of one + # (.c -> exe), because the warning occurs only in the second + # step + ax_pthread_save_ac_link="$ac_link" + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' + ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" + ax_pthread_save_CFLAGS="$CFLAGS" + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do + if test "x$ax_pthread_try" = "xunknown"; then : + break +fi + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" + ac_link="$ax_pthread_save_ac_link" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(void){return 0;} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_link="$ax_pthread_2step_ac_link" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(void){return 0;} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done + ac_link="$ax_pthread_save_ac_link" + CFLAGS="$ax_pthread_save_CFLAGS" + if test "x$ax_pthread_try" = "x"; then : + ax_pthread_try=no +fi + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&5 +$as_echo "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&6; } + + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in + no | unknown) ;; + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; + esac + +fi # $ax_pthread_clang = yes + +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; + -mt,pthread) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with -mt -lpthread" >&5 +$as_echo_n "checking whether pthreads work with -mt -lpthread... " >&6; } + PTHREAD_CFLAGS="-mt" + PTHREAD_LIBS="-lpthread" + ;; + -*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 -$as_echo_n "checking whether pthreads work with $flag... " >&6; } - PTHREAD_CFLAGS="$flag" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $ax_pthread_try_flag" >&5 +$as_echo_n "checking whether pthreads work with $ax_pthread_try_flag... " >&6; } + PTHREAD_CFLAGS="$ax_pthread_try_flag" ;; pthread-config) @@ -5685,22 +5963,24 @@ $as_echo "no" >&6; } fi - if test x"$ax_pthread_config" = xno; then continue; fi + if test "x$ax_pthread_config" = "xno"; then : + continue +fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 -$as_echo_n "checking for the pthreads library -l$flag... " >&6; } - PTHREAD_LIBS="-l$flag" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$ax_pthread_try_flag" >&5 +$as_echo_n "checking for the pthreads library -l$ax_pthread_try_flag... " >&6; } + PTHREAD_LIBS="-l$ax_pthread_try_flag" ;; esac - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we @@ -5711,9 +5991,13 @@ $as_echo_n "checking for the pthreads library -l$flag... " >&6; } # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; } int @@ -5735,14 +6019,14 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } - if test "x$ax_pthread_ok" = xyes; then - break; - fi + if test "x$ax_pthread_ok" = "xyes"; then : + break +fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" @@ -5750,74 +6034,82 @@ done fi # Various other checks: -if test "x$ax_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" +if test "x$ax_pthread_ok" = "xyes"; then + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +if ${ax_cv_PTHREAD_JOINABLE_ATTR+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_PTHREAD_JOINABLE_ATTR=unknown + for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { -int attr = $attr; return attr /* ; */ +int attr = $ax_pthread_attr; return attr /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - attr_name=$attr; break + ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - done - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 -$as_echo "$attr_name" >&6; } - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_JOINABLE_ATTR" >&5 +$as_echo "$ax_cv_PTHREAD_JOINABLE_ATTR" >&6; } + if test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ + test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ + test "x$ax_pthread_joinable_attr_defined" != "xyes"; then : cat >>confdefs.h <<_ACEOF -#define PTHREAD_CREATE_JOINABLE $attr_name +#define PTHREAD_CREATE_JOINABLE $ax_cv_PTHREAD_JOINABLE_ATTR _ACEOF - fi + ax_pthread_joinable_attr_defined=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 -$as_echo_n "checking if more special flags are required for pthreads... " >&6; } - flag=no - case ${host_os} in - aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; - osf* | hpux*) flag="-D_REENTRANT";; - solaris*) - if test "$GCC" = "yes"; then - flag="-D_REENTRANT" - else - flag="-mt -D_REENTRANT" - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 -$as_echo "${flag}" >&6; } - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether more special flags are required for pthreads" >&5 +$as_echo_n "checking whether more special flags are required for pthreads... " >&6; } +if ${ax_cv_PTHREAD_SPECIAL_FLAGS+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_PTHREAD_SPECIAL_FLAGS=no + case $host_os in + solaris*) + ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" + ;; + esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_SPECIAL_FLAGS" >&5 +$as_echo "$ax_cv_PTHREAD_SPECIAL_FLAGS" >&6; } + if test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ + test "x$ax_pthread_special_flags_added" != "xyes"; then : + PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" + ax_pthread_special_flags_added=yes +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : $as_echo_n "(cached) " >&6 else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - - #include +#include int main () { @@ -5837,18 +6129,32 @@ rm -f core conftest.err conftest.$ac_objext \ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 $as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } - if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then : + if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ + test "x$ax_pthread_prio_inherit_defined" != "xyes"; then : $as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h + ax_pthread_prio_inherit_defined=yes + fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - for ac_prog in xlc_r cc_r + # More AIX lossage: compile with *_r variant + if test "x$GCC" != "xyes"; then + case $host_os in + aix*) + case "x/$CC" in #( + x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6) : + #handle absolute path differently from PATH based program lookup + case "x$CC" in #( + x/*) : + if as_fn_executable_p ${CC}_r; then : + PTHREAD_CC="${CC}_r" +fi ;; #( + *) : + for ac_prog in ${CC}_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -5889,21 +6195,25 @@ fi test -n "$PTHREAD_CC" && break done -test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" - - else - PTHREAD_CC=$CC +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + ;; +esac ;; #( + *) : + ;; +esac + ;; + esac fi -else - PTHREAD_CC="$CC" fi +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$ax_pthread_ok" = xyes; then +if test "x$ax_pthread_ok" = "xyes"; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h @@ -7406,7 +7716,7 @@ esac fi : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} @@ -7907,11 +8217,8 @@ _LT_EOF test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -9130,8 +9437,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR cr libconftest.a conftest.o" >&5 + $AR cr libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -9163,11 +9470,11 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + 10.0,*86*-darwin8*|10.0,*-darwin[912]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012][,.]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) + 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; @@ -9992,6 +10299,12 @@ lt_prog_compiler_static= lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -14825,7 +15138,7 @@ fi # disable libudev check is USB is not used -if test "$use_usb" == "no"; then +if test "$use_usb" = "no"; then use_libudev="no" fi @@ -14982,7 +15295,7 @@ fi # disable libusb check is USB is not used -if test "$use_usb" == "no"; then +if test "$use_usb" = "no"; then use_libusb="no" fi @@ -15385,34 +15698,15 @@ if test x${usbdropdir} = xfalse ; then usbdropdir="$ac_default_libdir/pcsc/drivers" fi fi - - EXP_VAR=usbdropdir_exp - FROM_VAR=$usbdropdir - - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - full_var=$new_full_var - usbdropdir_exp="$full_var" - - - prefix=$prefix_save - exec_prefix=$exec_prefix_save - +_lcl_receval="$usbdropdir" +usbdropdir_exp=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "$_lcl_receval_old" != "$_lcl_receval"; do + _lcl_receval_old="$_lcl_receval" + eval _lcl_receval="\"$_lcl_receval\"" + done + echo "$_lcl_receval")` usbdropdir=$usbdropdir_exp cat >>confdefs.h <<_ACEOF @@ -15493,90 +15787,24 @@ fi - - EXP_VAR=confdir_exp - FROM_VAR=$confdir - - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - full_var=$new_full_var - confdir_exp="$full_var" - - - prefix=$prefix_save - exec_prefix=$exec_prefix_save - - - EXP_VAR=sbindir_exp - FROM_VAR=$sbindir - - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - full_var=$new_full_var - sbindir_exp="$full_var" - - - prefix=$prefix_save - exec_prefix=$exec_prefix_save - - - EXP_VAR=localstatedir_exp - FROM_VAR=$localstatedir - - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - full_var=$new_full_var - localstatedir_exp="$full_var" - - - prefix=$prefix_save - exec_prefix=$exec_prefix_save - +_lcl_receval="$confdir" +confdir_exp=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "$_lcl_receval_old" != "$_lcl_receval"; do + _lcl_receval_old="$_lcl_receval" + eval _lcl_receval="\"$_lcl_receval\"" + done + echo "$_lcl_receval")` +_lcl_receval="$sbindir" +sbindir_exp=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "$_lcl_receval_old" != "$_lcl_receval"; do + _lcl_receval_old="$_lcl_receval" + eval _lcl_receval="\"$_lcl_receval\"" + done + echo "$_lcl_receval")` PCSCLITE_CONFIG_DIR="${confdir_exp}" @@ -15586,22 +15814,15 @@ cat >>confdefs.h <<_ACEOF #define PCSCLITE_FEATURES "${PCSCLITE_FEATURES}" _ACEOF -PCSCD_BINARY="${sbindir_exp}/pcscd" - -cat >>confdefs.h <<_ACEOF -#define PCSCD_BINARY "$PCSCD_BINARY" -_ACEOF - cat << EOF PC/SC lite has been configured with following options: Version: ${PACKAGE_VERSION} -System binaries: $(eval eval eval echo "${sbindir_exp}") +System binaries: ${sbindir_exp} Configuration dir: ${PCSCLITE_CONFIG_DIR} - Host: ${host} Compiler: ${CC} Preprocessor flags: ${CPPFLAGS} @@ -15614,7 +15835,6 @@ PTHREAD_CFLAGS: ${PTHREAD_CFLAGS} PTHREAD_LIBS: ${PTHREAD_LIBS} PCSC_ARCH: ${PCSC_ARCH} -pcscd binary ${PCSCD_BINARY} polkit support: ${use_polkit} polkit policy dir: ${polkit_policy_dir} libudev support: ${use_libudev} @@ -16192,7 +16412,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pcsc-lite $as_me 1.9.1, which was +This file was extended by pcsc-lite $as_me 1.9.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16258,7 +16478,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pcsc-lite config.status 1.9.1 +pcsc-lite config.status 1.9.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 6b6ca79..298a18c 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.69]) -AC_INIT([pcsc-lite],[1.9.1]) +AC_INIT([pcsc-lite],[1.9.2]) AC_CONFIG_SRCDIR(src/pcscdaemon.c) AM_INIT_AUTOMAKE(1.8 dist-bzip2 no-dist-gzip) AC_CONFIG_HEADERS([config.h]) @@ -198,7 +198,7 @@ AC_ARG_ENABLE(libudev, fi ]) # disable libudev check is USB is not used -if test "$use_usb" == "no"; then +if test "$use_usb" = "no"; then use_libudev="no" fi @@ -244,7 +244,7 @@ AC_ARG_ENABLE(libusb, else use_libusb="${use_libusb-yes}" ; fi ] ) # disable libusb check is USB is not used -if test "$use_usb" == "no"; then +if test "$use_usb" = "no"; then use_libusb="no" fi @@ -350,7 +350,7 @@ if test x${usbdropdir} = xfalse ; then usbdropdir="$ac_default_libdir/pcsc/drivers" fi fi -AS_AC_EXPAND(usbdropdir_exp,$usbdropdir) +AX_RECURSIVE_EVAL($usbdropdir,usbdropdir_exp) usbdropdir=$usbdropdir_exp AC_DEFINE_UNQUOTED(PCSCLITE_HP_DROPDIR, "$usbdropdir", [directory containing USB drivers]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} usbdropdir=${usbdropdir}" @@ -406,26 +406,22 @@ AC_SUBST(ipcdir) AC_SUBST(serialconfdir) AC_SUBST(host_to_ccid_16) AC_SUBST(host_to_ccid_32) -AS_AC_EXPAND(confdir_exp,$confdir) -AS_AC_EXPAND(sbindir_exp,$sbindir) -AS_AC_EXPAND(localstatedir_exp,$localstatedir) +AX_RECURSIVE_EVAL($confdir,confdir_exp) +AX_RECURSIVE_EVAL($sbindir,sbindir_exp) PCSCLITE_CONFIG_DIR="${confdir_exp}" AC_SUBST(PCSCLITE_CONFIG_DIR) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} configdir=${PCSCLITE_CONFIG_DIR}" AC_DEFINE_UNQUOTED([PCSCLITE_FEATURES], ["${PCSCLITE_FEATURES}"], [Enabled PC/SC lite features]) -PCSCD_BINARY="${sbindir_exp}/pcscd" -AC_DEFINE_UNQUOTED([PCSCD_BINARY], ["$PCSCD_BINARY"], [pcscd filename]) cat << EOF PC/SC lite has been configured with following options: Version: ${PACKAGE_VERSION} -System binaries: $(eval eval eval echo "${sbindir_exp}") +System binaries: ${sbindir_exp} Configuration dir: ${PCSCLITE_CONFIG_DIR} - Host: ${host} Compiler: ${CC} Preprocessor flags: ${CPPFLAGS} @@ -438,7 +434,6 @@ PTHREAD_CFLAGS: ${PTHREAD_CFLAGS} PTHREAD_LIBS: ${PTHREAD_LIBS} PCSC_ARCH: ${PCSC_ARCH} -pcscd binary ${PCSCD_BINARY} polkit support: ${use_polkit} polkit policy dir: ${polkit_policy_dir} libudev support: ${use_libudev} diff --git a/doc/Makefile.in b/doc/Makefile.in index d3a64df..62c14a2 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -92,8 +92,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = doc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -329,7 +328,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir_exp = @confdir_exp@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -351,7 +349,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -localstatedir_exp = @localstatedir_exp@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -361,7 +358,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ -sbindir_exp = @sbindir_exp@ serialconfdir = @serialconfdir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -372,7 +368,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ usbdropdir = @usbdropdir@ -usbdropdir_exp = @usbdropdir_exp@ SUBDIRS = . example doc_DATA = \ README.polkit diff --git a/doc/example/Makefile.in b/doc/example/Makefile.in index 21d4662..58ba521 100644 --- a/doc/example/Makefile.in +++ b/doc/example/Makefile.in @@ -93,8 +93,7 @@ host_triplet = @host@ noinst_PROGRAMS = pcsc_demo$(EXEEXT) subdir = doc/example ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -287,7 +286,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir_exp = @confdir_exp@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -309,7 +307,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -localstatedir_exp = @localstatedir_exp@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -319,7 +316,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ -sbindir_exp = @sbindir_exp@ serialconfdir = @serialconfdir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -330,7 +326,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ usbdropdir = @usbdropdir@ -usbdropdir_exp = @usbdropdir_exp@ pcsc_demo_SOURCES = pcsc_demo.c pcsc_demo_CFLAGS = -I$(top_srcdir)/src/PCSC -I$(top_builddir)/src/PCSC pcsc_demo_LDADD = $(top_builddir)/src/libpcsclite.la diff --git a/doc/example/pcsc_demo.c b/doc/example/pcsc_demo.c index 1a98f26..c811b95 100644 --- a/doc/example/pcsc_demo.c +++ b/doc/example/pcsc_demo.c @@ -3,21 +3,31 @@ * * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ ) * - * Copyright (C) 2003-2011 + * Copyright (C) 2003-2021 * 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 3 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, see . +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. */ #include @@ -26,13 +36,7 @@ #include #include -#include -#include - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif +#include /* PCSC error message pretty print */ #define PCSC_ERROR(rv, text) \ diff --git a/doc/pcscd.8.in b/doc/pcscd.8.in index 81475ba..ce2983f 100644 --- a/doc/pcscd.8.in +++ b/doc/pcscd.8.in @@ -14,7 +14,7 @@ log APDUs and SW using the debug method (see .TP .BR \-c ", " \-\-config " \fIfile\fP" Specifies the file \fIfile\fP as an alternate location for -.IR @confdir_exp@/reader.conf . +.IR @PCSCLITE_CONFIG_DIR@/reader.conf . .TP .BR \-f ", " \-\-foreground Runs pcscd in the foreground and sends log messages to stderr instead of @@ -68,7 +68,7 @@ Displays the program version number .TP .BR \-H ", " \-\-hotplug Ask pcscd to re-read the -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf file to detect added or removed non-USB readers (serial or PCMCIA). . .TP @@ -98,7 +98,7 @@ Smart card reader drivers are placed in the directory. Each driver is simply an .I .so file. pcscd locates the driver using the -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf file. See the .BR reader.conf (5) manual page for more information. @@ -109,11 +109,11 @@ Some drivers are available at \fIhttps://muscle.apdu.fr/musclecard.com/drivers.h USB smart card reader drivers are located in .I @usbdropdir@ directory as a bundle. You shall not add a USB driver in -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf file. . .SH FILES -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf : Reader configuration file .PP .I @ipcdir@/pcscd.pid diff --git a/doc/reader.conf.5.in b/doc/reader.conf.5.in index 7973e6b..b86f92f 100644 --- a/doc/reader.conf.5.in +++ b/doc/reader.conf.5.in @@ -4,7 +4,7 @@ reader.conf \- configuration file for pcscd readers' drivers . .SH DESCRIPTION The -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf file contains configuration information for serial and (some) PCMCIA smart card readers. .PP @@ -14,7 +14,7 @@ uses another mechanism to automatically load USB drivers. . .SH SYNTAX The -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf is a regular text file. Each reader must be defined by four fields: .PP FRIENDLYNAME TEXT_STRING @@ -57,7 +57,7 @@ serial port number for a serial reader. . .SH DEBUGGING In order to set up your -.I @confdir_exp@/reader.conf +.I @PCSCLITE_CONFIG_DIR@/reader.conf file correctly you may want to have debug messages from .BR pcscd . I recommend you to start diff --git a/etc/Makefile.in b/etc/Makefile.in index d81f831..05b55d7 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -90,8 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = etc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -262,7 +261,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir_exp = @confdir_exp@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -284,7 +282,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -localstatedir_exp = @localstatedir_exp@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -294,7 +291,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ -sbindir_exp = @sbindir_exp@ serialconfdir = @serialconfdir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -305,7 +301,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ usbdropdir = @usbdropdir@ -usbdropdir_exp = @usbdropdir_exp@ @HAVE_SYSTEMD_TRUE@SCRIPT_IN_FILES = \ @HAVE_SYSTEMD_TRUE@ pcscd.service.in \ @HAVE_SYSTEMD_TRUE@ pcscd.socket.in diff --git a/etc/pcscd.service.in b/etc/pcscd.service.in index eb093de..65ad6a6 100644 --- a/etc/pcscd.service.in +++ b/etc/pcscd.service.in @@ -4,8 +4,9 @@ Requires=pcscd.socket Documentation=man:pcscd(8) [Service] -ExecStart=@sbindir_exp@/pcscd --foreground --auto-exit +ExecStart=@sbindir_exp@/pcscd --foreground --auto-exit $PCSCD_ARGS ExecReload=@sbindir_exp@/pcscd --hotplug +EnvironmentFile=-@sysconfdir@/default/pcscd [Install] Also=pcscd.socket diff --git a/m4/as-ac-expand.m4 b/m4/as-ac-expand.m4 deleted file mode 100644 index d6c9e33..0000000 --- a/m4/as-ac-expand.m4 +++ /dev/null @@ -1,43 +0,0 @@ -dnl as-ac-expand.m4 0.2.0 -dnl autostars m4 macro for expanding directories using configure's prefix -dnl thomas@apestaart.org - -dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) -dnl example -dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) -dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local - -AC_DEFUN([AS_AC_EXPAND], -[ - EXP_VAR=[$1] - FROM_VAR=[$2] - - dnl first expand prefix and exec_prefix if necessary - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - dnl if no prefix given, then use /usr/local, the default prefix - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - dnl if no exec_prefix given, then use prefix - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - dnl loop until it doesn't change anymore - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - dnl clean up - full_var=$new_full_var - AC_SUBST([$1], "$full_var") - - dnl restore prefix and exec_prefix - prefix=$prefix_save - exec_prefix=$exec_prefix_save -]) diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 deleted file mode 100644 index d90de34..0000000 --- a/m4/ax_pthread.m4 +++ /dev/null @@ -1,309 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_pthread.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -# -# DESCRIPTION -# -# This macro figures out how to build C programs using POSIX threads. It -# sets the PTHREAD_LIBS output variable to the threads library and linker -# flags, and the PTHREAD_CFLAGS output variable to any special C compiler -# flags that are needed. (The user can also force certain compiler -# flags/libs to be tested by setting these environment variables.) -# -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) -# -# NOTE: You are assumed to not only compile your program with these flags, -# but also link it with them as well. e.g. you should link with -# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS -# -# If you are only building threads programs, you may wish to use these -# variables in your default LIBS, CFLAGS, and CC: -# -# LIBS="$PTHREAD_LIBS $LIBS" -# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -# CC="$PTHREAD_CC" -# -# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant -# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name -# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -# -# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the -# PTHREAD_PRIO_INHERIT symbol is defined when compiling with -# PTHREAD_CFLAGS. -# -# ACTION-IF-FOUND is a list of shell commands to run if a threads library -# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it -# is not found. If ACTION-IF-FOUND is not specified, the default action -# will define HAVE_PTHREAD. -# -# Please let the authors know if this macro fails on any platform, or if -# you have any other suggestions or comments. This macro was based on work -# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help -# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by -# Alejandro Forero Cuervo to the autoconf macro repository. We are also -# grateful for the helpful feedback of numerous users. -# -# Updated for Autoconf 2.68 by Daniel Richard G. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2011 Daniel Richard G. -# -# 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 3 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, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 18 - -AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) -AC_DEFUN([AX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_PUSH([C]) -ax_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) - AC_MSG_RESULT($ax_pthread_ok) - if test x"$ax_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case ${host_os} in - solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" - ;; - - darwin*) - ax_pthread_flags="-pthread $ax_pthread_flags" - ;; -esac - -if test x"$ax_pthread_ok" = xno; then -for flag in $ax_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - pthread-config) - AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) - if test x"$ax_pthread_config" = xno; then continue; fi - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($ax_pthread_ok) - if test "x$ax_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$ax_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_MSG_CHECKING([for joinable pthread attribute]) - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], - [int attr = $attr; return attr /* ; */])], - [attr_name=$attr; break], - []) - done - AC_MSG_RESULT($attr_name) - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case ${host_os} in - aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; - osf* | hpux*) flag="-D_REENTRANT";; - solaris*) - if test "$GCC" = "yes"; then - flag="-D_REENTRANT" - else - flag="-mt -D_REENTRANT" - fi - ;; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], - ax_cv_PTHREAD_PRIO_INHERIT, [ - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], - [ax_cv_PTHREAD_PRIO_INHERIT=yes], - [ax_cv_PTHREAD_PRIO_INHERIT=no]) - ]) - AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], - AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) - else - PTHREAD_CC=$CC - fi -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$ax_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - ax_pthread_ok=no - $2 -fi -AC_LANG_POP -])dnl AX_PTHREAD diff --git a/m4/libtool.m4 b/m4/libtool.m4 index ee80844..c4c0294 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1041,8 +1041,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1071,11 +1071,11 @@ _LT_EOF # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) + 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; @@ -1492,7 +1492,7 @@ need_locks=$enable_libtool_lock m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) @@ -4063,7 +4063,8 @@ _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -4703,6 +4704,12 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -6438,7 +6445,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no @@ -6813,7 +6820,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -6878,7 +6885,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -7217,7 +7224,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support @@ -7301,7 +7308,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -7312,7 +7319,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' diff --git a/src/Makefile.in b/src/Makefile.in index 0963030..5c1aca4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -96,8 +96,7 @@ noinst_PROGRAMS = testpcsc$(EXEEXT) pcsc-wirecheck$(EXEEXT) \ pcsc-wirecheck-gen$(EXEEXT) subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -463,7 +462,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir_exp = @confdir_exp@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -485,7 +483,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -localstatedir_exp = @localstatedir_exp@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -495,7 +492,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ -sbindir_exp = @sbindir_exp@ serialconfdir = @serialconfdir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -506,7 +502,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ usbdropdir = @usbdropdir@ -usbdropdir_exp = @usbdropdir_exp@ SUBDIRS = spy AM_CPPFLAGS = -I$(top_srcdir)/src/PCSC -I$(top_builddir)/src/PCSC \ $(SYMBOL_VISIBILITY) diff --git a/src/PCSC/pcsclite.h b/src/PCSC/pcsclite.h index 332773a..5a60470 100644 --- a/src/PCSC/pcsclite.h +++ b/src/PCSC/pcsclite.h @@ -279,7 +279,7 @@ extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci; #define INFINITE 0xFFFFFFFF /**< Infinite timeout */ #endif -#define PCSCLITE_VERSION_NUMBER "1.9.1" /**< Current version */ +#define PCSCLITE_VERSION_NUMBER "1.9.2" /**< Current version */ /** Maximum readers context (a slot is count as a reader) */ #define PCSCLITE_MAX_READERS_CONTEXTS 16 diff --git a/src/PCSC/reader.h b/src/PCSC/reader.h index 7c8a802..f00eed7 100644 --- a/src/PCSC/reader.h +++ b/src/PCSC/reader.h @@ -150,7 +150,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Set structure elements aligment on bytes * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */ -#if defined(__APPLE__) | defined(sun) +#if defined(__APPLE__) || defined(sun) || defined(__NetBSD__) #pragma pack(1) #else #pragma pack(push, 1) @@ -247,7 +247,7 @@ typedef struct { } PIN_PROPERTIES_STRUCTURE; /* restore default structure elements alignment */ -#if defined(__APPLE__) | defined(sun) +#if defined(__APPLE__) || defined(sun) || defined(__NetBSD__) #pragma pack() #else #pragma pack(pop) diff --git a/src/hotplug_libudev.c b/src/hotplug_libudev.c index 25bd408..6364224 100644 --- a/src/hotplug_libudev.c +++ b/src/hotplug_libudev.c @@ -46,6 +46,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "debuglog.h" #include "parser.h" @@ -481,15 +482,26 @@ static void HPAddDevice(struct udev_device *dev) { char *result; + char *tmpInterfaceName = strdup(sInterfaceName); + + /* check the interface name contains only valid ASCII codes */ + for (size_t i=0; i $@ -framework: - rm -rf PCSC.framework - mkdir -p PCSC.framework/Versions/A - cp .libs/libpcscspy.dylib PCSC.framework/Versions/A/PCSC - ln -s Versions/Current/PCSC PCSC.framework - ln -s A PCSC.framework/Versions/Current - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/spy/libpcscspy.c b/src/spy/libpcscspy.c index 5abf4c9..db1663c 100644 --- a/src/spy/libpcscspy.c +++ b/src/spy/libpcscspy.c @@ -32,14 +32,6 @@ #define DEBUG -#ifdef __APPLE__ -#define SCardControl SCardControl132 - -PCSC_API int32_t SCardControl132(SCARDHANDLE hCard, uint32_t dwControlCode, - const void *pbSendBuffer, uint32_t cbSendLength, - void *pbRecvBuffer, uint32_t cbRecvLength, uint32_t *lpBytesReturned); -#endif - /* function prototypes */ #define p_SCardEstablishContext(fct) LONG(fct)(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) @@ -335,19 +327,8 @@ static void spy_readerstate(SCARD_READERSTATE * rgReaderStates, int cReaders) static LONG load_lib(void) { -#ifdef __APPLE__ -/* We should be able to directly use this - * #define LIBPCSC_NOSPY "/System/Library/Frameworks/PCSC.framework/PCSC" - * but for a yet unknown reason the dlsym() returns symbols from the spy - * library and not from the framework. - * Just copying the framework in /tmp does solve the problem. - */ -#define LIBPCSC_NOSPY "/tmp/PCSC" -#define LIBPCSC "/tmp/PCSC" -#else #define LIBPCSC_NOSPY "libpcsclite_nospy.so.1" #define LIBPCSC "libpcsclite.so.1" -#endif /* first try to load the NOSPY library * this is used for programs doing an explicit dlopen like diff --git a/src/spy/pcsc-spy b/src/spy/pcsc-spy index 85222c6..9b2da79 100755 --- a/src/spy/pcsc-spy +++ b/src/spy/pcsc-spy @@ -1,8 +1,8 @@ -#! /usr/bin/python +#! /usr/bin/python3 """ # Display PC/SC functions arguments -# Copyright (C) 2011-2012 Ludovic Rousseau +# Copyright (C) 2011-2021 Ludovic Rousseau """ # # This program is free software: you can redistribute it and/or modify @@ -18,7 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import print_function import os import signal import time @@ -65,6 +64,9 @@ def _parse_rv(line): return (code, rv, sec, usec) +class SpyExit(Exception): + pass + class StatRecord(object): """ Record to store statistics """ @@ -87,9 +89,15 @@ class PCSCspy(object): color_magenta = "\x1b[35m" color_normal = "\x1b[0m" + def get_line(self): + line = self.queue.get() + if line == "EXIT": + raise SpyExit() + return line + def _log_rv(self): """ log the return value """ - line = self.queue.get() + line = self.get_line() (code, rv, sec, usec) = _parse_rv(line) delta_sec = sec - self.sec delta_usec = usec - self.usec @@ -205,7 +213,7 @@ class PCSCspy(object): def log_in_hCard(self): """ log hCard IN parameter """ - hCard = self.queue.get() + hCard = self.get_line() if self.diffable: self.log_in("hCard: 0x????") else: @@ -213,7 +221,7 @@ class PCSCspy(object): def log_in_hContext(self): """ log hContext IN parameter """ - hContext = self.queue.get() + hContext = self.get_line() if self.diffable: self.log_in("hContext: 0x????") else: @@ -221,7 +229,7 @@ class PCSCspy(object): def log_in_disposition(self): """ log dwDisposition IN parameter """ - dwDisposition = self.queue.get() + dwDisposition = self.get_line() dispositions = {0: 'SCARD_LEAVE_CARD', 1: 'SCARD_RESET_CARD', 2: 'SCARD_UNPOWER_CARD', @@ -235,7 +243,7 @@ class PCSCspy(object): def log_in_attrid(self): """ log dwAttrId IN parameter """ - dwAttrId = self.queue.get() + dwAttrId = self.get_line() attrids = {0x00010100: 'SCARD_ATTR_VENDOR_NAME', 0x00010102: 'SCARD_ATTR_VENDOR_IFD_VERSION', 0x00010103: 'SCARD_ATTR_VENDOR_IFD_SERIAL_NO', @@ -255,7 +263,7 @@ class PCSCspy(object): def log_in_dwShareMode(self): """ log dwShareMode IN parameter """ - dwShareMode = self.queue.get() + dwShareMode = self.get_line() sharemodes = {1: 'SCARD_SHARE_EXCLUSIVE', 2: 'SCARD_SHARE_SHARED', 3: 'SCARD_SHARE_DIRECT'} @@ -267,7 +275,7 @@ class PCSCspy(object): def log_in_dwPreferredProtocols(self): """ log dwPreferredProtocols IN parameter """ - dwPreferredProtocols = self.queue.get() + dwPreferredProtocols = self.get_line() PreferredProtocols = list() protocol = int(dwPreferredProtocols, 16) if protocol & 1: @@ -283,7 +291,7 @@ class PCSCspy(object): def log_out_dwActiveProtocol(self): """ log dwActiveProtocol OUT parameter """ - dwActiveProtocol = self.queue.get() + dwActiveProtocol = self.get_line() protocol = int(dwActiveProtocol, 16) if protocol & 1: protocol = "T=0" @@ -300,7 +308,7 @@ class PCSCspy(object): def log_out_hContext(self): """ log hContext OUT parameter """ - hContext = self.queue.get() + hContext = self.get_line() if self.diffable: self.log_out("hContext: 0x????") else: @@ -329,19 +337,19 @@ class PCSCspy(object): def log_dwCurrentState(self, log): """ log dwCurrentState IN/OUT parameter """ - dwCurrentState = self.queue.get() + dwCurrentState = self.get_line() state = self._get_state(int(dwCurrentState, 16)) log(" dwCurrentState: %s (%s)" % (state, dwCurrentState)) def log_dwEventState(self, log): """ log dwEventState IN/OUT parameter """ - dwEventState = self.queue.get() + dwEventState = self.get_line() state = self._get_state(int(dwEventState, 16)) log(" dwEventState: %s (%s)" % (state, dwEventState)) def log_dwControlCode(self): """ log SCardControl() dwControlCode """ - dwControlCode = self.queue.get() + dwControlCode = self.get_line() try: code = self.ControlCodes[int(dwControlCode, 16)] @@ -353,7 +361,7 @@ class PCSCspy(object): def log_in2(self, header): """ generic log IN parameter """ - data = self.queue.get() + data = self.get_line() if data.startswith("0x"): decimal = int(data, 16) self.log_in("%s %s (%d)" % (header, data, decimal)) @@ -363,9 +371,7 @@ class PCSCspy(object): def log_out2(self, header): """ generic log OUT parameter """ - data = self.queue.get() - if data == "EXIT": - raise Exception("Exit") + data = self.get_line() if data.startswith("0x"): decimal = int(data, 16) self.log_out("%s %s (%d)" % (header, data, decimal)) @@ -375,16 +381,16 @@ class PCSCspy(object): def log_out_n_str(self, size_name, field_name): """ log multi-lines entries """ - data = self.queue.get() + data = self.get_line() self.log_out("%s %s" % (size_name, data)) size = int(data, 16) data_read = 0 if 0 == size: - data = self.queue.get() + data = self.get_line() self.log_out("%s %s" % (field_name, data)) else: while data_read < size: - data = self.queue.get() + data = self.get_line() self.log_out("%s %s" % (field_name, data)) if data == 'NULL': break @@ -419,7 +425,7 @@ class PCSCspy(object): log = self.log_out log_multi = self.log_out_multi - hex_buffer = self.queue.get() + hex_buffer = self.get_line() log(field) if hex_buffer == "NULL": log(" NULL") @@ -433,7 +439,7 @@ class PCSCspy(object): def _SCardEstablishContext(self): """ SCardEstablishContext """ self.log_name("SCardEstablishContext") - dwScope = self.queue.get() + dwScope = self.get_line() scopes = {0: 'SCARD_SCOPE_USER', 1: 'SCARD_SCOPE_TERMINAL', 2: 'SCARD_SCOPE_SYSTEM'} @@ -474,7 +480,7 @@ class PCSCspy(object): self.log_name("SCardGetStatusChange") self.log_in_hContext() self.log_in2("dwTimeout:") - readers = int(self.queue.get(), 16) + readers = int(self.get_line(), 16) self.log_in("cReaders: %d" % readers) self._log_readers(readers, direction="in") self._log_readers(readers, direction="out") @@ -703,7 +709,9 @@ class PCSCspy(object): self.color = color self.diffable = diffable self.stats = stats - self.indent = " " * indent + self.indent = " " * (indent * 4) + if display_thread: + self.indent += " (t%d) " % indent self.features = {0x01: "FEATURE_VERIFY_PIN_START", 0x02: "FEATURE_VERIFY_PIN_FINISH", @@ -747,48 +755,51 @@ class PCSCspy(object): else: print("Garbage: ", line) else: - # dispatch - (direction, sec, usec, fct) = line.strip().split('|') - self.sec = int(sec) - self.usec = int(usec) - if fct == 'SCardEstablishContext': - self._SCardEstablishContext() - elif fct == 'SCardReleaseContext': - self._SCardReleaseContext() - elif fct == 'SCardIsValidContext': - self._SCardIsValidContext() - elif fct == 'SCardListReaderGroups': - self._SCardListReaderGroups() - elif fct == 'SCardFreeMemory': - self._SCardFreeMemory() - elif fct == 'SCardListReaders': - self._SCardListReaders() - elif fct == 'SCardGetStatusChange': - self._SCardGetStatusChange() - elif fct == 'SCardConnect': - self._SCardConnect() - elif fct == 'SCardTransmit': - self._SCardTransmit() - elif fct == 'SCardControl' or fct == 'SCardControl132': - self._SCardControl() - elif fct == 'SCardGetAttrib': - self._SCardGetAttrib() - elif fct == 'SCardSetAttrib': - self._SCardSetAttrib() - elif fct == 'SCardStatus': - self._SCardStatus() - elif fct == 'SCardReconnect': - self._SCardReconnect() - elif fct == 'SCardDisconnect': - self._SCardDisconnect() - elif fct == 'SCardBeginTransaction': - self._SCardBeginTransaction() - elif fct == 'SCardEndTransaction': - self._SCardEndTransaction() - elif fct == 'SCardCancel': - self._SCardCancel() - else: - print("Unknown function:", fct) + try: + # dispatch + (direction, sec, usec, fct) = line.strip().split('|') + self.sec = int(sec) + self.usec = int(usec) + if fct == 'SCardEstablishContext': + self._SCardEstablishContext() + elif fct == 'SCardReleaseContext': + self._SCardReleaseContext() + elif fct == 'SCardIsValidContext': + self._SCardIsValidContext() + elif fct == 'SCardListReaderGroups': + self._SCardListReaderGroups() + elif fct == 'SCardFreeMemory': + self._SCardFreeMemory() + elif fct == 'SCardListReaders': + self._SCardListReaders() + elif fct == 'SCardGetStatusChange': + self._SCardGetStatusChange() + elif fct == 'SCardConnect': + self._SCardConnect() + elif fct == 'SCardTransmit': + self._SCardTransmit() + elif fct == 'SCardControl' or fct == 'SCardControl132': + self._SCardControl() + elif fct == 'SCardGetAttrib': + self._SCardGetAttrib() + elif fct == 'SCardSetAttrib': + self._SCardSetAttrib() + elif fct == 'SCardStatus': + self._SCardStatus() + elif fct == 'SCardReconnect': + self._SCardReconnect() + elif fct == 'SCardDisconnect': + self._SCardDisconnect() + elif fct == 'SCardBeginTransaction': + self._SCardBeginTransaction() + elif fct == 'SCardEndTransaction': + self._SCardEndTransaction() + elif fct == 'SCardCancel': + self._SCardCancel() + else: + print("Unknown function:", fct) + except SpyExit: + return try: record = self.stats[fct] @@ -810,7 +821,7 @@ class PCSCdemultiplexer(object): # create the FIFO file try: os.mkfifo(logfile) - except (OSError): + except OSError: print("fifo %s already present. Reusing it." % logfile) self.sec = self.usec = 0 @@ -866,7 +877,7 @@ class PCSCdemultiplexer(object): if previous_thread != thread: # schedule the other thread so it has time to empty its # queue - time.sleep(.01) + time.sleep(.001) try: queue = self.queues[thread] @@ -878,7 +889,7 @@ class PCSCdemultiplexer(object): color=self.color, diffable=self.diffable) threads[thread] = Thread(target=spy.worker) threads[thread].start() - indent += 4 + indent += 1 queue.put(tail) @@ -933,7 +944,7 @@ def signal_handler(sig, frame): def print_usage(): - print("Usage: pcsc-spy [-n|--nocolor] [-d|--diffable] [-h|--help] [-v|--version]") + print("Usage: pcsc-spy [-n|--nocolor] [-d|--diffable] [-h|--help] [-v|--version] [-t|--thread]") if __name__ == "__main__": import sys @@ -941,14 +952,15 @@ if __name__ == "__main__": logfile = None try: - opts, args = getopt.getopt(sys.argv[1:], "ndhv", ["nocolor", - "diffable", "help", "version"]) + opts, args = getopt.getopt(sys.argv[1:], "ndhvt", ["nocolor", + "diffable", "help", "version", "thread"]) except getopt.GetoptError: print_usage() sys.exit(1) color = True diffable = False + display_thread = False for o, a in opts: if o == "-n" or o == "--nocolor": color = False @@ -958,10 +970,12 @@ if __name__ == "__main__": print_usage() sys.exit(1) if o == "-v" or o == "--version": - print("pcsc-spy version 1.0") - print("Copyright (c) 2011-2012, Ludovic Rousseau ") + print("pcsc-spy version 1.1") + print("Copyright (c) 2011-2021, Ludovic Rousseau ") print() sys.exit(1) + if o == "-t" or o == "--thread": + display_thread = True if len(args) > 0: logfile = args[0] diff --git a/src/spy/pcsc-spy.pod b/src/spy/pcsc-spy.pod index be319fb..73eb6fc 100644 --- a/src/spy/pcsc-spy.pod +++ b/src/spy/pcsc-spy.pod @@ -5,7 +5,7 @@ pcsc-spy - A PC/SC spy command =head1 SYNOPSIS pcsc-spy [B<-n>|B<--nocolor>] [B<-d>|B<--diffable>] [B<-h>|B<--help>] -[F] +[B<-v>|B<--version>] [B<-t>|B<--thread>] [F] =head1 DESCRIPTION @@ -47,6 +47,11 @@ file for example). Print the version of the F program plus a copyright, a list of authors. +=item B<-t>, B<--thread> + +Add a thread number before each line of log to identify the calls from +the same threads. + =back =head1 EXAMPLES @@ -58,7 +63,7 @@ library. Example: - LD_PRELOAD=/usr/lib/libpcscspy.so pcsc_scan + LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpcscspy.so pcsc_scan =head2 Application loading libpcsclite.so.1 @@ -92,24 +97,6 @@ To create the log file just do: and run your PC/SC application. -=head2 Mac OS X - -The installation is not automatic. In the pcsc-lite/src/spy directory do: - - make framework - -Then copy the PCSC.framework directory in /tmp - - cp -a PCSC.framework /tmp - -Copy the official PCSC.framework (binary only) in /tmp - - cp /System/Library/Frameworks/PCSC.framework/PCSC /tmp - -Run the application to debug as: - - DYLD_FRAMEWORK_PATH=/tmp pcsctest - =head1 FILES F<~/pcsc-spy> FIFO file is used by F to send the raw diff --git a/src/utils.c b/src/utils.c index 5234f0b..2a3e5e6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -50,6 +50,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pcscd.h" #include "sys_generic.h" +#ifndef LIBPCSCLITE pid_t GetDaemonPid(void) { int fd; @@ -128,6 +129,7 @@ int CheckForOpenCT(void) return 0; } /* CheckForOpenCT */ +#endif /** * return the difference (as long int) in µs between 2 struct timeval @@ -147,6 +149,7 @@ long int time_sub(struct timeval *a, struct timeval *b) return r.tv_sec * 1000000 + r.tv_usec; } /* time_sub */ +#ifndef LIBPCSCLITE int ThreadCreate(pthread_t * pthThread, int attributes, PCSCLITE_THREAD_FUNCTION(pvFunction), LPVOID pvArg) { @@ -184,3 +187,4 @@ error: pthread_attr_destroy(&attr); return ret; } +#endif diff --git a/src/utils.h b/src/utils.h index 1a05ab3..791883b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -35,16 +35,18 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "wintypes.h" #include "readerfactory.h" -#define PID_ASCII_SIZE 11 -pid_t GetDaemonPid(void); -int SendHotplugSignal(void); +long int time_sub(struct timeval *a, struct timeval *b); /* defined in winscard_clnt.c */ LONG SCardCheckDaemonAvailability(void); -int CheckForOpenCT(void); +#ifndef LIBPCSCLITE -long int time_sub(struct timeval *a, struct timeval *b); +#define PID_ASCII_SIZE 11 +pid_t GetDaemonPid(void); +int SendHotplugSignal(void); + +int CheckForOpenCT(void); /* thread attributes */ #define THREAD_ATTR_DEFAULT 0 @@ -57,3 +59,5 @@ int ThreadCreate(pthread_t *, int, PCSCLITE_THREAD_FUNCTION( ), #endif +#endif +