]> git.pld-linux.org Git - packages/pcsc-lite.git/blame - noautostart.patch
- sorted BRs
[packages/pcsc-lite.git] / noautostart.patch
CommitLineData
10f2ab78
ER
1# Disable pcscd on-demand startup (#653903)
2https://bugzilla.redhat.com/show_bug.cgi?id=653903
3
6534d619
JB
4--- pcsc-lite-1.7.0/src/winscard_clnt.c.orig 2011-02-22 23:20:25.000000000 +0100
5+++ pcsc-lite-1.7.0/src/winscard_clnt.c 2011-03-18 16:44:57.275416294 +0100
6@@ -444,80 +444,16 @@
10f2ab78
ER
7 LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
8 {
9 LONG rv;
10- int daemon_launched = FALSE;
11- int retries = 0;
12
6534d619 13 API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
10f2ab78
ER
14 PROFILE_START
15
16-again:
17 /* Check if the server is running */
18 rv = SCardCheckDaemonAvailability();
19 if (SCARD_E_INVALID_HANDLE == rv)
20 /* we reconnected to a daemon or we got called from a forked child */
21 rv = SCardCheckDaemonAvailability();
22
23- if (SCARD_E_NO_SERVICE == rv)
24- {
25-launch:
26- if (daemon_launched)
27- {
28- retries++;
29- if (retries < 50) /* 50 x 100ms = 5 seconds */
30- {
31- /* give some more time to the server to start */
32- SYS_USleep(100*1000); /* 100 ms */
33- goto again;
34- }
35-
36- /* the server failed to start (in time) */
37- goto end;
38- }
39- else
40- {
41- int pid;
42-
43- pid = fork();
44-
45- if (pid < 0)
46- {
47- Log2(PCSC_LOG_CRITICAL, "fork failed: %s", strerror(errno));
48- rv = SCARD_F_INTERNAL_ERROR;
49- goto end;
50- }
51-
52- if (0 == pid)
53- {
6534d619 54- int i, max;
10f2ab78
ER
55- char *param = getenv("PCSCLITE_PCSCD_ARGS");
56-
57- /* close all file handles except stdin, stdout and
58- * stderr so that pcscd does not confiscate ressources
59- * allocated by the application */
60- max = sysconf(_SC_OPEN_MAX);
61- if (-1 == max)
62- max = 1024;
63- for (i=3; i<max; i++)
64- (void)close(i);
65-
66- /* son process */
6534d619 67- execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,
10f2ab78
ER
68- (char *)NULL);
69- Log2(PCSC_LOG_CRITICAL, "exec " PCSCD_BINARY " failed: %s",
70- strerror(errno));
71- exit(1);
72- }
73-
74- /* father process */
75- daemon_launched = TRUE;
76-
77- if (waitpid(pid, NULL, 0) < 0)
78- Log2(PCSC_LOG_CRITICAL, "waitpid failed: %s", strerror(errno));
79-
80- goto again;
81- }
82- }
83-
84 if (rv != SCARD_S_SUCCESS)
85 goto end;
86
6534d619 87@@ -526,15 +462,6 @@
10f2ab78
ER
88 pvReserved2, phContext);
89 (void)SCardUnlockThread();
90
91- /* SCardEstablishContextTH may fail if the previous pcscd crashed
92- * without cleaning /var/run/pcscd/pcscd.comm */
93- if (SCARD_E_NO_SERVICE == rv)
94- {
95- retries++;
96- if (retries <= 1)
97- goto launch;
98- }
99-
100 end:
101 PROFILE_END(rv)
6534d619 102 API_TRACE_OUT("%ld", *phContext)
This page took 0.616206 seconds and 4 git commands to generate.