On Wed, 11 Jul 2012, David Coppa wrote:

> Hi,
> 
> Just a little poll about security/gnupg2 and smartcard support:
> 
> Now that pcsc-lite-1.8.x is working fine (dunno what, but something
> has been fixed in either rthreads or libusb1: thanks a lot to the
> usual suspects!), is it better to completely disable internal ccid
> support from gnupg2 and add a runtime dependency on pcsc-lite and ccid
> or to leave things as they currently are and tell the users to install
> pcsc-lite and ccid in order to use a card reader other than the SCM
> SCR335 USB SmartCard reader[1] (the only reader supported by gnupg2
> without pcsc-lite)?
> 
> Thoughts welcome...
> 
> [1] http://www.scm-pc-card.de/picture/scr-335.jpg

Hi again,

Here's my diff for both pcsc-lite and gnupg2.

Tested on amd64 with the O2 O2Micro CCID SC Reader (the embedded
card reader in my Dell Latitude) and with the SCM SCR335 USB SC
Reader. Build-only tested on sparc64.

Bonus point: it does not link with -lfl anymore.

OK?

I will send the new security/ccid port in another mail...

Index: gnupg2/Makefile
===================================================================
RCS file: /cvs/ports/security/gnupg2/Makefile,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile
--- gnupg2/Makefile     14 May 2012 08:49:54 -0000      1.19
+++ gnupg2/Makefile     12 Jul 2012 09:01:40 -0000
@@ -3,7 +3,7 @@
 COMMENT =      gnu privacy guard - a free PGP replacement
 
 DISTNAME =     gnupg-2.0.19
-REVISION =     0
+REVISION =     1
 CATEGORIES =   security
 
 MASTER_SITES =         ftp://ftp.gnupg.org/gcrypt/gnupg/ \
@@ -27,7 +27,7 @@ PERMIT_DISTFILES_FTP =        Yes
 
 WANTLIB +=             assuan bz2 c crypto curl gcrypt
 WANTLIB +=             gpg-error idn ksba pth pthread
-WANTLIB +=             readline ssl termcap usb z
+WANTLIB +=             readline ssl termcap z
 
 EXTRACT_SUFX =                 .tar.bz2
 
@@ -37,7 +37,6 @@ FLAVORS =             ldap
 FLAVOR ?=
 
 LIB_DEPENDS =          archivers/bzip2 \
-                       devel/libusb-compat \
                        security/libassuan \
                        security/libgcrypt \
                        security/libksba \
@@ -52,7 +51,8 @@ LIB_DEPENDS +=                databases/openldap
 CONFIGURE_ARGS +=      --disable-ldap
 .endif
 
-RUN_DEPENDS =          security/pinentry
+RUN_DEPENDS =          security/ccid \
+                       security/pinentry
 
 # gpg-agent must be installed to run the regress tests
 REGRESS_DEPENDS =      ${FULLPKGNAME}:${BUILD_PKGPATH}
@@ -62,8 +62,9 @@ USE_GROFF =           Yes
 
 CONFIGURE_STYLE =      gnu
 CONFIGURE_ENV =        CPPFLAGS="-I${LOCALBASE}/include" \
-                       LDFLAGS="-L${LOCALBASE}/lib -pthread"
+                       LDFLAGS="-L${LOCALBASE}/lib"
 CONFIGURE_ARGS =       docdir=${LOCALBASE}/share/doc/gnupg2 \
+                       --disable-ccid-driver \
                        --enable-gpgtar
 
 # Avoid conflict with gnupg-1.x
Index: gnupg2/patches/patch-scd_Makefile_in
===================================================================
RCS file: /cvs/ports/security/gnupg2/patches/patch-scd_Makefile_in,v
retrieving revision 1.1
diff -u -p -r1.1 patch-scd_Makefile_in
--- gnupg2/patches/patch-scd_Makefile_in        14 May 2012 08:49:54 -0000      
1.1
+++ gnupg2/patches/patch-scd_Makefile_in        12 Jul 2012 09:01:40 -0000
@@ -1,15 +1,12 @@
 $OpenBSD: patch-scd_Makefile_in,v 1.1 2012/05/14 08:49:54 dcoppa Exp $
-
-No PC/SC-Lite (pcsc-lite) support for now
-
 --- scd/Makefile.in.orig       Tue Mar 27 10:22:48 2012
-+++ scd/Makefile.in    Sun May 13 18:23:49 2012
-@@ -70,7 +70,7 @@ POST_UNINSTALL = :
- build_triplet = @build@
- host_triplet = @host@
- bin_PROGRAMS = scdaemon$(EXEEXT)
--@HAVE_W32_SYSTEM_FALSE@libexec_PROGRAMS = gnupg-pcsc-wrapper$(EXEEXT)
-+@HAVE_W32_SYSTEM_FALSE@libexec_PROGRAMS =
- DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-       $(top_srcdir)/am/cmacros.am
- @HAVE_DOSISH_SYSTEM_FALSE@am__append_1 = -DGNUPG_BINDIR="\"$(bindir)\""       
     \
++++ scd/Makefile.in    Wed Jul 11 22:08:58 2012
+@@ -227,7 +227,7 @@ KSBA_CONFIG = @KSBA_CONFIG@
+ KSBA_LIBS = @KSBA_LIBS@
+ LDAPLIBS = @LDAPLIBS@
+ LDAP_CPPFLAGS = @LDAP_CPPFLAGS@
+-LDFLAGS = @LDFLAGS@
++LDFLAGS = @LDFLAGS@ -pthread -Wl,--export-dynamic
+ LIBASSUAN_CFLAGS = @LIBASSUAN_CFLAGS@
+ LIBASSUAN_CONFIG = @LIBASSUAN_CONFIG@
+ LIBASSUAN_LIBS = @LIBASSUAN_LIBS@
Index: gnupg2/patches/patch-scd_apdu_c
===================================================================
RCS file: gnupg2/patches/patch-scd_apdu_c
diff -N gnupg2/patches/patch-scd_apdu_c
--- gnupg2/patches/patch-scd_apdu_c     14 May 2012 08:49:54 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-$OpenBSD: patch-scd_apdu_c,v 1.3 2012/05/14 08:49:54 dcoppa Exp $
-
-No PC/SC-Lite (pcsc-lite) support for now
-
---- scd/apdu.c.orig    Tue Mar 27 10:00:38 2012
-+++ scd/apdu.c Sun May 13 18:41:37 2012
-@@ -66,7 +66,7 @@
- /* Due to conflicting use of threading libraries we usually can't link
-    against libpcsclite.   Instead we use a wrapper program.  */
- #ifdef USE_GNU_PTH
--#if !defined(HAVE_W32_SYSTEM) && !defined(__CYGWIN__)
-+#if !defined(HAVE_W32_SYSTEM) && !defined(__CYGWIN__) && !defined(__OpenBSD__)
- #define NEED_PCSC_WRAPPER 1
- #endif
- #endif
-@@ -2389,6 +2389,9 @@ apdu_open_reader (const char *portstr, int *r_no_servi
-   /* No ctAPI configured, so lets try the PC/SC API */
-   if (!pcsc_api_loaded)
-     {
-+#ifdef __OpenBSD__
-+      return -1;
-+#endif
- #ifndef NEED_PCSC_WRAPPER
-       void *handle;
- 
Index: gnupg2/pkg/PLIST
===================================================================
RCS file: /cvs/ports/security/gnupg2/pkg/PLIST,v
retrieving revision 1.7
diff -u -p -r1.7 PLIST
--- gnupg2/pkg/PLIST    14 May 2012 08:49:54 -0000      1.7
+++ gnupg2/pkg/PLIST    12 Jul 2012 09:01:40 -0000
@@ -15,6 +15,7 @@ bin/gpgsm-gencert.sh
 @bin bin/scdaemon
 @bin bin/watchgnupg
 @info info/gnupg.info
+@bin libexec/gnupg-pcsc-wrapper
 @bin libexec/gpg-check-pattern
 @bin libexec/gpg-preset-passphrase
 @bin libexec/gpg-protect-tool
Index: pcsc-lite/Makefile
===================================================================
RCS file: /cvs/ports/security/pcsc-lite/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- pcsc-lite/Makefile  20 Nov 2010 17:22:45 -0000      1.10
+++ pcsc-lite/Makefile  12 Jul 2012 09:01:42 -0000
@@ -1,45 +1,47 @@
 # $OpenBSD: Makefile,v 1.10 2010/11/20 17:22:45 espie Exp $
-# Uses pthreads
 
 COMMENT=       resource manager for PCSC
 
-DISTNAME=      pcsc-lite-1.0.1
-REVISION =     0
+DISTNAME=      pcsc-lite-1.8.4
 CATEGORIES=    security
-SHARED_LIBS=   pcsclite-core   0.2 \
-               pcsclite        0.1
-MODGNU_SHARED_LIBS=    pcsclite-core   '' \
-                       pcsclite        ''
-LIBpcsclite-core_ALIAS=        realpcsclite_core
 
-MASTER_SITES=  http://www.linuxnet.com/middleware/files/
+SHARED_LIBS+=  pcsclite        1.0 # 1.0.0
+SHARED_LIBS+=  pcscspy         0.0 # 0.0.0
 
-HOMEPAGE=      http://www.linuxnet.com/
+HOMEPAGE=      http://pcsclite.alioth.debian.org/pcsclite.html
 
+MASTER_SITES=  https://alioth.debian.org/frs/download.php/3734/
+
+EXTRACT_SUFX=  .tar.bz2
+
+MAINTAINER=    David Coppa <dco...@openbsd.org>
+
+# BSD and GPLv3+
 PERMIT_PACKAGE_CDROM=  Yes
 PERMIT_PACKAGE_FTP=    Yes
 PERMIT_DISTFILES_CDROM=        Yes
 PERMIT_DISTFILES_FTP=  Yes
-WANTLIB=               c pthread
 
-CONFIGURE_STYLE= gnu
-CONFIGURE_ARGS=        ${CONFIGURE_SHARED}     \
-               --enable-static         \
-               --enable-daemon         \
-               --enable-debug          \
-               --enable-syslog         \
-               --enable-threadsafe
-CONFIGURE_ENV= PTHREAD_LIBS=-pthread
-MODGNU_CONFIG_GUESS_DIRS=${WRKSRC}/build
+WANTLIB=               c pthread usb-1.0
+
+MODULES=               lang/python
+
+LIB_DEPENDS=           devel/libusb1
+
+MODPY_ADJ_FILES=       src/spy/pcsc-spy
 
 USE_GMAKE=     Yes
 USE_LIBTOOL=   Yes
-NO_REGRESS=    Yes
 
-EXDIR=         ${PREFIX}/share/examples/pcscd
+CONFIGURE_STYLE= gnu
+
+CONFIGURE_ARGS= --disable-libudev \
+               --without-systemdsystemunitdir \
+               --enable-libusb \
+               --enable-confdir=${SYSCONFDIR}/ccid
+
+CONFIGURE_ENV= ac_cv_lib_lex='none needed'
 
-post-install:
-       ${INSTALL_DATA_DIR} ${EXDIR}
-       ${INSTALL_DATA} ${FILESDIR}/reader.conf.sample ${EXDIR}
+NO_REGRESS=    Yes
 
 .include <bsd.port.mk>
Index: pcsc-lite/distinfo
===================================================================
RCS file: /cvs/ports/security/pcsc-lite/distinfo,v
retrieving revision 1.3
diff -u -p -r1.3 distinfo
--- pcsc-lite/distinfo  5 Apr 2007 17:26:09 -0000       1.3
+++ pcsc-lite/distinfo  12 Jul 2012 09:01:42 -0000
@@ -1,5 +1,5 @@
-MD5 (pcsc-lite-1.0.1.tar.gz) = UZ+Gtc3d17+5q2Mw3Ylmsw==
-RMD160 (pcsc-lite-1.0.1.tar.gz) = +gcgqKS4Y1h8VO5HNEIqRhIVbBE=
-SHA1 (pcsc-lite-1.0.1.tar.gz) = qYeJ7Kc0hziSMAXQ9MG6sOl2Dqw=
-SHA256 (pcsc-lite-1.0.1.tar.gz) = AiAh8aOOEiCSCRdIWgKahF6C3rWhs0ieB5gvSIfCbW0=
-SIZE (pcsc-lite-1.0.1.tar.gz) = 333975
+MD5 (pcsc-lite-1.8.4.tar.bz2) = Pva1aRKLFZaa26JdgM7Y0A==
+RMD160 (pcsc-lite-1.8.4.tar.bz2) = jzK8cN7RpQX8WzeIlbYXIRSAEuE=
+SHA1 (pcsc-lite-1.8.4.tar.bz2) = cR17zsyGin+NNTxoXafzjV4gvgU=
+SHA256 (pcsc-lite-1.8.4.tar.bz2) = XvzVoqQxhoV19/zhwULYvBJPxlhc4Ueir7ndb1jaP6Y=
+SIZE (pcsc-lite-1.8.4.tar.bz2) = 550284
Index: pcsc-lite/files/reader.conf.sample
===================================================================
RCS file: pcsc-lite/files/reader.conf.sample
diff -N pcsc-lite/files/reader.conf.sample
--- pcsc-lite/files/reader.conf.sample  7 Dec 2001 06:33:19 -0000       1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-# Configuration file for pcsc-lite
-# David Corcoran <corco...@linuxnet.com>
-#
-# In this file, you can have more than one
-# reader information.
-#
-# FRIENDLYNAME         Give any name to your reader
-# DEVICENAME           Give any name to your reader
-# LIBPATH              The path of your reader's driver
-# CHANNELID :
-#      0x0103F8        COM1
-#      0x0102F8        COM2
-#      0x0103E8        COM3
-#      0x0102E8        COM4
-#
-# $OpenBSD: reader.conf.sample,v 1.1.1.1 2001/12/07 06:33:19 shell Exp $
-
-FRIENDLYNAME     "Generic Reader"
-DEVICENAME       GEN_SMART_RDR
-LIBPATH          /usr/lib/readers/libgen_ifd.so
-CHANNELID        0x0103F8
-
-
-# End of file
Index: pcsc-lite/patches/patch-src-debuglog_c
===================================================================
RCS file: pcsc-lite/patches/patch-src-debuglog_c
diff -N pcsc-lite/patches/patch-src-debuglog_c
--- pcsc-lite/patches/patch-src-debuglog_c      25 Dec 2005 09:13:57 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-$OpenBSD: patch-src-debuglog_c,v 1.2 2005/12/25 09:13:57 sturm Exp $
---- src/debuglog.c.orig        Wed Nov  7 23:54:30 2001
-+++ src/debuglog.c     Sun Dec 25 10:08:57 2005
-@@ -18,15 +18,17 @@
- #include <syslog.h>
- #include <stdio.h>
- 
-+#define DEBUG_BUFFER_LENGTH 150
-+
- static LONG lSuppress = DEBUGLOG_LOG_ENTRIES;
- 
- void DebugLogA( LPCSTR pcMessage, LPCSTR pcFile, LONG liLine ) {
- 
-   if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
- #ifdef        USE_SYSLOG
--    syslog( LOG_DEBUG, "%15s %3d: %s", pcFile, (int)liLine, pcMessage );
-+    syslog( LOG_INFO, "%15s %3d: %s", pcFile, (int)liLine, pcMessage );
- #else
--    printf("%15s %3d: %s", pcFile, (int)liLine, pcMessage);
-+    printf("%15s %3d: %s\n", pcFile, (int)liLine, pcMessage);
- #endif
-   }
- 
-@@ -34,14 +36,16 @@ void DebugLogA( LPCSTR pcMessage, LPCSTR
- 
- void DebugLogB( LPCSTR pcFormat, LONG liValue, LPCSTR pcFile, LONG liLine ) {
- 
--  char pcBuffer[150];
-+  char pcBuffer[DEBUG_BUFFER_LENGTH];
- 
-   if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
--    sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
-+    snprintf(pcBuffer, sizeof(pcBuffer), "%15s %3d: %s", pcFile,
-+              (int)liLine, pcFormat );
- #ifdef        USE_SYSLOG
--    syslog( LOG_DEBUG, pcBuffer, liValue );
-+    syslog( LOG_INFO, pcBuffer, liValue );
- #else
-     printf(pcBuffer, liValue);
-+      putchar('\n');
- #endif
-   }
- 
-@@ -50,14 +54,16 @@ void DebugLogB( LPCSTR pcFormat, LONG li
- void DebugLogC( LPCSTR pcFormat, LPCSTR pcMessage, LPCSTR pcFile, 
-               LONG liLine ) {
- 
--  char pcBuffer[150];
-+  char pcBuffer[DEBUG_BUFFER_LENGTH];
- 
-   if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
--    sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
-+    snprintf(pcBuffer,  sizeof(pcBuffer), "%15s %3d: %s", pcFile,
-+              (int)liLine, pcFormat );
- #ifdef  USE_SYSLOG
--    syslog( LOG_DEBUG, pcBuffer, pcMessage );
-+    syslog( LOG_INFO, pcBuffer, pcMessage );
- #else
-     printf(pcBuffer, pcMessage);
-+      putchar('\n');
- #endif
-   }
- 
-@@ -67,28 +73,26 @@ void DebugLogD( LPCSTR pcFormat, PUCHAR 
-               LPCSTR pcFile, LONG liLine ) {
- 
-   int i;
--  char pcBuffer[150];
-+  char pcBuffer[DEBUG_BUFFER_LENGTH];
-   char *tmpBuffer;
--  /* tmpBuffer = (char *)malloc( ( 4+liLength ) * sizeof( PUCHAR ) ); */
- 
-   if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
--    sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
-+    snprintf(pcBuffer,  sizeof(pcBuffer), "%15s %3d: %s", pcFile,
-+              (int)liLine, pcFormat );
- #ifdef  USE_SYSLOG
-     tmpBuffer = (char *)malloc( liLength*3 + 1); 
--    syslog( LOG_DEBUG, pcBuffer, pcFormat );
-+    syslog( LOG_INFO, pcBuffer, pcFormat );
-     for (i=0; i < liLength; i++) {
--      /* sprintf( tmpBuffer, "%x ", pucData[i] ); */
-       sprintf( tmpBuffer + i*3, "%02X ", pucData[i] );
- 
-     } 
--    /*    sprintf( tmpBuffer, "\n" ); */
--    syslog( LOG_DEBUG, tmpBuffer );
-+    syslog( LOG_INFO, tmpBuffer );
-     free( tmpBuffer );
- #else
-     printf(pcBuffer, pcFormat);
-     for (i=0; i < liLength; i++) {
--      printf("%x ", pucData[i]);
--    } printf("\n");
-+      printf("%02X ", pucData[i]);
-+    } putchar('\n');
- #endif
-   }
- 
Index: pcsc-lite/patches/patch-src-pcscdaemon_c
===================================================================
RCS file: pcsc-lite/patches/patch-src-pcscdaemon_c
diff -N pcsc-lite/patches/patch-src-pcscdaemon_c
--- pcsc-lite/patches/patch-src-pcscdaemon_c    2 Jan 2004 22:53:09 -0000       
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-$OpenBSD: patch-src-pcscdaemon_c,v 1.2 2004/01/02 22:53:09 espie Exp $
---- src/pcscdaemon.c.orig      2001-11-07 23:54:30.000000000 +0100
-+++ src/pcscdaemon.c   2004-01-02 23:47:08.000000000 +0100
-@@ -26,9 +26,17 @@
- #include <stdio.h>
- #include <unistd.h>
- 
-+#ifdef USE_DAEMON
-+#ifndef USE_SYSLOG
-+#error You must use '--enable-syslog' when also using '--enable-daemon' or 
you will not get any message
-+#endif
-+#endif
-+
- /* Some internal functions */
- void SVCServiceRunLoop();
- void SVCClientCleanup( psharedSegmentMsg );
-+void at_exit(void);
-+void at_exit_signal(int);
- 
- extern int errno;
- 
-@@ -55,9 +63,9 @@ void SVCServiceRunLoop() {
-   rsp = SHMInitializeCommonSegment();
- 
-   if ( rsp == -1 ) {
--    DebugLogA("SVCServiceRunLoop: Error initializing pcscd.\n",
-+    DebugLogA("SVCServiceRunLoop: Error initializing pcscd.",
-             __FILE__, __LINE__);
--    SYS_Exit(-1);
-+    exit(-1);
-   }
- 
-   /* Solaris sends a SIGALRM and it is annoying */
-@@ -82,8 +90,7 @@ void SVCServiceRunLoop() {
-       MSGCleanupClient( &msgStruct ); 
-       SYS_MutexUnLock(&usbNotifierMutex);
-       snprintf(errMessage, sizeof(errMessage), "%s%d%s",
--               "SVCServiceRun: Client ", msgStruct.request_id,
--               " has disappeared.\n" );
-+               "SVCServiceRun: Client ", msgStruct.request_id, " has 
disappeared." );
- #ifdef PCSC_DEBUG
-       DebugLogA(errMessage, __FILE__, __LINE__);
- #endif
-@@ -108,8 +115,7 @@ void SVCServiceRunLoop() {
- 
-     case -1:
- #ifdef PCSC_DEBUG
--      DebugLogA("SVCServiceRun: Error in ProcessEvents.\n", 
--                __FILE__, __LINE__);
-+      DebugLogA("SVCServiceRun: Error in ProcessEvents.", __FILE__, __LINE__);
- #endif
-       break;
- 
-@@ -137,8 +143,7 @@ int main(int argc, char **argv) {
-     printf("pcscd -help    - This help menu\n");
-     return 0;
-   } else if ( argc == 3 && (strcmp(argv[1], "-c") == 0) ) {
--    DebugLogC("main: Using new config file: %s\n", argv[2],
--            __FILE__, __LINE__);
-+    DebugLogC("main: Using new config file: %s", argv[2], __FILE__, __LINE__);
-     newReaderConfig = argv[2];
-   } else if ( argc == 1 ) {
-     /* All OK Here */
-@@ -150,7 +155,7 @@ int main(int argc, char **argv) {
- #ifdef USE_DAEMON
-   /* standard daemonizing actions */
- #ifndef HAVE_DAEMON
--  switch (fork()) {
-+  switch (SYS_Fork()) {
-     case -1:
-       return (-1);
-     case 0:
-@@ -167,22 +172,47 @@ int main(int argc, char **argv) {
- #endif
- #endif
- 
--  /* Create the /tmp/pcsc directory and chmod it */
--  rv = SYS_Mkdir("/tmp/pcsc", S_ISVTX | S_IRWXO | S_IRWXG | S_IRWXU );
-+  /* test the presence of /tmp/pcsc */
-+  {
-+      struct stat buf;
-+
-+    rv = SYS_Stat(PCSCLITE_IPC_DIR, &buf);
-+      if (rv == 0)
-+      {
- #ifdef PCSC_DEBUG
-+      DebugLogA("main: directory " PCSCLITE_IPC_DIR " already exists",
-+                      __FILE__, __LINE__);
-+              return 1;
-+#endif
-+      }
-+
-+  }
-+
-+  /* cleanly remove /tmp/pcsc when exiting */
-+  atexit(at_exit);
-+  signal(SIGQUIT, at_exit_signal);
-+  signal(SIGTERM, at_exit_signal);
-+  signal(SIGINT, at_exit_signal);
-+  signal(SIGHUP, at_exit_signal);
-+
-+  /* Create the /tmp/pcsc directory and chmod it */
-+  rv = SYS_Mkdir(PCSCLITE_IPC_DIR, S_ISVTX | S_IRWXO | S_IRWXG | S_IRWXU );
-   if ( rv != 0 ) {
--    DebugLogC("main: Cannot create /tmp/pcsc: %s\n", strerror(errno),
-+#ifdef PCSC_DEBUG
-+    DebugLogC("main: Cannot create " PCSCLITE_IPC_DIR ": %s", strerror(errno),
-             __FILE__, __LINE__);
--  }
- #endif
-+      return 1;
-+  }
- 
--  rv = SYS_Chmod("/tmp/pcsc", S_ISVTX | S_IRWXO | S_IRWXG | S_IRWXU );
--#ifdef PCSC_DEBUG
-+  rv = SYS_Chmod(PCSCLITE_IPC_DIR, S_ISVTX | S_IRWXO | S_IRWXG | S_IRWXU );
-   if ( rv != 0 ) {
--    DebugLogC("main: Cannot chmod /tmp/pcsc: %s\n", strerror(errno),
-+#ifdef PCSC_DEBUG
-+    DebugLogC("main: Cannot chmod " PCSCLITE_IPC_DIR ": %s", strerror(errno),
-             __FILE__, __LINE__);
--  }
- #endif
-+      return 1;
-+  }
- 
-   /* Allocate memory for reader structures     */
-   RFAllocateReaderSpace( PCSCLITE_MAX_CONTEXTS );
-@@ -199,13 +229,58 @@ int main(int argc, char **argv) {
-   g_rgSCardT1Pci.dwProtocol  = SCARD_PROTOCOL_T1;  
-   g_rgSCardRawPci.dwProtocol = SCARD_PROTOCOL_RAW;
-   
--  DebugLogA("main: PC/SC Lite Daemon Ready.\n", __FILE__, __LINE__);
-+  DebugLogA("main: PC/SC Lite Daemon Ready.", __FILE__, __LINE__);
-   
-   SVCServiceRunLoop();
-+
- #ifdef USE_SYSLOG
--  syslog( LOG_ERR, "pcscdaemon.c: main: SVCServiceRunLoop returned\n" );
-+  syslog( LOG_ERR, "pcscdaemon.c: main: SVCServiceRunLoop returned" );
- #else
--  fprintf(stderr, "pcscdaemon.c: main: SVCServiceRunLoop returned\n");
-+  fprintf(stderr, "pcscdaemon.c: main: SVCServiceRunLoop returned");
- #endif
-   return 1;
- }
-+
-+void at_exit(void)
-+{
-+      int rv;
-+
-+      DebugLogA("at_exit: cleaning " PCSCLITE_IPC_DIR, __FILE__, __LINE__);
-+
-+      rv = SYS_Unlink(PCSCLITE_SHM_FILE);
-+#ifdef PCSC_DEBUG
-+      if ( rv != 0 )
-+      DebugLogC("main: Cannot unlink " PCSCLITE_SHM_FILE ": %s",
-+                      strerror(errno), __FILE__, __LINE__);
-+#endif
-+
-+      rv = SYS_Unlink(PCSCLITE_PUBSHM_FILE);
-+#ifdef PCSC_DEBUG
-+      if ( rv != 0 )
-+      DebugLogC("main: Cannot unlink " PCSCLITE_PUBSHM_FILE ": %s",
-+                      strerror(errno), __FILE__, __LINE__);
-+#endif
-+
-+      rv = SYS_Unlink(PCSCLITE_CSOCK_NAME);
-+#ifdef PCSC_DEBUG
-+      if ( rv != 0 )
-+      DebugLogC("main: Cannot unlink " PCSCLITE_CSOCK_NAME ": %s",
-+                      strerror(errno), __FILE__, __LINE__);
-+#endif
-+
-+      rv = SYS_Rmdir(PCSCLITE_IPC_DIR);
-+#ifdef PCSC_DEBUG
-+      if ( rv != 0 )
-+      DebugLogC("main: Cannot rmdir " PCSCLITE_IPC_DIR ": %s",
-+                      strerror(errno), __FILE__, __LINE__);
-+#endif
-+
-+      SYS_Exit(1);
-+}
-+
-+void at_exit_signal(int sig)
-+{
-+      /* will call at_exit() */
-+      exit(0);
-+}
-+
Index: pcsc-lite/patches/patch-src-pcsclite_h
===================================================================
RCS file: pcsc-lite/patches/patch-src-pcsclite_h
diff -N pcsc-lite/patches/patch-src-pcsclite_h
--- pcsc-lite/patches/patch-src-pcsclite_h      25 Dec 2005 09:13:57 -0000      
1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-$OpenBSD: patch-src-pcsclite_h,v 1.4 2005/12/25 09:13:57 sturm Exp $
---- src/pcsclite.h.orig        Wed Nov  7 23:54:30 2001
-+++ src/pcsclite.h     Sun Dec 25 10:08:58 2005
-@@ -143,11 +143,13 @@ char * pcsc_stringify_error( long );
- #define BLOCK_STATUS_RESUME             0x00FF  /* Normal resume        */
- #define BLOCK_STATUS_BLOCKING           0x00FA  /* Function is blocking */
- 
--#define PCSCLITE_READER_CONFIG                "/etc/reader.conf"
--#define PCSCLITE_CARD_CONFIG          "/etc/card.conf"
--#define PCSCLITE_SHM_FILE               "/tmp/pcsc/.pcsctmp"
--#define PCSCLITE_PUBSHM_FILE            "/tmp/pcsc/.pcscpub"
--#define PCSCLITE_CSOCK_NAME             "/tmp/pcsc/.pcscomm"
-+#define PCSCLITE_CONFIG_DIR           "/etc/pcscd"
-+#define PCSCLITE_READER_CONFIG                PCSCLITE_CONFIG_DIR 
"/reader.conf"
-+#define PCSCLITE_CARD_CONFIG          PCSCLITE_CONFIG_DIR "/card.conf"
-+#define PCSCLITE_IPC_DIR              "/var/run/pcsc"
-+#define PCSCLITE_SHM_FILE               PCSCLITE_IPC_DIR "/.pcsctmp"
-+#define PCSCLITE_PUBSHM_FILE            PCSCLITE_IPC_DIR "/.pcscpub"
-+#define PCSCLITE_CSOCK_NAME             PCSCLITE_IPC_DIR "/.pcscomm"
- 
- #define PCSCLITE_SVC_IDENTITY      0x01030000 /* Service ID           */
- 
Index: pcsc-lite/patches/patch-src-sys_generic_h
===================================================================
RCS file: pcsc-lite/patches/patch-src-sys_generic_h
diff -N pcsc-lite/patches/patch-src-sys_generic_h
--- pcsc-lite/patches/patch-src-sys_generic_h   25 Dec 2005 09:13:57 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,33 +0,0 @@
-$OpenBSD: patch-src-sys_generic_h,v 1.2 2005/12/25 09:13:57 sturm Exp $
---- src/sys_generic.h.orig     Wed Nov  7 23:54:32 2001
-+++ src/sys_generic.h  Sun Dec 25 10:08:58 2005
-@@ -19,6 +19,8 @@
- extern "C" {
- #endif     
- 
-+#include <sys/stat.h>
-+
-   int SYS_Initialize();
- 
-   int SYS_Mkdir( char*, int );
-@@ -73,13 +75,19 @@ extern "C" {
-   
-   int SYS_Wait( int, int );
-   
--  int SYS_Stat( int );
-+  int SYS_Stat( char *pcFile, struct stat *psStatus );
-+
-+  int SYS_Fstat( int );
-   
-   int SYS_Random( int, float, float );
- 
-   int SYS_GetSeed();
- 
-   int SYS_Exit( int );
-+
-+  int SYS_Rmdir( char *pcFile );
-+
-+  int SYS_Unlink( char *pcFile );
- 
- #ifdef __cplusplus
- }
Index: pcsc-lite/patches/patch-src-sys_unix_c
===================================================================
RCS file: pcsc-lite/patches/patch-src-sys_unix_c
diff -N pcsc-lite/patches/patch-src-sys_unix_c
--- pcsc-lite/patches/patch-src-sys_unix_c      25 Dec 2005 09:13:57 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-$OpenBSD: patch-src-sys_unix_c,v 1.2 2005/12/25 09:13:57 sturm Exp $
---- src/sys_unix.c.orig        Wed Nov  7 23:54:32 2001
-+++ src/sys_unix.c     Sun Dec 25 10:08:58 2005
-@@ -128,7 +128,7 @@ void *SYS_MemoryMap( int iSize, int iFid
-   /* Here are some common error types:
-   switch( errno ) {
-   case EINVAL:
--    printf("EINVAL\n");
-+    printf("EINVAL");
-   case EBADF:
-     printf("EBADF");
-     break;
-@@ -169,7 +169,11 @@ int SYS_Wait( int iPid, int iWait ) {
-  return waitpid( -1, 0, WNOHANG );
- }
- 
--int SYS_Stat( int iFd ) {
-+int SYS_Stat( char *pcFile, struct stat *psStatus ) {
-+  return stat( pcFile, psStatus );
-+}
-+
-+int SYS_Fstat( int iFd ) {
-   struct stat sStatus;
-   return fstat( iFd, &sStatus );
- }
-@@ -205,5 +209,15 @@ int SYS_GetSeed() {
- 
- int SYS_Exit( int iRetVal ) {
-   _exit( iRetVal );
-+}
-+
-+int SYS_Rmdir( char *pcFile )
-+{
-+      return rmdir(pcFile);
-+}
-+
-+int SYS_Unlink( char *pcFile )
-+{
-+      return unlink(pcFile);
- }
- 
Index: pcsc-lite/patches/patch-src-utils-installifs_c
===================================================================
RCS file: pcsc-lite/patches/patch-src-utils-installifs_c
diff -N pcsc-lite/patches/patch-src-utils-installifs_c
--- pcsc-lite/patches/patch-src-utils-installifs_c      25 Dec 2005 09:13:57 
-0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-src-utils-installifs_c,v 1.2 2005/12/25 09:13:57 sturm Exp $
---- src/utils/installifd.c.orig        Wed Nov  7 23:54:32 2001
-+++ src/utils/installifd.c     Sun Dec 25 10:08:58 2005
-@@ -107,12 +107,12 @@ int main(int argc, char **argv) {
- 
- 
-   printf("\n\n");
--  printf("Now creating new /etc/reader.conf: \n");
-+  printf("Now creating new /etc/pcscd/reader.conf: \n");
- 
--  fd = fopen("/etc/reader.conf", "w" );
-+  fd = fopen("/etc/pcscd/reader.conf", "w" );
- 
-   if ( fd == 0 ) {
--    printf("Cannot open file /etc/reader.conf (are you root ?)\n");
-+    printf("Cannot open file /etc/pcscd/reader.conf (are you root ?)\n");
-     free(lpcPortID);
-     return 1;
-   }
Index: pcsc-lite/patches/patch-src_Makefile_in
===================================================================
RCS file: pcsc-lite/patches/patch-src_Makefile_in
diff -N pcsc-lite/patches/patch-src_Makefile_in
--- pcsc-lite/patches/patch-src_Makefile_in     25 Dec 2005 11:15:34 -0000      
1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-$OpenBSD: patch-src_Makefile_in,v 1.1 2005/12/25 11:15:34 sturm Exp $
---- src/Makefile.in.orig       Sun Dec 25 11:33:49 2005
-+++ src/Makefile.in    Sun Dec 25 11:34:06 2005
-@@ -121,7 +121,8 @@ TESTS = testpcsc
- libpcsclite_core_la_SOURCES = configfile.l bundleparser.l     winscard.c 
eventhandler.c ifdwrapper.c atrhandler.c prothandler.c       readerfactory.c 
winscard_msg.c debuglog.c $(PCSC_SYSTEM_SOURCE)         $(PCSC_THREAD_SOURCE) 
$(PCSC_HOTPLUG_SOURCE) $(PCSC_DYNLOAD_SOURCE)
- 
- 
--libpcsclite_core_la_LDFLAGS = -version-info 0:2:0 $(PCSC_INCLUDE_LIBS)
-+libpcsclite_core_la_LDFLAGS = ${librealpcsclite_core_la_LDFLAGS} \
-+      $(PCSC_INCLUDE_LIBS)
- 
- libpcsclite_la_SOURCES = winscard_clnt.c debuglog.c $(PCSC_SYSTEM_SOURCE)     
                 winscard_msg.c $(PCSC_CLIENT)
- 
Index: pcsc-lite/patches/patch-src_spy_Makefile_in
===================================================================
RCS file: pcsc-lite/patches/patch-src_spy_Makefile_in
diff -N pcsc-lite/patches/patch-src_spy_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pcsc-lite/patches/patch-src_spy_Makefile_in 12 Jul 2012 09:01:42 -0000
@@ -0,0 +1,20 @@
+$OpenBSD$
+--- src/spy/Makefile.in.orig   Mon Jul  9 13:33:21 2012
++++ src/spy/Makefile.in        Mon Jul  9 13:33:58 2012
+@@ -293,7 +293,6 @@ dist_bin_SCRIPTS = pcsc-spy
+ libpcscspy_la_SOURCES = \
+       libpcscspy.c
+ 
+-libpcscspy_la_LIBADD = -ldl
+ man_MANS = pcsc-spy.1
+ EXTRA_DIST = install_spy.sh uninstall_spy.sh pcsc-spy.pod
+ CLEANFILES = pcsc-spy.1
+@@ -364,7 +363,7 @@ clean-libLTLIBRARIES:
+         rm -f "$${dir}/so_locations"; \
+       done
+ libpcscspy.la: $(libpcscspy_la_OBJECTS) $(libpcscspy_la_DEPENDENCIES) 
$(EXTRA_libpcscspy_la_DEPENDENCIES) 
+-      $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libpcscspy_la_OBJECTS) 
$(libpcscspy_la_LIBADD) $(LIBS)
++      $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libpcscspy_la_OBJECTS) $(LIBS)
+ install-dist_binSCRIPTS: $(dist_bin_SCRIPTS)
+       @$(NORMAL_INSTALL)
+       @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
Index: pcsc-lite/patches/patch-src_spy_libpcscspy_c
===================================================================
RCS file: pcsc-lite/patches/patch-src_spy_libpcscspy_c
diff -N pcsc-lite/patches/patch-src_spy_libpcscspy_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pcsc-lite/patches/patch-src_spy_libpcscspy_c        12 Jul 2012 09:01:42 
-0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+--- src/spy/libpcscspy.c.orig  Mon Jul  9 16:54:38 2012
++++ src/spy/libpcscspy.c       Mon Jul  9 16:56:12 2012
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <sys/time.h>
+ #include <pthread.h>
++#include <inttypes.h>
+ 
+ #include "misc.h"
+ #include <winscard.h>
+@@ -168,7 +169,7 @@ static void spy_line_direct(char *line)
+       if (Log_fd < 0)
+               return;
+ 
+-      snprintf(threadid, sizeof threadid, "%lX@", pthread_self());
++      snprintf(threadid, sizeof threadid, "%" PRIXPTR "@", 
(uintptr_t)pthread_self());
+       pthread_mutex_lock(&Log_fd_mutex);
+       write(Log_fd, threadid, strlen(threadid));
+       write(Log_fd, line, strlen(line));
+@@ -194,7 +195,7 @@ static void spy_line(const char *fmt, ...)
+               printf("libpcsc-spy: Buffer is too small!\n");
+               return;
+       }
+-      snprintf(threadid, sizeof threadid, "%lX@", pthread_self());
++      snprintf(threadid, sizeof threadid, "%" PRIXPTR "@", 
(uintptr_t)pthread_self());
+       pthread_mutex_lock(&Log_fd_mutex);
+       write(Log_fd, threadid, strlen(threadid));
+       write(Log_fd, line, size);
Index: pcsc-lite/pkg/DESCR
===================================================================
RCS file: /cvs/ports/security/pcsc-lite/pkg/DESCR,v
retrieving revision 1.2
diff -u -p -r1.2 DESCR
--- pcsc-lite/pkg/DESCR 15 Dec 2003 21:55:22 -0000      1.2
+++ pcsc-lite/pkg/DESCR 12 Jul 2012 09:01:42 -0000
@@ -1,4 +1,4 @@
-PC/SC Architecture for most Unix type operating systems.  Allows
-easy porting of Windows smartcard software to other operating
-systems.  Supports many types of serial, PCMCIA, and USB smartcard
-readers and cryptographic tokens.
+PC/SC Architecture for most Unix type operating systems.
+It allows easy porting of Windows smartcard software to other
+operating systems. It supports many types of serial, PCMCIA, and
+USB smartcard readers and cryptographic tokens.
Index: pcsc-lite/pkg/PFRAG.shared
===================================================================
RCS file: /cvs/ports/security/pcsc-lite/pkg/PFRAG.shared,v
retrieving revision 1.3
diff -u -p -r1.3 PFRAG.shared
--- pcsc-lite/pkg/PFRAG.shared  25 Dec 2005 11:15:34 -0000      1.3
+++ pcsc-lite/pkg/PFRAG.shared  12 Jul 2012 09:01:42 -0000
@@ -1,3 +1,3 @@
 @comment $OpenBSD: PFRAG.shared,v 1.3 2005/12/25 11:15:34 sturm Exp $
-@lib lib/libpcsclite-core.so.${LIBpcsclite-core_VERSION}
 @lib lib/libpcsclite.so.${LIBpcsclite_VERSION}
+@lib lib/libpcscspy.so.${LIBpcscspy_VERSION}
Index: pcsc-lite/pkg/PLIST
===================================================================
RCS file: /cvs/ports/security/pcsc-lite/pkg/PLIST,v
retrieving revision 1.3
diff -u -p -r1.3 PLIST
--- pcsc-lite/pkg/PLIST 4 Oct 2004 19:56:28 -0000       1.3
+++ pcsc-lite/pkg/PLIST 12 Jul 2012 09:01:42 -0000
@@ -1,30 +1,22 @@
 @comment $OpenBSD: PLIST,v 1.3 2004/10/04 19:56:28 xsa Exp $
-include/atrhandler.h
-include/configfile.h
-include/debuglog.h
-include/dyn_generic.h
-include/eventhandler.h
-include/hotplug.h
-include/ifdhandler.h
-include/ifdwrapper.h
-include/pcsclite.h
-include/prothandler.h
-include/readerfactory.h
-include/sys_generic.h
-include/thread_generic.h
-include/winscard.h
-include/winscard_msg.h
-include/winscard_svc.h
-include/wintypes.h
-lib/libpcsclite-core.a
-lib/libpcsclite-core.la
+%%SHARED%%
+bin/pcsc-spy
+include/PCSC/
+include/PCSC/debuglog.h
+include/PCSC/ifdhandler.h
+include/PCSC/pcsclite.h
+include/PCSC/reader.h
+include/PCSC/winscard.h
+include/PCSC/wintypes.h
 lib/libpcsclite.a
 lib/libpcsclite.la
-sbin/pcscd
-share/examples/pcscd/
-share/examples/pcscd/reader.conf.sample
-@mode 711
-@sample ${SYSCONFDIR}/pcscd/
-@mode
-@sample ${SYSCONFDIR}/pcscd/reader.conf
-%%SHARED%%
+lib/libpcscspy.a
+lib/libpcscspy.la
+lib/pkgconfig/libpcsclite.pc
+@man man/man1/pcsc-spy.1
+@man man/man5/reader.conf.5
+@man man/man8/pcscd.8
+@bin sbin/pcscd
+@comment share/doc/pcsc-lite/
+@comment share/doc/pcsc-lite/README.DAEMON
+@rcscript ${RCDIR}/pcscd
Index: pcsc-lite/pkg/pcscd.rc
===================================================================
RCS file: pcsc-lite/pkg/pcscd.rc
diff -N pcsc-lite/pkg/pcscd.rc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pcsc-lite/pkg/pcscd.rc      12 Jul 2012 09:01:42 -0000
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# $OpenBSD$
+
+daemon="${TRUEPREFIX}/sbin/pcscd"
+
+. /etc/rc.d/rc.subr
+
+rc_reload=NO
+
+rc_cmd $1

Reply via email to