Changeset View
Changeset View
Standalone View
Standalone View
g10/delkey.c
| Context not available. | |||||
| #include "call-agent.h" | #include "call-agent.h" | ||||
| static gpg_error_t | static gpg_error_t | ||||
| agent_delete_secret_key (ctrl_t ctrl, PKT_public_key *pk) | agent_delete_secret_key (ctrl_t ctrl, PKT_public_key *pk, int stubs_only) | ||||
| { | { | ||||
| gpg_error_t err; | gpg_error_t err; | ||||
| char *prompt; | char *prompt; | ||||
| Context not available. | |||||
| * may also be used for other protocols and thus deleting it from the gpg | * may also be used for other protocols and thus deleting it from the gpg | ||||
| * would also delete the key for other tools. */ | * would also delete the key for other tools. */ | ||||
| if (!err && !opt.dry_run) | if (!err && !opt.dry_run) | ||||
| err = agent_delete_key (NULL, hexgrip, prompt, opt.answer_yes); | err = agent_delete_key (NULL, hexgrip, prompt, opt.answer_yes, stubs_only); | ||||
| xfree (prompt); | xfree (prompt); | ||||
| xfree (hexgrip); | xfree (hexgrip); | ||||
| Context not available. | |||||
| */ | */ | ||||
| static gpg_error_t | static gpg_error_t | ||||
| do_delete_key (ctrl_t ctrl, const char *username, | do_delete_key (ctrl_t ctrl, const char *username, | ||||
| int secret, int force, int subkeys_only, | int secret, int force, int subkeys_only, int stubs_only, | ||||
| int *r_sec_avail) | int *r_sec_avail) | ||||
| { | { | ||||
| gpg_error_t err; | gpg_error_t err; | ||||
| Context not available. | |||||
| if (subkeys_only && node->pkt->pkttype != PKT_PUBLIC_SUBKEY) | if (subkeys_only && node->pkt->pkttype != PKT_PUBLIC_SUBKEY) | ||||
| continue; | continue; | ||||
| err = agent_delete_secret_key (ctrl, node->pkt->pkt.public_key); | err = agent_delete_secret_key (ctrl, | ||||
| node->pkt->pkt.public_key, | |||||
| stubs_only); | |||||
| if (err == GPG_ERR_NO_SECKEY) | if (err == GPG_ERR_NO_SECKEY) | ||||
| continue; /* No secret key for that public (sub)key. */ | continue; /* No secret key for that public (sub)key. */ | ||||
| Context not available. | |||||
| * Delete a public or secret key from a keyring. | * Delete a public or secret key from a keyring. | ||||
| */ | */ | ||||
| gpg_error_t | gpg_error_t | ||||
| delete_keys (ctrl_t ctrl, strlist_t names, int secret, int allow_both, int subkeys_only) | delete_keys (ctrl_t ctrl, strlist_t names, | ||||
| int secret, int allow_both, int subkeys_only, int stubs_only) | |||||
| { | { | ||||
| gpg_error_t err; | gpg_error_t err; | ||||
| int avail; | int avail; | ||||
| Context not available. | |||||
| for ( ;names ; names=names->next ) | for ( ;names ; names=names->next ) | ||||
| { | { | ||||
| err = do_delete_key (ctrl, names->d, secret, force, subkeys_only, &avail); | err = do_delete_key (ctrl, names->d, | ||||
| secret, force, subkeys_only, stubs_only, | |||||
| &avail); | |||||
| if (err && avail) | if (err && avail) | ||||
| { | { | ||||
| if (allow_both) | if (allow_both) | ||||
| { | { | ||||
| err = do_delete_key (ctrl, names->d, 1, 0, subkeys_only, &avail); | err = do_delete_key (ctrl, names->d, | ||||
| 1, 0, subkeys_only, stubs_only, | |||||
| &avail); | |||||
| if (!err) | if (!err) | ||||
| err = do_delete_key (ctrl, names->d, 0, 0, subkeys_only, &avail); | err = do_delete_key (ctrl, names->d, | ||||
| 0, 0, subkeys_only, stubs_only, | |||||
| &avail); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| Context not available. | |||||