]> TLD Linux GIT Repositories - packages/pcsc-lite.git/blob - noautostart.patch
- merged 2.0.1 from PLD
[packages/pcsc-lite.git] / noautostart.patch
1 # Disable pcscd on-demand startup (#653903)
2 https://bugzilla.redhat.com/show_bug.cgi?id=653903
3
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 @@
7         LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
8  {
9         LONG rv;
10 -       int daemon_launched = FALSE;
11 -       int retries = 0;
12  
13         API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
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 -                       {
54 -                               int i, max;
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 */
67 -                               execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,
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  
87 @@ -526,15 +462,6 @@
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)
102         API_TRACE_OUT("%ld", *phContext)