From 108c22c9c50a4aa6f5d106d1d830c6d32b0bac7f Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 28 May 2019 16:06:32 +0900 Subject: g10,agent: Support CONFIRM for --delete-key. * agent/call-pinentry.c (agent_get_confirmation): Add call of pinentry_loopback_confirm. (agent_popup_message_start): Likewise. (agent_popup_message_stop): Return if it's loopback mode. * agent/command.c (pinentry_loopback_confirm): New. * g10/call-agent.c (default_inq_cb): Support "CONFIRM" inquery when PINENTRY_MODE_LOOPBACK mode. (confirm_status_cb): New. (agent_delete_key): Supply confirm_status_cb to set the description string for confirmation. -- GnuPG-bug-id: 3465 Signed-off-by: NIIBE Yutaka --- agent/command.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'agent/command.c') diff --git a/agent/command.c b/agent/command.c index c056eb3f0..8f90948df 100644 --- a/agent/command.c +++ b/agent/command.c @@ -3655,3 +3655,26 @@ pinentry_loopback(ctrl_t ctrl, const char *keyword, assuan_end_confidential (ctx); return rc; } + +/* Helper for the pinentry loopback mode to ask confirmation + or just to show message. */ +gpg_error_t +pinentry_loopback_confirm (ctrl_t ctrl, const char *desc, + int ask_confirmation, + const char *ok, const char *notok) +{ + gpg_error_t err = 0; + assuan_context_t ctx = ctrl->server_local->assuan_ctx; + + if (desc) + err = print_assuan_status (ctx, "SETDESC", "%s", desc); + if (!err && ok) + err = print_assuan_status (ctx, "SETOK", "%s", ok); + if (!err && notok) + err = print_assuan_status (ctx, "SETNOTOK", "%s", notok); + + if (!err) + err = assuan_inquire (ctx, ask_confirmation ? "CONFIRM 1" : "CONFIRM 0", + NULL, NULL, 0); + return err; +} -- cgit v1.2.3