Disabled pcscd on-demand startup (#653903)

This commit is contained in:
Kalev Lember 2010-12-13 00:08:12 +02:00
parent 85c0568314
commit 7d47f6f2cb
2 changed files with 106 additions and 1 deletions

View File

@ -0,0 +1,99 @@
diff -up pcsc-lite-1.6.4/src/winscard_clnt.c.noautostart pcsc-lite-1.6.4/src/winscard_clnt.c
--- pcsc-lite-1.6.4/src/winscard_clnt.c.noautostart 2010-12-12 23:46:43.228293593 +0200
+++ pcsc-lite-1.6.4/src/winscard_clnt.c 2010-12-12 23:52:44.388532774 +0200
@@ -387,79 +387,15 @@ LONG SCardEstablishContext(DWORD dwScope
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
{
LONG rv;
- int daemon_launched = FALSE;
- int retries = 0;
PROFILE_START
-again:
/* 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();
- if (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;
-
- 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 ret, 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 */
- ret = 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, NULL, 0) < 0)
- Log2(PCSC_LOG_CRITICAL, "waitpid failed: %s", strerror(errno));
-
- goto again;
- }
- }
-
if (rv != SCARD_S_SUCCESS)
goto end;
@@ -468,15 +404,6 @@ launch:
pvReserved2, phContext);
(void)SCardUnlockThread();
- /* 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;
- }
-
end:
PROFILE_END(rv)

View File

@ -2,7 +2,7 @@
Name: pcsc-lite
Version: 1.6.4
Release: 1%{?dist}
Release: 2%{?dist}
Summary: PC/SC Lite smart card framework and applications
Group: System Environment/Daemons
@ -12,6 +12,8 @@ Source0: http://alioth.debian.org/download.php/%{upstream_build}/%{name}-
Source1: pcscd.init
Patch0: %{name}-1.4-docinst.patch
Patch1: %{name}-1.5.5-rpath64.patch
# Disable pcscd on-demand startup (#653903)
Patch2: %{name}-1.6.4-noautostart.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: hal-devel
@ -63,6 +65,7 @@ Requires: %{name}-libs = %{version}-%{release}
%setup -q
%patch0 -p0 -b .docinst
%patch1 -p1 -b .rpath64
%patch2 -p1 -b .noautostart
# Convert to utf-8
for file in ChangeLog; do
@ -143,6 +146,9 @@ fi
%changelog
* Mon Dec 13 2010 Kalev Lember <kalev@smartlink.ee> - 1.6.4-2
- Disabled pcscd on-demand startup (#653903)
* Sun Aug 15 2010 Kalev Lember <kalev@smartlink.ee> - 1.6.4-1
- Update to 1.6.4
- Buildrequire graphviz for apidoc generation