mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: Fix cancellation handling for scdaemon.
* agent/call-scd.c (cancel_inquire): Remove. (agent_card_pksign, agent_card_pkdecrypt, agent_card_writekey) (agent_card_scd): Don't call cancel_inquire. -- Since libassuan 2.1.0, cancellation command "CAN" is handled within the library, by assuan_transact. So, cancel_inquire just caused spurious "CAN" command to scdaemon which resulted an error. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
2396055c09
commit
9f5e50e7c8
@ -89,7 +89,6 @@ struct inq_needpin_parm_s
|
||||
const char *getpin_cb_desc;
|
||||
assuan_context_t passthru; /* If not NULL, pass unknown inquiries
|
||||
up to the caller. */
|
||||
int any_inq_seen;
|
||||
|
||||
/* The next fields are used by inq_writekey_parm. */
|
||||
const unsigned char *keydata;
|
||||
@ -727,7 +726,6 @@ inq_needpin (void *opaque, const char *line)
|
||||
size_t pinlen;
|
||||
int rc;
|
||||
|
||||
parm->any_inq_seen = 1;
|
||||
if ((s = has_leading_keyword (line, "NEEDPIN")))
|
||||
{
|
||||
line = s;
|
||||
@ -811,30 +809,6 @@ hash_algo_option (int algo)
|
||||
}
|
||||
|
||||
|
||||
static gpg_error_t
|
||||
cancel_inquire (ctrl_t ctrl, gpg_error_t rc)
|
||||
{
|
||||
gpg_error_t oldrc = rc;
|
||||
|
||||
/* The inquire callback was called and transact returned a
|
||||
cancel error. We assume that the inquired process sent a
|
||||
CANCEL. The passthrough code is not able to pass on the
|
||||
CANCEL and thus scdaemon would stuck on this. As a
|
||||
workaround we send a CANCEL now. */
|
||||
rc = assuan_write_line (ctrl->scd_local->ctx, "CAN");
|
||||
if (!rc) {
|
||||
char *line;
|
||||
size_t len;
|
||||
|
||||
rc = assuan_read_line (ctrl->scd_local->ctx, &line, &len);
|
||||
if (!rc)
|
||||
rc = oldrc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* Create a signature using the current card. MDALGO is either 0 or
|
||||
* gives the digest algorithm. DESC_TEXT is an additional parameter
|
||||
* passed to GETPIN_CB. */
|
||||
@ -875,7 +849,6 @@ agent_card_pksign (ctrl_t ctrl,
|
||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||
inqparm.getpin_cb_desc = desc_text;
|
||||
inqparm.passthru = 0;
|
||||
inqparm.any_inq_seen = 0;
|
||||
inqparm.keydata = NULL;
|
||||
inqparm.keydatalen = 0;
|
||||
|
||||
@ -888,9 +861,6 @@ agent_card_pksign (ctrl_t ctrl,
|
||||
put_membuf_cb, &data,
|
||||
inq_needpin, &inqparm,
|
||||
NULL, NULL);
|
||||
if (inqparm.any_inq_seen && (gpg_err_code(rc) == GPG_ERR_CANCELED ||
|
||||
gpg_err_code(rc) == GPG_ERR_ASS_CANCELED))
|
||||
rc = cancel_inquire (ctrl, rc);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
@ -974,7 +944,6 @@ agent_card_pkdecrypt (ctrl_t ctrl,
|
||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||
inqparm.getpin_cb_desc = desc_text;
|
||||
inqparm.passthru = 0;
|
||||
inqparm.any_inq_seen = 0;
|
||||
inqparm.keydata = NULL;
|
||||
inqparm.keydatalen = 0;
|
||||
snprintf (line, DIM(line), "PKDECRYPT %s", keyid);
|
||||
@ -982,9 +951,6 @@ agent_card_pkdecrypt (ctrl_t ctrl,
|
||||
put_membuf_cb, &data,
|
||||
inq_needpin, &inqparm,
|
||||
padding_info_cb, r_padding);
|
||||
if (inqparm.any_inq_seen && (gpg_err_code(rc) == GPG_ERR_CANCELED ||
|
||||
gpg_err_code(rc) == GPG_ERR_ASS_CANCELED))
|
||||
rc = cancel_inquire (ctrl, rc);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
@ -1111,15 +1077,11 @@ agent_card_writekey (ctrl_t ctrl, int force, const char *serialno,
|
||||
parms.getpin_cb_arg = getpin_cb_arg;
|
||||
parms.getpin_cb_desc= NULL;
|
||||
parms.passthru = 0;
|
||||
parms.any_inq_seen = 0;
|
||||
parms.keydata = keydata;
|
||||
parms.keydatalen = keydatalen;
|
||||
|
||||
rc = assuan_transact (ctrl->scd_local->ctx, line, NULL, NULL,
|
||||
inq_writekey_parms, &parms, NULL, NULL);
|
||||
if (parms.any_inq_seen && (gpg_err_code(rc) == GPG_ERR_CANCELED ||
|
||||
gpg_err_code(rc) == GPG_ERR_ASS_CANCELED))
|
||||
rc = cancel_inquire (ctrl, rc);
|
||||
return unlock_scd (ctrl, rc);
|
||||
}
|
||||
|
||||
@ -1344,7 +1306,6 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
|
||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||
inqparm.getpin_cb_desc = NULL;
|
||||
inqparm.passthru = assuan_context;
|
||||
inqparm.any_inq_seen = 0;
|
||||
inqparm.keydata = NULL;
|
||||
inqparm.keydatalen = 0;
|
||||
|
||||
@ -1354,8 +1315,6 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
|
||||
pass_data_thru, assuan_context,
|
||||
inq_needpin, &inqparm,
|
||||
pass_status_thru, assuan_context);
|
||||
if (inqparm.any_inq_seen && gpg_err_code(rc) == GPG_ERR_ASS_CANCELED)
|
||||
rc = cancel_inquire (ctrl, rc);
|
||||
|
||||
assuan_set_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS, saveflag);
|
||||
if (rc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user