scd,pcsc: Fix for initializing PC/SC.

* scd/apdu.c (pcsc_init): Load it at first.
(apdu_open_reader): Check for the CCID internal driver.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-09-11 10:36:29 +09:00
parent e8534f8999
commit 441106cdf0
1 changed files with 13 additions and 9 deletions

View File

@ -1062,14 +1062,6 @@ pcsc_init (void)
static int pcsc_api_loaded;
long err;
err = pcsc_establish_context (PCSC_SCOPE_SYSTEM, NULL, NULL, &pcsc.context);
if (err)
{
log_error ("pcsc_establish_context failed: %s (0x%lx)\n",
pcsc_error_string (err), err);
return -1;
}
/* Lets try the PC/SC API */
if (!pcsc_api_loaded)
{
@ -1152,6 +1144,15 @@ pcsc_init (void)
return -1;
}
pcsc_api_loaded = 1;
err = pcsc_establish_context (PCSC_SCOPE_SYSTEM, NULL, NULL,
&pcsc.context);
if (err)
{
log_error ("pcsc_establish_context failed: %s (0x%lx)\n",
pcsc_error_string (err), err);
return -1;
}
}
return 0;
@ -2051,10 +2052,13 @@ apdu_open_reader (struct dev_list *dl, int app_empty)
int slot;
#ifdef HAVE_LIBUSB
if (dl->table)
if (!opt.disable_ccid)
{ /* CCID readers. */
int readerno;
if (!dl->table)
return -1;
/* See whether we want to use the reader ID string or a reader
number. A readerno of -1 indicates that the reader ID string is
to be used. */