Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F23020590
D480.id1394.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
2 KB
Subscribers
None
D480.id1394.diff
View Options
diff --git a/g10/delkey.c b/g10/delkey.c
--- a/g10/delkey.c
+++ b/g10/delkey.c
@@ -40,6 +40,32 @@
#include "../common/i18n.h"
#include "call-agent.h"
+static gpg_error_t
+agent_delete_secret_key (ctrl_t ctrl, PKT_public_key *pk)
+{
+ gpg_error_t err;
+ char *prompt;
+ char *hexgrip;
+
+ if (agent_probe_secret_key (NULL, pk))
+ return gpg_error (GPG_ERR_NO_SECKEY);
+
+ prompt = gpg_format_keydesc (ctrl, pk, FORMAT_KEYDESC_DELKEY, 1);
+
+ err = hexkeygrip_from_pk (pk, &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 && !opt.dry_run)
+ err = agent_delete_key (NULL, hexgrip, prompt, opt.answer_yes);
+
+ xfree (prompt);
+ xfree (hexgrip);
+
+ return err;
+}
/****************
* Delete a public or secret key from a keyring.
@@ -218,9 +244,7 @@
{
if (secret)
{
- char *prompt;
gpg_error_t firsterr = 0;
- char *hexgrip;
setup_main_keyids (keyblock);
for (kbctx=NULL; (node = walk_kbnode (keyblock, &kbctx, 0)); )
@@ -232,24 +256,12 @@
if (thiskeyonly && targetnode != node)
continue;
- if (agent_probe_secret_key (NULL, node->pkt->pkt.public_key))
- continue; /* No secret key for that public (sub)key. */
-
- prompt = gpg_format_keydesc (ctrl,
- 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 && !opt.dry_run)
- err = agent_delete_key (NULL, hexgrip, prompt,
- opt.answer_yes);
- xfree (prompt);
- xfree (hexgrip);
- if (err)
+ err = agent_delete_secret_key (ctrl, node->pkt->pkt.public_key);
+
+ if (err == GPG_ERR_NO_SECKEY)
+ continue; /* No secret key for that public (sub)key. */
+
+ else if (err)
{
if (gpg_err_code (err) == GPG_ERR_KEY_ON_CARD)
write_status_text (STATUS_DELETE_PROBLEM, "1");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 11, 6:26 PM (16 h, 27 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
02/1c/401a6117be2d6bfd236c89821536
Attached To
D480: gpg: factor out secret key deletion function
Event Timeline
Log In to Comment