~ubuntu-branches/ubuntu/lucid/pcsc-lite/lucid-security

« back to all changes in this revision

Viewing changes to src/pcscdaemon.c

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Rousseau
  • Date: 2007-06-19 21:19:54 UTC
  • mfrom: (1.2.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070619211954-h5jtokimr8wrw3oj
Tags: 1.4.3-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Copyright (C) 1999-2007
7
7
 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
8
8
 *
9
 
 * $Id: pcscdaemon.c 2505 2007-04-12 09:41:13Z rousseau $
 
9
 * $Id: pcscdaemon.c 2568 2007-06-19 12:37:13Z rousseau $
10
10
 */
11
11
 
12
12
/**
24
24
#include <signal.h>
25
25
#include <sys/types.h>
26
26
#include <sys/stat.h>
 
27
#include <fcntl.h>
27
28
#include <errno.h>
28
29
#include <stdio.h>
29
30
#include <unistd.h>
174
175
                        rv = CreateContextThread(&dwClientID);
175
176
 
176
177
                        if (rv != SCARD_S_SUCCESS)
177
 
                        {
178
178
                                Log1(PCSC_LOG_ERROR, "Problem during the context thread creation");
179
 
                                AraKiri = TRUE;
180
 
                        }
181
 
 
182
179
                        break;
183
180
 
184
181
                case 2:
228
225
#ifdef HAVE_GETOPT_LONG
229
226
        int option_index = 0;
230
227
        static struct option long_options[] = {
231
 
                {"config", 1, 0, 'c'},
232
 
                {"foreground", 0, 0, 'f'},
233
 
                {"help", 0, 0, 'h'},
234
 
                {"version", 0, 0, 'v'},
235
 
                {"apdu", 0, 0, 'a'},
236
 
                {"debug", 0, 0, 'd'},
237
 
                {"info", 0, 0, 0},
238
 
                {"error", 0, 0, 'e'},
239
 
                {"critical", 0, 0, 'C'},
240
 
                {"hotplug", 0, 0, 'H'},
241
 
                {"force-reader-polling", optional_argument, 0, 0},
242
 
                {0, 0, 0, 0}
 
228
                {"config", 1, NULL, 'c'},
 
229
                {"foreground", 0, NULL, 'f'},
 
230
                {"help", 0, NULL, 'h'},
 
231
                {"version", 0, NULL, 'v'},
 
232
                {"apdu", 0, NULL, 'a'},
 
233
                {"debug", 0, NULL, 'd'},
 
234
                {"info", 0, NULL, 0},
 
235
                {"error", 0, NULL, 'e'},
 
236
                {"critical", 0, NULL, 'C'},
 
237
                {"hotplug", 0, NULL, 'H'},
 
238
                {"force-reader-polling", optional_argument, NULL, 0},
 
239
                {NULL, 0, NULL, 0}
243
240
        };
244
241
#endif
245
242
#define OPT_STRING "c:fdhvaeCH"
425
422
         * to kill the correct pcscd
426
423
         */
427
424
        {
428
 
                FILE *f;
 
425
                int f;
429
426
 
430
 
                if ((f = fopen(USE_RUN_PID, "wb")) != NULL)
 
427
                if ((f = SYS_OpenFile(USE_RUN_PID, O_RDWR | O_CREAT, 00644)) != -1)
431
428
                {
432
 
                        fprintf(f, "%u\n", (unsigned) getpid());
433
 
                        fclose(f);
 
429
                        char pid[PID_ASCII_SIZE];
 
430
 
 
431
                        snprintf(pid, sizeof(pid), "%u", (unsigned) getpid());
 
432
                        SYS_WriteFile(f, pid, strlen(pid));
 
433
                        SYS_CloseFile(f);
 
434
 
 
435
                        /* set mode so that the file is world readable.
 
436
                         * The file is used by libpcsclite */
 
437
                        SYS_Chmod(USE_RUN_PID, 0644);
434
438
                }
 
439
                else
 
440
                        Log2(PCSC_LOG_CRITICAL, "cannot create " USE_RUN_PID ": %s",
 
441
                                strerror(errno));
435
442
        }
436
443
 
437
444
        /*