1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd,pcsc: Support "reader-port" option for PC/SC reader.

* scd/apdu.c (apdu_open_reader): Skip use of a reader if it's not the
one specified when it is specified.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-09-12 09:30:37 +09:00
parent c569e49d17
commit 6d750fe7fc

View File

@ -2058,10 +2058,6 @@ int
apdu_open_reader (struct dev_list *dl)
{
int slot;
#ifdef HAVE_LIBUSB
if (!opt.disable_ccid)
{ /* CCID readers. */
int readerno;
if (!dl->table)
@ -2075,27 +2071,24 @@ apdu_open_reader (struct dev_list *dl)
else if (dl->portstr)
{
readerno = atoi (dl->portstr);
if (readerno < 0)
{
return -1;
}
}
else
readerno = 0; /* Default. */
if (readerno > 0)
{ /* Use single, the specific reader. */
if (readerno >= dl->idx_max)
if (readerno < 0 || readerno >= dl->idx_max)
return -1;
dl->idx = readerno;
dl->portstr = NULL;
slot = open_ccid_reader (dl);
dl->idx = dl->idx_max;
if (slot >= 0)
return slot;
}
else
return -1;
readerno = 0; /* Default. */
#ifdef HAVE_LIBUSB
if (!opt.disable_ccid)
{ /* CCID readers. */
if (readerno > 0)
{ /* Use single, the specific reader. */
slot = open_ccid_reader (dl);
/* And stick the reader and no scan. */
dl->idx = dl->idx_max;
return slot;
}
while (dl->idx < dl->idx_max)
@ -2139,6 +2132,14 @@ apdu_open_reader (struct dev_list *dl)
else
#endif
{ /* PC/SC readers. */
if (readerno > 0)
{ /* Use single, the specific reader. */
slot = open_pcsc_reader (pcsc.rdrname[readerno]);
/* And stick the reader and no scan. */
dl->idx = dl->idx_max;
return slot;
}
while (dl->idx < dl->idx_max)
{
const char *rdrname = pcsc.rdrname[dl->idx];
@ -2157,6 +2158,10 @@ apdu_open_reader (struct dev_list *dl)
if (DBG_READER)
log_debug ("apdu_open_reader: new device=%s\n", rdrname);
/* When reader string is specified, check if it is the one. */
if (readerno < 0 && strcmp (rdrname, dl->portstr) != 0)
continue;
slot = open_pcsc_reader (rdrname);
dl->idx++;