mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
Make the inquire cancel fix a little bit more robust.
This commit is contained in:
parent
29af48840f
commit
809dfd70e3
@ -1,3 +1,10 @@
|
|||||||
|
2011-07-27 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* call-scd.c (struct inq_needpin_s): Add field ANY_INQ_SEEN.
|
||||||
|
(inq_needpin): Set it.
|
||||||
|
(agent_card_scd): Send the cancel only if an inquire was actually
|
||||||
|
used.
|
||||||
|
|
||||||
2011-07-09 Ben Kibbey <bjk@luxsci.net>
|
2011-07-09 Ben Kibbey <bjk@luxsci.net>
|
||||||
|
|
||||||
* call-scd.c (agent_card_scd): Send the CANCEL command back to SCD
|
* call-scd.c (agent_card_scd): Send the CANCEL command back to SCD
|
||||||
|
@ -92,6 +92,7 @@ struct inq_needpin_s
|
|||||||
void *getpin_cb_arg;
|
void *getpin_cb_arg;
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -726,6 +727,7 @@ inq_needpin (void *opaque, const char *line)
|
|||||||
size_t pinlen;
|
size_t pinlen;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
parm->any_inq_seen = 1;
|
||||||
if (!strncmp (line, "NEEDPIN", 7) && (line[7] == ' ' || !line[7]))
|
if (!strncmp (line, "NEEDPIN", 7) && (line[7] == ' ' || !line[7]))
|
||||||
{
|
{
|
||||||
line += 7;
|
line += 7;
|
||||||
@ -857,6 +859,7 @@ agent_card_pksign (ctrl_t ctrl,
|
|||||||
inqparm.getpin_cb = getpin_cb;
|
inqparm.getpin_cb = getpin_cb;
|
||||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||||
inqparm.passthru = 0;
|
inqparm.passthru = 0;
|
||||||
|
inqparm.any_inq_seen = 0;
|
||||||
if (ctrl->use_auth_call)
|
if (ctrl->use_auth_call)
|
||||||
snprintf (line, sizeof line, "PKAUTH %s", keyid);
|
snprintf (line, sizeof line, "PKAUTH %s", keyid);
|
||||||
else
|
else
|
||||||
@ -935,6 +938,7 @@ agent_card_pkdecrypt (ctrl_t ctrl,
|
|||||||
inqparm.getpin_cb = getpin_cb;
|
inqparm.getpin_cb = getpin_cb;
|
||||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||||
inqparm.passthru = 0;
|
inqparm.passthru = 0;
|
||||||
|
inqparm.any_inq_seen = 0;
|
||||||
snprintf (line, DIM(line)-1, "PKDECRYPT %s", keyid);
|
snprintf (line, DIM(line)-1, "PKDECRYPT %s", keyid);
|
||||||
line[DIM(line)-1] = 0;
|
line[DIM(line)-1] = 0;
|
||||||
rc = assuan_transact (ctrl->scd_local->ctx, line,
|
rc = assuan_transact (ctrl->scd_local->ctx, line,
|
||||||
@ -1169,14 +1173,20 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
|
|||||||
inqparm.getpin_cb = getpin_cb;
|
inqparm.getpin_cb = getpin_cb;
|
||||||
inqparm.getpin_cb_arg = getpin_cb_arg;
|
inqparm.getpin_cb_arg = getpin_cb_arg;
|
||||||
inqparm.passthru = assuan_context;
|
inqparm.passthru = assuan_context;
|
||||||
|
inqparm.any_inq_seen = 0;
|
||||||
saveflag = assuan_get_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS);
|
saveflag = assuan_get_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS);
|
||||||
assuan_set_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS, 1);
|
assuan_set_flag (ctrl->scd_local->ctx, ASSUAN_CONVEY_COMMENTS, 1);
|
||||||
rc = assuan_transact (ctrl->scd_local->ctx, cmdline,
|
rc = assuan_transact (ctrl->scd_local->ctx, 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 (gpg_err_code(rc) == GPG_ERR_ASS_CANCELED)
|
if (inqparm.any_inq_seen && gpg_err_code(rc) == GPG_ERR_ASS_CANCELED)
|
||||||
{
|
{
|
||||||
|
/* 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");
|
rc = assuan_write_line(ctrl->scd_local->ctx, "CAN");
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
char *line;
|
char *line;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user