mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-09 21:28:51 +01:00
Revert SCD changes of 2010-05-03 (scd/ChangeLog 2010-03-17).
* scd/apdu.c (pcsc_no_service): Remove. (open_pcsc_reader_direct, open_pcsc_reader_wrapped): Remove pcsc_no_service support. (apdu_open_reader): Remove R_NO_SERVICE. * scd/apdu.h (apdu_open_reader): Remove R_NO_SERVICE. * scd/command.c (reader_disabled): Remove. (get_reader_slot): Follow the change of R_NO_SERVICE. (open_card, cmd_serialno, scd_command_handler): Remove reader_disabled support. * scd/sc-copykeys.c (main): Follow the change of R_NO_SERVICE. -- Daemon should handle all possible cases. Even if such a difficult case like reader_disabled, it should not exit.
This commit is contained in:
parent
9afd2bb7fb
commit
0d7cf7bb06
27
scd/apdu.c
27
scd/apdu.c
@ -305,9 +305,6 @@ long (* DLSTDCALL pcsc_control) (unsigned long card,
|
|||||||
unsigned long recv_len,
|
unsigned long recv_len,
|
||||||
unsigned long *bytes_returned);
|
unsigned long *bytes_returned);
|
||||||
|
|
||||||
/* Flag set if PC/SC returned the no-service error. */
|
|
||||||
static int pcsc_no_service;
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes. */
|
/* Prototypes. */
|
||||||
static int pcsc_get_status (int slot, unsigned int *status);
|
static int pcsc_get_status (int slot, unsigned int *status);
|
||||||
@ -1712,11 +1709,8 @@ open_pcsc_reader_direct (const char *portstr)
|
|||||||
pcsc_error_string (err), err);
|
pcsc_error_string (err), err);
|
||||||
reader_table[slot].used = 0;
|
reader_table[slot].used = 0;
|
||||||
unlock_slot (slot);
|
unlock_slot (slot);
|
||||||
if (err == PCSC_E_NO_SERVICE)
|
|
||||||
pcsc_no_service = 1;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pcsc_no_service = 0;
|
|
||||||
|
|
||||||
err = pcsc_list_readers (reader_table[slot].pcsc.context,
|
err = pcsc_list_readers (reader_table[slot].pcsc.context,
|
||||||
NULL, NULL, &nreader);
|
NULL, NULL, &nreader);
|
||||||
@ -1820,7 +1814,6 @@ open_pcsc_reader_wrapped (const char *portstr)
|
|||||||
{
|
{
|
||||||
log_error ("can't run PC/SC access module `%s': %s\n",
|
log_error ("can't run PC/SC access module `%s': %s\n",
|
||||||
wrapperpgm, strerror (errno));
|
wrapperpgm, strerror (errno));
|
||||||
pcsc_no_service = 1;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1920,8 +1913,6 @@ open_pcsc_reader_wrapped (const char *portstr)
|
|||||||
;
|
;
|
||||||
#undef WAIT
|
#undef WAIT
|
||||||
|
|
||||||
pcsc_no_service = 1;
|
|
||||||
|
|
||||||
/* Now send the open request. */
|
/* Now send the open request. */
|
||||||
msgbuf[0] = 0x01; /* OPEN command. */
|
msgbuf[0] = 0x01; /* OPEN command. */
|
||||||
len = portstr? strlen (portstr):0;
|
len = portstr? strlen (portstr):0;
|
||||||
@ -1954,15 +1945,11 @@ open_pcsc_reader_wrapped (const char *portstr)
|
|||||||
{
|
{
|
||||||
log_error ("PC/SC returned a too large ATR (len=%lx)\n",
|
log_error ("PC/SC returned a too large ATR (len=%lx)\n",
|
||||||
(unsigned long)len);
|
(unsigned long)len);
|
||||||
pcsc_no_service = 0;
|
|
||||||
goto command_failed;
|
goto command_failed;
|
||||||
}
|
}
|
||||||
err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16)
|
err = PCSC_ERR_MASK ((msgbuf[5] << 24) | (msgbuf[6] << 16)
|
||||||
| (msgbuf[7] << 8 ) | msgbuf[8]);
|
| (msgbuf[7] << 8 ) | msgbuf[8]);
|
||||||
|
|
||||||
if (err != PCSC_E_NO_SERVICE)
|
|
||||||
pcsc_no_service = 0;
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
log_error ("PC/SC OPEN failed: %s (0x%08x)\n",
|
log_error ("PC/SC OPEN failed: %s (0x%08x)\n",
|
||||||
@ -2803,18 +2790,14 @@ open_rapdu_reader (int portno,
|
|||||||
error. If PORTSTR is NULL we default to a suitable port (for ctAPI:
|
error. If PORTSTR is NULL we default to a suitable port (for ctAPI:
|
||||||
the first USB reader. For PC/SC the first listed reader). */
|
the first USB reader. For PC/SC the first listed reader). */
|
||||||
int
|
int
|
||||||
apdu_open_reader (const char *portstr, int *r_no_service)
|
apdu_open_reader (const char *portstr)
|
||||||
{
|
{
|
||||||
static int pcsc_api_loaded, ct_api_loaded;
|
static int pcsc_api_loaded, ct_api_loaded;
|
||||||
int slot;
|
|
||||||
|
|
||||||
if (r_no_service)
|
|
||||||
*r_no_service = 0;
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB
|
#ifdef HAVE_LIBUSB
|
||||||
if (!opt.disable_ccid)
|
if (!opt.disable_ccid)
|
||||||
{
|
{
|
||||||
int i;
|
int slot, i;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
slot = open_ccid_reader (portstr);
|
slot = open_ccid_reader (portstr);
|
||||||
@ -2947,11 +2930,7 @@ apdu_open_reader (const char *portstr, int *r_no_service)
|
|||||||
pcsc_api_loaded = 1;
|
pcsc_api_loaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
slot = open_pcsc_reader (portstr);
|
return open_pcsc_reader (portstr);
|
||||||
if (slot == -1 && r_no_service && pcsc_no_service)
|
|
||||||
*r_no_service = 1;
|
|
||||||
|
|
||||||
return slot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ enum {
|
|||||||
|
|
||||||
|
|
||||||
/* Note, that apdu_open_reader returns no status word but -1 on error. */
|
/* Note, that apdu_open_reader returns no status word but -1 on error. */
|
||||||
int apdu_open_reader (const char *portstr, int *r_no_service);
|
int apdu_open_reader (const char *portstr);
|
||||||
int apdu_open_remote_reader (const char *portstr,
|
int apdu_open_remote_reader (const char *portstr,
|
||||||
const unsigned char *cookie, size_t length,
|
const unsigned char *cookie, size_t length,
|
||||||
int (*readfnc) (void *opaque,
|
int (*readfnc) (void *opaque,
|
||||||
|
@ -74,10 +74,6 @@
|
|||||||
&& (c)->reader_slot == locked_session->ctrl_backlink->reader_slot)
|
&& (c)->reader_slot == locked_session->ctrl_backlink->reader_slot)
|
||||||
|
|
||||||
|
|
||||||
/* Flag indicating that the reader has been disabled. */
|
|
||||||
static int reader_disabled;
|
|
||||||
|
|
||||||
|
|
||||||
/* This structure is used to keep track of open readers (slots). */
|
/* This structure is used to keep track of open readers (slots). */
|
||||||
struct slot_status_s
|
struct slot_status_s
|
||||||
{
|
{
|
||||||
@ -414,14 +410,7 @@ get_reader_slot (void)
|
|||||||
/* Try to open the reader. */
|
/* Try to open the reader. */
|
||||||
if (ss->slot == -1)
|
if (ss->slot == -1)
|
||||||
{
|
{
|
||||||
int no_service_flag;
|
ss->slot = apdu_open_reader (opt.reader_port);
|
||||||
ss->slot = apdu_open_reader (opt.reader_port, &no_service_flag);
|
|
||||||
|
|
||||||
if (no_service_flag)
|
|
||||||
{
|
|
||||||
log_info ("no card services - disabling scdaemon\n");
|
|
||||||
reader_disabled = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we still don't have a slot, we have no readers.
|
/* If we still don't have a slot, we have no readers.
|
||||||
Invalidate for now until a reader is attached. */
|
Invalidate for now until a reader is attached. */
|
||||||
@ -444,9 +433,6 @@ open_card (ctrl_t ctrl, const char *apptype)
|
|||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
if (reader_disabled)
|
|
||||||
return gpg_error (GPG_ERR_NOT_OPERATIONAL);
|
|
||||||
|
|
||||||
/* If we ever got a card not present error code, return that. Only
|
/* If we ever got a card not present error code, return that. Only
|
||||||
the SERIALNO command and a reset are able to clear from that
|
the SERIALNO command and a reset are able to clear from that
|
||||||
state. */
|
state. */
|
||||||
@ -479,7 +465,7 @@ open_card (ctrl_t ctrl, const char *apptype)
|
|||||||
slot = get_reader_slot ();
|
slot = get_reader_slot ();
|
||||||
ctrl->reader_slot = slot;
|
ctrl->reader_slot = slot;
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
err = gpg_error (reader_disabled? GPG_ERR_NOT_OPERATIONAL: GPG_ERR_CARD);
|
err = gpg_error (GPG_ERR_CARD);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Fixme: We should move the apdu_connect call to
|
/* Fixme: We should move the apdu_connect call to
|
||||||
@ -537,7 +523,7 @@ cmd_serialno (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
/* Clear the remove flag so that the open_card is able to reread it. */
|
/* Clear the remove flag so that the open_card is able to reread it. */
|
||||||
retry:
|
retry:
|
||||||
if (!reader_disabled && ctrl->server_local->card_removed)
|
if (ctrl->server_local->card_removed)
|
||||||
{
|
{
|
||||||
if ( IS_LOCKED (ctrl) )
|
if ( IS_LOCKED (ctrl) )
|
||||||
return gpg_error (GPG_ERR_LOCKED);
|
return gpg_error (GPG_ERR_LOCKED);
|
||||||
@ -2066,7 +2052,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
|
|||||||
BUG ();
|
BUG ();
|
||||||
sl->next_session = ctrl->server_local->next_session;
|
sl->next_session = ctrl->server_local->next_session;
|
||||||
}
|
}
|
||||||
stopme = ctrl->server_local->stopme || reader_disabled;
|
stopme = ctrl->server_local->stopme;
|
||||||
xfree (ctrl->server_local);
|
xfree (ctrl->server_local);
|
||||||
ctrl->server_local = NULL;
|
ctrl->server_local = NULL;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ main (int argc, char **argv )
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
usage (1);
|
usage (1);
|
||||||
|
|
||||||
slot = apdu_open_reader (reader_port, NULL);
|
slot = apdu_open_reader (reader_port);
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
exit (1);
|
exit (1);
|
||||||
if (apdu_connect (slot))
|
if (apdu_connect (slot))
|
||||||
|
Loading…
Reference in New Issue
Block a user