From: Klemens Nanni Subject: security/pcsc-lite: update to 2.2.3 To: ports Date: Sun, 28 Jul 2024 12:29:38 +0000 'make test' passes with my card (reader), qdigidoc4 is still happy. Upstream now supports meson, I find that easier to use than autoconf, which fails to configure in this version (both 2.69 and 2.71). polkit and systemd were always searched and picked up, I fixed that and intend to send that patch upstream. Doxygen is used if found and has no option, so I neutered it. To dlopen() the new pcsclite_real lib with our correct .so version, I pass it via CFLAGS instead of SUBST_CMD'ing LIB..._VERSION in our patch. Tests? Feedack? OK? Relavent Changelog summary: - Fix memory leak on exit - libpcscspy: dump an output buffer only if the call succeeded - Some code cleanup - provide files for meson build tool (replaces autoconf/auoomake) - fix shutdown issues with hotplug_libusb - update pcsc-spy manpage - Some other minor improvements - LIBPCSCLITE_DELEGATE is used to redirect to another libpcsclite library - setup_spy.sh displays the LIBPCSCLITE_DELEGATE value to use for spying - provides libfake.c as a sample source code - Some other minor improvements - add SCARD_E_UNKNOWN_RES_MNG back Index: Makefile =================================================================== RCS file: /cvs/ports/security/pcsc-lite/Makefile,v diff -u -p -r1.64 Makefile --- Makefile 6 May 2024 12:23:56 -0000 1.64 +++ Makefile 28 Jul 2024 12:13:57 -0000 @@ -1,25 +1,27 @@ COMMENT= resource manager for PC/SC -V= 2.0.2 +V= 2.2.3 DISTNAME= pcsc-lite-${V} CATEGORIES= security -REVISION= 0 +SHARED_LIBS+= pcsclite_real 0.0 # 1.0.0 SHARED_LIBS+= pcsclite 1.0 # 1.0.0 -SHARED_LIBS+= pcscspy 0.0 # 0.0.0 +SHARED_LIBS+= pcscspy 1.0 # 1.0.0 HOMEPAGE= https://pcsclite.apdu.fr SITES= https://pcsclite.apdu.fr/files/ -EXTRACT_SUFX= .tar.bz2 +EXTRACT_SUFX= .tar.xz # BSD and GPLv3+ PERMIT_PACKAGE= Yes WANTLIB= c pthread usb-1.0 -MODULES+= lang/python +MODULES= devel/meson \ + lang/python + MODPY_BUILDDEP= No MODPY_ADJ_LINES= src/spy/pcsc-spy @@ -32,19 +34,13 @@ LIB_DEPENDS= devel/libusb1 MODPY_ADJ_FILES= src/spy/pcsc-spy -USE_GMAKE= Yes - -CONFIGURE_STYLE= gnu - -CONFIGURE_ARGS= --disable-libudev \ - --disable-libsystemd \ - --disable-polkit \ - --without-systemdsystemunitdir \ - --enable-libusb \ - --enable-confdir=${SYSCONFDIR}/ccid \ - --enable-ipcdir=/var/run/pcscd - -CONFIGURE_ENV= ac_cv_lib_lex='none needed' +CONFIGURE_ARGS= -Dipcdir=/var/run/pcscd \ + -Dlibsystemd=false \ + -Dlibudev=false \ + -Dlibusb=true \ + -Dpolkit=false \ + -Dserialconfdir=${SYSCONFDIR}/ccid \ + -Dusbdropdir=/usr/local/lib/pcsc/drivers TEST_DEPENDS= ${BUILD_PKGPATH}=${V} \ security/ccid @@ -53,11 +49,11 @@ TEST_DEPENDS= ${BUILD_PKGPATH}=${V} \ # insertion of a smart card reader as well as smart card TEST_IS_INTERACTIVE= Yes -do-test: - ${WRKBUILD}/src/testpcsc +_name= pcsclite_real +_file= "lib${_name}.so.${LIB${_name}_VERSION}" +CFLAGS+= -DLIBPCSC=${_file:Q:Q} -post-install: - rm ${PREFIX}/share/doc/pcsc-lite/{README.polkit,*install_spy.sh} - rmdir ${PREFIX}/share/doc/pcsc-lite +post-test: + ${WRKBUILD}/testpcsc .include Index: distinfo =================================================================== RCS file: /cvs/ports/security/pcsc-lite/distinfo,v diff -u -p -r1.31 distinfo --- distinfo 5 Mar 2024 14:58:55 -0000 1.31 +++ distinfo 28 Jul 2024 11:54:19 -0000 @@ -1,2 +1,2 @@ -SHA256 (pcsc-lite-2.0.2.tar.bz2) = ioh87WxahfL/boPP3HNd2YYl02puNozoQfteN5IhsVo= -SIZE (pcsc-lite-2.0.2.tar.bz2) = 818204 +SHA256 (pcsc-lite-2.2.3.tar.xz) = yrHmJ1VxP2LOG1Z5VNuw6afmaP+8O7rTzoXFP49OAKQ= +SIZE (pcsc-lite-2.2.3.tar.xz) = 207892 Index: patches/patch-meson_build =================================================================== RCS file: patches/patch-meson_build diff -N patches/patch-meson_build --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-meson_build 28 Jul 2024 12:28:02 -0000 @@ -0,0 +1,60 @@ +- -Dpolkit=false only makes it optional; it was always used when found. + Hide detection behind the option, being required when enabled as already + done for libusb. +- Omit setup_spy.sh +- Ignore Doxygen + +Index: meson.build +--- meson.build.orig ++++ meson.build +@@ -111,15 +111,18 @@ endif + + cc = meson.get_compiler('c') + dl_deps = cc.find_library('dl', required: false) ++pcscd_dep += dl_deps + +-polkit_dep = dependency('polkit-gobject-1', required : get_option('polkit')) +-if polkit_dep.found() ++if get_option('polkit') ++ polkit_dep = dependency('polkit-gobject-1') ++ pcscd_dep += polkit_dep + conf_data.set('HAVE_POLKIT', true) + features += 'polkit' + endif + +-systemd_dep = dependency('libsystemd', required : get_option('libsystemd')) +-if systemd_dep.found() ++if get_option('libsystemd') ++ systemd_dep = dependency('libsystemd') ++ pcscd_dep += systemd_dep + conf_data.set('USE_LIBSYSTEMD', true) + features += 'systemd' + endif +@@ -134,8 +137,6 @@ if pcsc_arch == 'Darwin' + endif + conf_data.set_quoted('PCSC_ARCH', pcsc_arch) + +-pcscd_dep += [polkit_dep, systemd_dep, dl_deps] +- + features += pcsc_arch + features += target_machine.cpu() + features += 'ipcdir=' + get_option('ipcdir') +@@ -200,9 +201,6 @@ library('pcscspy', + install_data('src/spy/pcsc-spy', + install_dir : get_option('bindir')) + +-install_data('src/spy/setup_spy.sh', +- install_dir : 'share/doc/pcsc-lite') +- + run_command('pod2man', + ['--date=2024-01-01', 'src/spy/pcsc-spy.pod', 'pcsc-spy.1'], + check : true) +@@ -290,7 +288,7 @@ configure_file(output : 'doxygen.conf', + input : 'doc/doxygen.conf.in', + configuration : confgen_data) + doxygen = find_program('doxygen', required : false) +-if doxygen.found() ++if false and doxygen.found() + message('Doxygen found') + run_target('doc', command : [doxygen, 'doxygen.conf']) + else Index: patches/patch-src_debug_c =================================================================== RCS file: /cvs/ports/security/pcsc-lite/patches/patch-src_debug_c,v diff -u -p -r1.4 patch-src_debug_c --- patches/patch-src_debug_c 5 Jul 2023 15:08:04 -0000 1.4 +++ patches/patch-src_debug_c 28 Jul 2024 11:54:19 -0000 @@ -3,7 +3,7 @@ Disable colors by default. Index: src/debug.c --- src/debug.c.orig +++ src/debug.c -@@ -73,6 +73,7 @@ static void log_init(void) +@@ -74,6 +74,7 @@ static void log_init(void) if (e) LogLevel = atoi(e); @@ -11,7 +11,7 @@ Index: src/debug.c /* log to stderr and stderr is a tty? */ if (isatty(fileno(stderr))) { -@@ -96,6 +97,7 @@ static void log_init(void) +@@ -97,6 +98,7 @@ static void log_init(void) } } } Index: patches/patch-src_debuglog_c =================================================================== RCS file: /cvs/ports/security/pcsc-lite/patches/patch-src_debuglog_c,v diff -u -p -r1.6 patch-src_debuglog_c --- patches/patch-src_debuglog_c 19 Dec 2023 10:22:42 -0000 1.6 +++ patches/patch-src_debuglog_c 28 Jul 2024 11:54:19 -0000 @@ -3,7 +3,7 @@ Disable colors by default. Index: src/debuglog.c --- src/debuglog.c.orig +++ src/debuglog.c -@@ -264,7 +264,7 @@ static void log_line(const int priority, const char *D +@@ -262,7 +262,7 @@ static void log_line(const int priority, const char *D break; } @@ -12,7 +12,7 @@ Index: src/debuglog.c #define THREAD_FORMAT "%p" #else #define THREAD_FORMAT "%lu" -@@ -350,6 +350,9 @@ void DebugLogSetLogType(const int dbgtype) +@@ -348,6 +348,9 @@ void DebugLogSetLogType(const int dbgtype) LogMsgType = DEBUGLOG_STDOUT_DEBUG; } @@ -22,7 +22,7 @@ Index: src/debuglog.c /* log to stdout and stdout is a tty? */ if ((DEBUGLOG_STDOUT_DEBUG == LogMsgType && isatty(fileno(stdout))) || (DEBUGLOG_STDOUT_COLOR_DEBUG == LogMsgType)) -@@ -374,6 +377,7 @@ void DebugLogSetLogType(const int dbgtype) +@@ -372,6 +375,7 @@ void DebugLogSetLogType(const int dbgtype) } } } Index: patches/patch-src_libredirect_c =================================================================== RCS file: patches/patch-src_libredirect_c diff -N patches/patch-src_libredirect_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_libredirect_c 28 Jul 2024 11:46:10 -0000 @@ -0,0 +1,14 @@ +Leave dlopen()ed .so version to CFLAGS + +Index: src/libredirect.c +--- src/libredirect.c.orig ++++ src/libredirect.c +@@ -127,8 +127,6 @@ static void log_line(const char *fmt, ...) + + static LONG load_lib(void) + { +-#define LIBPCSC "libpcsclite_real.so.1" +- + const char *lib; + + lib = SYS_GetEnv("LIBPCSCLITE_DELEGATE"); Index: patches/patch-src_spy_libpcscspy_c =================================================================== RCS file: /cvs/ports/security/pcsc-lite/patches/patch-src_spy_libpcscspy_c,v diff -u -p -r1.6 patch-src_spy_libpcscspy_c --- patches/patch-src_spy_libpcscspy_c 16 Mar 2022 10:22:32 -0000 1.6 +++ patches/patch-src_spy_libpcscspy_c 28 Jul 2024 11:54:19 -0000 @@ -1,3 +1,6 @@ +- Fix printf format +- Leave dlopen()ed .so version to CFLAGS + Index: src/spy/libpcscspy.c --- src/spy/libpcscspy.c.orig +++ src/spy/libpcscspy.c @@ -9,7 +12,7 @@ Index: src/spy/libpcscspy.c #include "misc.h" #include -@@ -162,7 +163,7 @@ static void spy_line_direct(char *line) +@@ -121,7 +122,7 @@ static void spy_line_direct(char *line) if (Log_fd < 0) return; @@ -18,7 +21,7 @@ Index: src/spy/libpcscspy.c pthread_mutex_lock(&Log_fd_mutex); r = write(Log_fd, threadid, strlen(threadid)); r = write(Log_fd, line, strlen(line)); -@@ -191,7 +192,7 @@ static void spy_line(const char *fmt, ...) +@@ -150,7 +151,7 @@ static void spy_line(const char *fmt, ...) printf("libpcsc-spy: Buffer is too small!\n"); return; } @@ -27,3 +30,13 @@ Index: src/spy/libpcscspy.c pthread_mutex_lock(&Log_fd_mutex); r = write(Log_fd, threadid, strlen(threadid)); r = write(Log_fd, line, size); +@@ -285,9 +286,6 @@ static void spy_readerstate(SCARD_READERSTATE * rgRead + + static LONG load_lib(void) + { +- +-#define LIBPCSC "libpcsclite_real.so.1" +- + const char *lib; + + lib = SYS_GetEnv("LIBPCSCLITE_SPY_DELEGATE"); Index: patches/patch-src_testpcsc_c =================================================================== RCS file: /cvs/ports/security/pcsc-lite/patches/patch-src_testpcsc_c,v diff -u -p -r1.6 patch-src_testpcsc_c --- patches/patch-src_testpcsc_c 14 May 2022 13:51:28 -0000 1.6 +++ patches/patch-src_testpcsc_c 28 Jul 2024 11:54:19 -0000 @@ -3,7 +3,7 @@ Make regress suite noninteractive. Index: src/testpcsc.c --- src/testpcsc.c.orig +++ src/testpcsc.c -@@ -470,8 +470,6 @@ wait_for_card_again: +@@ -461,8 +461,6 @@ wait_for_card_again: free(pcReader); #endif Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/security/pcsc-lite/pkg/PLIST,v diff -u -p -r1.9 PLIST --- pkg/PLIST 16 Mar 2022 10:22:32 -0000 1.9 +++ pkg/PLIST 28 Jul 2024 11:54:19 -0000 @@ -7,11 +7,8 @@ include/PCSC/pcsclite.h include/PCSC/reader.h include/PCSC/winscard.h include/PCSC/wintypes.h -@static-lib lib/libpcsclite.a -lib/libpcsclite.la @lib lib/libpcsclite.so.${LIBpcsclite_VERSION} -@static-lib lib/libpcscspy.a -lib/libpcscspy.la +@lib lib/libpcsclite_real.so.${LIBpcsclite_real_VERSION} @lib lib/libpcscspy.so.${LIBpcscspy_VERSION} lib/pkgconfig/libpcsclite.pc @man man/man1/pcsc-spy.1