diff --git a/agent/agent.h b/agent/agent.h index dfef54c62..e72fa0fa0 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -535,7 +535,7 @@ int agent_get_passphrase (ctrl_t ctrl, char **retpass, const char *keyinfo, cache_mode_t cache_mode, struct pin_entry_info_s *pininfo); int agent_get_confirmation (ctrl_t ctrl, const char *desc, const char *ok, - const char *notokay, int with_cancel); + const char *notokay, unsigned int flags); int agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn); int agent_popup_message_start (ctrl_t ctrl, const char *desc, const char *ok_btn); @@ -543,6 +543,9 @@ void agent_popup_message_stop (ctrl_t ctrl); int agent_clear_passphrase (ctrl_t ctrl, const char *keyinfo, cache_mode_t cache_mode); +#define CONFIRM_FLAG_WITHCANCEL (1 << 0) +#define CONFIRM_FLAG_FOCUSOK (1 << 1) + /*-- cache.c --*/ void initialize_module_cache (void); void deinitialize_module_cache (void); diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index ba37a775e..b951306ab 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -1923,14 +1923,16 @@ agent_get_passphrase (ctrl_t ctrl, /* Pop up the PIN-entry, display the text and the prompt and ask the user to confirm this. We return 0 for success, ie. the user confirmed it, GPG_ERR_NOT_CONFIRMED for what the text says or an - other error. If WITH_CANCEL it true an extra cancel button is - displayed to allow the user to easily return a GPG_ERR_CANCELED. - if the Pinentry does not support this, the user can still cancel by - closing the Pinentry window. */ + other error. If FLAGS has FOCUSOK, confirmation is done with + --focus=ok to ask pinentry put the focus on OK button. If FLAGS + has WITHCANCEL, an extra cancel button is displayed to allow the + user to easily return a GPG_ERR_CANCELED. if the Pinentry does not + support this, the user can still cancel by closing the Pinentry + window. */ int agent_get_confirmation (ctrl_t ctrl, const char *desc, const char *ok, - const char *notok, int with_cancel) + const char *notok, unsigned int flags) { int rc; char line[ASSUAN_LINELENGTH]; @@ -1977,7 +1979,7 @@ agent_get_confirmation (ctrl_t ctrl, /* Try to use the newer NOTOK feature if a cancel button is requested. If no cancel button is requested we keep on using the standard cancel. */ - if (with_cancel) + if ((flags & CONFIRM_FLAG_WITHCANCEL)) { snprintf (line, DIM(line), "SETNOTOK %s", notok); rc = assuan_transact (entry_ctx, @@ -2003,7 +2005,10 @@ agent_get_confirmation (ctrl_t ctrl, rc = watch_sock_start (&sock_watched, &thread); if (!rc) { - rc = assuan_transact (entry_ctx, "CONFIRM", + const char *cmd = "CONFIRM"; + if ((flags & CONFIRM_FLAG_FOCUSOK)) + cmd = "CONFIRM --focus=ok"; + rc = assuan_transact (entry_ctx, cmd, NULL, NULL, NULL, NULL, NULL, NULL); if (rc && gpg_err_source (rc) && gpg_err_code (rc) == GPG_ERR_ASS_CANCELED) diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 2809916e2..a0ce9d5f6 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -2944,7 +2944,8 @@ data_sign (ctrl_t ctrl, ssh_key_type_spec_t *spec, fpr, comment? comment:""); xfree (fpr); gcry_free (comment); - err = agent_get_confirmation (ctrl, prompt, L_("Allow"), L_("Deny"), 0); + err = agent_get_confirmation (ctrl, prompt, L_("Allow"), L_("Deny"), + CONFIRM_FLAG_FOCUSOK); xfree (prompt); if (err) goto out; diff --git a/agent/findkey.c b/agent/findkey.c index 954199fcd..9fac81509 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -1338,7 +1338,8 @@ prompt_for_card (ctrl_t ctrl, const unsigned char *grip, err = out_of_core (); else { - err = agent_get_confirmation (ctrl, desc, NULL, NULL, 0); + err = agent_get_confirmation (ctrl, desc, NULL, NULL, + CONFIRM_FLAG_FOCUSOK); if (ctrl->pinentry_mode == PINENTRY_MODE_LOOPBACK && gpg_err_code (err) == GPG_ERR_NO_PIN_ENTRY) err = gpg_error (GPG_ERR_CARD_NOT_PRESENT); @@ -1471,7 +1472,8 @@ agent_key_from_file (ctrl_t ctrl, const char *cache_nonce, gcry_free (comment_buffer); err = agent_get_confirmation (ctrl, prompt, - L_("Allow"), L_("Deny"), 0); + L_("Allow"), L_("Deny"), + CONFIRM_FLAG_FOCUSOK); xfree (prompt); if (err) diff --git a/agent/trustlist.c b/agent/trustlist.c index 57a9c777f..e552c362a 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -788,7 +788,8 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) xfree (nameformatted); return out_of_core (); } - err = agent_get_confirmation (ctrl, desc, L_("Yes"), L_("No"), 1); + err = agent_get_confirmation (ctrl, desc, L_("Yes"), L_("No"), + CONFIRM_FLAG_WITHCANCEL); xfree (desc); if (!err) yes_i_trust = 1; @@ -844,7 +845,8 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) wrong = L_("Wrong"); if (!strcmp (wrong, "Wrong")) wrong = "_Wrong"; - err = agent_get_confirmation (ctrl, desc, correct, wrong, 1); + err = agent_get_confirmation (ctrl, desc, correct, wrong, + CONFIRM_FLAG_WITHCANCEL); xfree (desc); if (gpg_err_code (err) == GPG_ERR_NOT_CONFIRMED) yes_i_trust = 0;