diff options
Diffstat (limited to 'g10')
-rw-r--r-- | g10/call-agent.c | 9 | ||||
-rw-r--r-- | g10/call-agent.h | 2 | ||||
-rw-r--r-- | g10/delkey.c | 8 |
3 files changed, 14 insertions, 5 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c index c5bd694f0..d8c6dede3 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -2349,9 +2349,11 @@ agent_export_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc, /* Ask the agent to delete the key identified by HEXKEYGRIP. If DESC is not NULL, display DESC instead of the default description - message. */ + message. If FORCE is true the agent is advised not to ask for + confirmation. */ gpg_error_t -agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc) +agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc, + int force) { gpg_error_t err; char line[ASSUAN_LINELENGTH]; @@ -2376,7 +2378,8 @@ agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc) return err; } - snprintf (line, DIM(line)-1, "DELETE_KEY %s", hexkeygrip); + snprintf (line, DIM(line)-1, "DELETE_KEY%s %s", + force? " --force":"", hexkeygrip); err = assuan_transact (agent_ctx, line, NULL, NULL, default_inq_cb, &dfltparm, NULL, NULL); diff --git a/g10/call-agent.h b/g10/call-agent.h index 208b75b2d..06a19d47b 100644 --- a/g10/call-agent.h +++ b/g10/call-agent.h @@ -196,7 +196,7 @@ gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip, /* Delete a key from the agent. */ gpg_error_t agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, - const char *desc); + const char *desc, int force); /* Change the passphrase of a key. */ gpg_error_t agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc, diff --git a/g10/delkey.c b/g10/delkey.c index f76277c5a..966c5712f 100644 --- a/g10/delkey.c +++ b/g10/delkey.c @@ -184,8 +184,14 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail ) prompt = gpg_format_keydesc (node->pkt->pkt.public_key, FORMAT_KEYDESC_DELKEY, 1); err = hexkeygrip_from_pk (node->pkt->pkt.public_key, &hexgrip); + /* NB: We require --yes to advise the agent not to + * request a confirmation. The rationale for this extra + * pre-caution is that since 2.1 the secret key may also + * be used for other protocols and thus deleting it from + * the gpg would also delete the key for other tools. */ if (!err) - err = agent_delete_key (NULL, hexgrip, prompt); + err = agent_delete_key (NULL, hexgrip, prompt, + opt.answer_yes); xfree (prompt); xfree (hexgrip); if (err) |