mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +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. -- Cherry-picked master commit of: 9f5e50e7c85aa8b847d38010241ed570ac114fc3 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
90e5f49b6a
commit
005e951714
@ -89,7 +89,6 @@ struct inq_needpin_parm_s
|
|||||||
const char *getpin_cb_desc;
|
const char *getpin_cb_desc;
|
||||||
assuan_context_t passthru; /* If not NULL, pass unknown inquiries
|
assuan_context_t passthru; /* If not NULL, pass unknown inquiries
|
||||||
up to the caller. */
|
up to the caller. */
|
||||||
int any_inq_seen;
|
|
||||||
|
|
||||||
/* The next fields are used by inq_writekey_parm. */
|
/* The next fields are used by inq_writekey_parm. */
|
||||||
const unsigned char *keydata;
|
const unsigned char *keydata;
|
||||||
@ -727,7 +726,6 @@ inq_needpin (void *opaque, const char *line)
|
|||||||
size_t pinlen;
|
size_t pinlen;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
parm->any_inq_seen = 1;
|
|
||||||
if ((s = has_leading_keyword (line, "NEEDPIN")))
|
if ((s = has_leading_keyword (line, "NEEDPIN")))
|
||||||
{
|
{
|
||||||
line = s;
|
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
|
/* Create a signature using the current card. MDALGO is either 0 or
|
||||||
* gives the digest algorithm. DESC_TEXT is an additional parameter
|
* gives the digest algorithm. DESC_TEXT is an additional parameter
|
||||||
* passed to GETPIN_CB. */
|
* passed to GETPIN_CB. */
|
||||||
@ -875,7 +849,6 @@ agent_card_pksign (ctrl_t ctrl,
|
|||||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||||
inqparm.getpin_cb_desc = desc_text;
|
inqparm.getpin_cb_desc = desc_text;
|
||||||
inqparm.passthru = 0;
|
inqparm.passthru = 0;
|
||||||
inqparm.any_inq_seen = 0;
|
|
||||||
inqparm.keydata = NULL;
|
inqparm.keydata = NULL;
|
||||||
inqparm.keydatalen = 0;
|
inqparm.keydatalen = 0;
|
||||||
|
|
||||||
@ -888,9 +861,6 @@ agent_card_pksign (ctrl_t ctrl,
|
|||||||
put_membuf_cb, &data,
|
put_membuf_cb, &data,
|
||||||
inq_needpin, &inqparm,
|
inq_needpin, &inqparm,
|
||||||
NULL, NULL);
|
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)
|
if (rc)
|
||||||
{
|
{
|
||||||
@ -974,7 +944,6 @@ agent_card_pkdecrypt (ctrl_t ctrl,
|
|||||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||||
inqparm.getpin_cb_desc = desc_text;
|
inqparm.getpin_cb_desc = desc_text;
|
||||||
inqparm.passthru = 0;
|
inqparm.passthru = 0;
|
||||||
inqparm.any_inq_seen = 0;
|
|
||||||
inqparm.keydata = NULL;
|
inqparm.keydata = NULL;
|
||||||
inqparm.keydatalen = 0;
|
inqparm.keydatalen = 0;
|
||||||
snprintf (line, DIM(line), "PKDECRYPT %s", keyid);
|
snprintf (line, DIM(line), "PKDECRYPT %s", keyid);
|
||||||
@ -982,9 +951,6 @@ agent_card_pkdecrypt (ctrl_t ctrl,
|
|||||||
put_membuf_cb, &data,
|
put_membuf_cb, &data,
|
||||||
inq_needpin, &inqparm,
|
inq_needpin, &inqparm,
|
||||||
padding_info_cb, r_padding);
|
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)
|
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_arg = getpin_cb_arg;
|
||||||
parms.getpin_cb_desc= NULL;
|
parms.getpin_cb_desc= NULL;
|
||||||
parms.passthru = 0;
|
parms.passthru = 0;
|
||||||
parms.any_inq_seen = 0;
|
|
||||||
parms.keydata = keydata;
|
parms.keydata = keydata;
|
||||||
parms.keydatalen = keydatalen;
|
parms.keydatalen = keydatalen;
|
||||||
|
|
||||||
rc = assuan_transact (ctrl->scd_local->ctx, line, NULL, NULL,
|
rc = assuan_transact (ctrl->scd_local->ctx, line, NULL, NULL,
|
||||||
inq_writekey_parms, &parms, 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);
|
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_arg = getpin_cb_arg;
|
||||||
inqparm.getpin_cb_desc = NULL;
|
inqparm.getpin_cb_desc = NULL;
|
||||||
inqparm.passthru = assuan_context;
|
inqparm.passthru = assuan_context;
|
||||||
inqparm.any_inq_seen = 0;
|
|
||||||
inqparm.keydata = NULL;
|
inqparm.keydata = NULL;
|
||||||
inqparm.keydatalen = 0;
|
inqparm.keydatalen = 0;
|
||||||
|
|
||||||
@ -1354,8 +1315,6 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
|
|||||||
pass_data_thru, assuan_context,
|
pass_data_thru, assuan_context,
|
||||||
inq_needpin, &inqparm,
|
inq_needpin, &inqparm,
|
||||||
pass_status_thru, assuan_context);
|
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);
|
assuan_set_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS, saveflag);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user