mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
agent: Minor change for pinentry status handling.
* agent/call-pinentry.c (struct entry_parm_s): Add status. (do_getpin): Use param->status. (agent_askpin): Copy param->status. to pininfo. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
ada797f477
commit
99aa54323f
@ -85,6 +85,7 @@ struct entry_parm_s
|
|||||||
int lines;
|
int lines;
|
||||||
size_t size;
|
size_t size;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
|
int status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -945,19 +946,16 @@ build_cmd_setdesc (char *line, size_t linelen, const char *desc)
|
|||||||
* FIXME: Support EOF detection of the socket: ctrl->thread_startup.fd
|
* FIXME: Support EOF detection of the socket: ctrl->thread_startup.fd
|
||||||
*/
|
*/
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
do_getpin (ctrl_t ctrl, struct entry_parm_s *parm,
|
do_getpin (ctrl_t ctrl, struct entry_parm_s *parm)
|
||||||
struct pin_entry_info_s *pininfo)
|
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int pinentry_status;
|
|
||||||
int saveflag = assuan_get_flag (entry_ctx, ASSUAN_CONFIDENTIAL);
|
int saveflag = assuan_get_flag (entry_ctx, ASSUAN_CONFIDENTIAL);
|
||||||
|
|
||||||
(void)ctrl;
|
(void)ctrl;
|
||||||
assuan_begin_confidential (entry_ctx);
|
assuan_begin_confidential (entry_ctx);
|
||||||
pinentry_status = 0;
|
|
||||||
rc = assuan_transact (entry_ctx, "GETPIN", getpin_cb, parm,
|
rc = assuan_transact (entry_ctx, "GETPIN", getpin_cb, parm,
|
||||||
inq_quality, entry_ctx,
|
inq_quality, entry_ctx,
|
||||||
pinentry_status_cb, &pinentry_status);
|
pinentry_status_cb, &parm->status);
|
||||||
assuan_set_flag (entry_ctx, ASSUAN_CONFIDENTIAL, saveflag);
|
assuan_set_flag (entry_ctx, ASSUAN_CONFIDENTIAL, saveflag);
|
||||||
/* Most pinentries out in the wild return the old Assuan error code
|
/* Most pinentries out in the wild return the old Assuan error code
|
||||||
for canceled which gets translated to an assuan Cancel error and
|
for canceled which gets translated to an assuan Cancel error and
|
||||||
@ -966,13 +964,10 @@ do_getpin (ctrl_t ctrl, struct entry_parm_s *parm,
|
|||||||
rc = gpg_err_make (gpg_err_source (rc), GPG_ERR_CANCELED);
|
rc = gpg_err_make (gpg_err_source (rc), GPG_ERR_CANCELED);
|
||||||
/* Change error code in case the window close button was clicked
|
/* Change error code in case the window close button was clicked
|
||||||
to cancel the operation. */
|
to cancel the operation. */
|
||||||
if ((pinentry_status & PINENTRY_STATUS_CLOSE_BUTTON)
|
if ((parm->status & PINENTRY_STATUS_CLOSE_BUTTON)
|
||||||
&& gpg_err_code (rc) == GPG_ERR_CANCELED)
|
&& gpg_err_code (rc) == GPG_ERR_CANCELED)
|
||||||
rc = gpg_err_make (gpg_err_source (rc), GPG_ERR_FULLY_CANCELED);
|
rc = gpg_err_make (gpg_err_source (rc), GPG_ERR_FULLY_CANCELED);
|
||||||
|
|
||||||
if (pininfo)
|
|
||||||
pininfo->status = pinentry_status;
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,7 +1129,8 @@ agent_askpin (ctrl_t ctrl,
|
|||||||
return unlock_pinentry (ctrl, rc);
|
return unlock_pinentry (ctrl, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = do_getpin (ctrl, &parm, pininfo);
|
rc = do_getpin (ctrl, &parm);
|
||||||
|
pininfo->status = parm.status;
|
||||||
if (gpg_err_code (rc) == GPG_ERR_ASS_TOO_MUCH_DATA)
|
if (gpg_err_code (rc) == GPG_ERR_ASS_TOO_MUCH_DATA)
|
||||||
errtext = is_pin? L_("PIN too long")
|
errtext = is_pin? L_("PIN too long")
|
||||||
: L_("Passphrase too long");
|
: L_("Passphrase too long");
|
||||||
@ -1289,7 +1285,7 @@ agent_get_passphrase (ctrl_t ctrl,
|
|||||||
if (!parm.buffer)
|
if (!parm.buffer)
|
||||||
return unlock_pinentry (ctrl, out_of_core ());
|
return unlock_pinentry (ctrl, out_of_core ());
|
||||||
|
|
||||||
rc = do_getpin (ctrl, &parm, NULL);
|
rc = do_getpin (ctrl, &parm);
|
||||||
if (rc)
|
if (rc)
|
||||||
xfree (parm.buffer);
|
xfree (parm.buffer);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user