[Pcsclite-cvs-commit] r6105 - in /trunk/PCSC: configure.in src/pcscdaemon.c src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Mon Nov 14 10:19:45 UTC 2011
Author: rousseau
Date: Mon Nov 14 10:19:44 2011
New Revision: 6105
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6105
Log:
Remove pcscd autostart feature
The auto start feature (launch pcscd from the library if not already
running) was a fragile code with some issues. This service is far better
implemented by systemd.
Thanks to Kalev Lember for pushing the systemd patches.
Modified:
trunk/PCSC/configure.in
trunk/PCSC/src/pcscdaemon.c
trunk/PCSC/src/winscard_clnt.c
Modified: trunk/PCSC/configure.in
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/configure.in?rev=6105&op=diff
==============================================================================
--- trunk/PCSC/configure.in (original)
+++ trunk/PCSC/configure.in Mon Nov 14 10:19:44 2011
@@ -287,16 +287,6 @@
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
-
-# --disable-autostart
-AC_ARG_ENABLE(autostart,
- AC_HELP_STRING([--disable-autostart], [disable pcscd automatic startup]),
- [ use_autostart="${enableval}" ], [ use_autostart="yes" ] )
-
-if test x$use_autostart != xno; then
- AC_DEFINE(ENABLE_AUTOSTART, 1, [Enable pcscd automatic startup])
- PCSCLITE_FEATURES="${PCSCLITE_FEATURES} autostart"
-fi
# --enable-embedded
AC_ARG_ENABLE(embedded,
@@ -405,7 +395,6 @@
ipcdir: ${ipcdir}
use serial: ${use_serial}
use usb: ${use_usb}
-use autostart: ${use_autostart}
systemd unit directory: ${with_systemdsystemunitdir}
PCSCLITE_FEATURES: ${PCSCLITE_FEATURES}
Modified: trunk/PCSC/src/pcscdaemon.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscdaemon.c?rev=6105&op=diff
==============================================================================
--- trunk/PCSC/src/pcscdaemon.c (original)
+++ trunk/PCSC/src/pcscdaemon.c Mon Nov 14 10:19:44 2011
@@ -516,24 +516,6 @@
#endif
Log1(PCSC_LOG_INFO, "pcsc-lite " VERSION " daemon ready.");
-
- if (AutoExit && !SocketActivated)
- {
- int pid;
-
- /* create a new session so that Ctrl-C on the application will
- * not also quit pcscd */
- setsid();
-
- /* fork() so that pcscd always return in --auto-exit mode */
- pid = fork();
- if (-1 == pid )
- Log2(PCSC_LOG_CRITICAL, "fork() failed: %s", strerror(errno));
-
- if (pid)
- /* father */
- return EXIT_SUCCESS;
- }
/*
* Record our pid to make it easier
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=6105&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Mon Nov 14 10:19:44 2011
@@ -392,26 +392,6 @@
static LONG SCardEstablishContextTH(DWORD, LPCVOID, LPCVOID,
/*@out@*/ LPSCARDCONTEXT);
-static int sd_booted(void) {
-#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
- return 0;
-#else
-
- struct stat a, b;
-
- /* We simply test whether the systemd cgroup hierarchy is
- * mounted */
-
- if (lstat("/sys/fs/cgroup", &a) < 0)
- return 0;
-
- if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
- return 0;
-
- return a.st_dev != b.st_dev;
-#endif
-}
-
/**
* @brief Creates an Application Context to the PC/SC Resource Manager.
*
@@ -449,10 +429,6 @@
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
{
LONG rv;
-#ifdef ENABLE_AUTOSTART
- int daemon_launched = FALSE;
- int retries = 0;
-#endif
static int first_time = TRUE;
API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
@@ -467,92 +443,12 @@
pthread_atfork(NULL, NULL, SCardInvalidateHandles);
}
-#ifdef ENABLE_AUTOSTART
-again:
-#endif
/* Check if the server is running */
rv = SCardCheckDaemonAvailability();
if (SCARD_E_INVALID_HANDLE == rv)
/* we reconnected to a daemon or we got called from a forked child */
rv = SCardCheckDaemonAvailability();
-#ifdef ENABLE_AUTOSTART
- if (!sd_booted() && SCARD_E_NO_SERVICE == rv)
- {
-launch:
- if (daemon_launched)
- {
- retries++;
- if (retries < 50) /* 50 x 100ms = 5 seconds */
- {
- /* give some more time to the server to start */
- SYS_USleep(100*1000); /* 100 ms */
- goto again;
- }
-
- /* the server failed to start (in time) */
- goto end;
- }
- else
- {
- int pid, stat_loc;
- struct stat mystat;
-
- /* If the daemon is not present then just fail without waiting */
- if (stat(PCSCD_BINARY, &mystat))
- {
- Log2(PCSC_LOG_CRITICAL, "stat " PCSCD_BINARY " failed: %s", strerror(errno));
- return SCARD_E_NO_SERVICE;
- }
-
- pid = fork();
-
- if (pid < 0)
- {
- Log2(PCSC_LOG_CRITICAL, "fork failed: %s", strerror(errno));
- rv = SCARD_F_INTERNAL_ERROR;
- goto end;
- }
-
- if (0 == pid)
- {
- int i, max;
- char *param = getenv("PCSCLITE_PCSCD_ARGS");
-
- /* close all file handles except stdin, stdout and
- * stderr so that pcscd does not confiscate ressources
- * allocated by the application */
- max = sysconf(_SC_OPEN_MAX);
- if (-1 == max)
- max = 1024;
- for (i=3; i<max; i++)
- (void)close(i);
-
- /* son process */
- execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,
- (char *)NULL);
- Log2(PCSC_LOG_CRITICAL, "exec " PCSCD_BINARY " failed: %s",
- strerror(errno));
- exit(1);
- }
-
- /* father process */
- daemon_launched = TRUE;
-
- if (waitpid(pid, &stat_loc, 0) < 0)
- Log2(PCSC_LOG_CRITICAL, "waitpid failed: %s", strerror(errno));
- else
- {
- Log2(PCSC_LOG_INFO, "return value: %d", stat_loc);
- if (stat_loc)
- return SCARD_E_NO_SERVICE;
- }
-
- goto again;
- }
- }
-#endif
-
if (rv != SCARD_S_SUCCESS)
goto end;
@@ -560,17 +456,6 @@
rv = SCardEstablishContextTH(dwScope, pvReserved1,
pvReserved2, phContext);
(void)SCardUnlockThread();
-
-#ifdef ENABLE_AUTOSTART
- /* SCardEstablishContextTH may fail if the previous pcscd crashed
- * without cleaning /var/run/pcscd/pcscd.comm */
- if (SCARD_E_NO_SERVICE == rv)
- {
- retries++;
- if (retries <= 1)
- goto launch;
- }
-#endif
end:
PROFILE_END(rv)
More information about the Pcsclite-cvs-commit
mailing list