Changeset View
Changeset View
Standalone View
Standalone View
g10/delkey.c
Context not available. | |||||
} | } | ||||
static gpg_error_t | static gpg_error_t | ||||
gpg_agent_delete_secret_key (ctrl_t ctrl, PKT_public_key *public_key) | gpg_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; | ||||
char *hexgrip; | char *hexgrip; | ||||
if (agent_probe_secret_key (NULL, public_key)) | if (agent_probe_secret_key (NULL, pk)) | ||||
return gpg_error (GPG_ERR_NO_SECKEY); | return gpg_error (GPG_ERR_NO_SECKEY); | ||||
prompt = gpg_format_keydesc (ctrl, public_key, FORMAT_KEYDESC_DELKEY, 1); | prompt = gpg_format_keydesc (ctrl, pk, FORMAT_KEYDESC_DELKEY, 1); | ||||
err = hexkeygrip_from_pk (public_key, &hexgrip); | err = hexkeygrip_from_pk (pk, &hexgrip); | ||||
/* NB: We require --yes to advise the agent not to request a confirmation. | /* 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 | * 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 | * 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 (confirm_deletion (ctrl, node->pkt, secret, exactmatch)) | if (confirm_deletion (ctrl, node->pkt, secret, exactmatch)) | ||||
{ | { | ||||
err = gpg_agent_delete_secret_key (ctrl, node->pkt->pkt.public_key); | err = gpg_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. |