diff --git a/doc/gpg.texi b/doc/gpg.texi --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -421,7 +421,6 @@ deleted; if the exclamation mark is used with the fingerprint of the primary key only the secret part of the primary key is deleted. - @item --delete-secret-and-public-key @var{name} @opindex delete-secret-and-public-key Same as @option{--delete-key}, but if a secret key exists, it will be @@ -429,6 +428,18 @@ The option @option{--yes} can be used to advice gpg-agent not to request a confirmation. +@item --delete-secret-subkeys @var{name} +@opindex delete-secret-subkeys +Remove subkeys from the secret keyring. In batch mode the subkey must be +specified by fingerprint. The option @option{--yes} can be used to +advice gpg-agent not to request a confirmation. This extra +pre-caution is done because @command{@gpgname} can't be sure that the +secret subkey (as controlled by gpg-agent) is only used for the given +OpenPGP public key. If the exclamation mark syntax is used with the +fingerprint of a subkey only the secret part of that subkey is +deleted; if the exclamation mark is used with the fingerprint of the +primary key nothing will be done. + @item --export @opindex export Either export all keys from all keyrings (default keyrings and those diff --git a/g10/delkey.c b/g10/delkey.c --- a/g10/delkey.c +++ b/g10/delkey.c @@ -73,7 +73,8 @@ * key can't be deleted for that reason. */ static gpg_error_t -do_delete_key (ctrl_t ctrl, const char *username, int secret, int force, +do_delete_key (ctrl_t ctrl, const char *username, + int secret, int force, int subkeys_only, int *r_sec_avail) { gpg_error_t err; @@ -256,6 +257,9 @@ if (thiskeyonly && targetnode != node) continue; + if (subkeys_only && node->pkt->pkttype != PKT_PUBLIC_SUBKEY) + continue; + err = agent_delete_secret_key (ctrl, node->pkt->pkt.public_key); if (err == GPG_ERR_NO_SECKEY) @@ -348,7 +352,7 @@ * Delete a public or secret key from a keyring. */ gpg_error_t -delete_keys (ctrl_t ctrl, strlist_t names, int secret, int allow_both) +delete_keys (ctrl_t ctrl, strlist_t names, int secret, int allow_both, int subkeys_only) { gpg_error_t err; int avail; @@ -359,14 +363,14 @@ for ( ;names ; names=names->next ) { - err = do_delete_key (ctrl, names->d, secret, force, &avail); + err = do_delete_key (ctrl, names->d, secret, force, subkeys_only, &avail); if (err && avail) { if (allow_both) { - err = do_delete_key (ctrl, names->d, 1, 0, &avail); + err = do_delete_key (ctrl, names->d, 1, 0, subkeys_only, &avail); if (!err) - err = do_delete_key (ctrl, names->d, 0, 0, &avail); + err = do_delete_key (ctrl, names->d, 0, 0, subkeys_only, &avail); } else { diff --git a/g10/gpg.c b/g10/gpg.c --- a/g10/gpg.c +++ b/g10/gpg.c @@ -140,6 +140,7 @@ aEditKey, aDeleteKeys, aDeleteSecretKeys, + aDeleteSecretSubkeys, aDeleteSecretAndPublicKeys, aImport, aFastImport, @@ -482,6 +483,8 @@ N_("remove keys from the public keyring")), ARGPARSE_c (aDeleteSecretKeys, "delete-secret-keys", N_("remove keys from the secret keyring")), + ARGPARSE_c (aDeleteSecretSubkeys, "delete-secret-subkeys", + N_("remove subkeys from the secret keyring")), ARGPARSE_c (aQuickSignKey, "quick-sign-key" , N_("quickly sign a key")), ARGPARSE_c (aQuickLSignKey, "quick-lsign-key", @@ -2653,6 +2656,7 @@ case aFullKeygen: case aEditKey: case aDeleteSecretKeys: + case aDeleteSecretSubkeys: case aDeleteSecretAndPublicKeys: case aDeleteKeys: case aPasswd: @@ -4205,6 +4209,7 @@ case aEditKey: case aPasswd: case aDeleteSecretKeys: + case aDeleteSecretSubkeys: case aDeleteSecretAndPublicKeys: case aQuickKeygen: case aQuickAddUid: @@ -4492,6 +4497,7 @@ case aDeleteKeys: case aDeleteSecretKeys: + case aDeleteSecretSubkeys: case aDeleteSecretAndPublicKeys: sl = NULL; /* I'm adding these in reverse order as add_to_strlist2 @@ -4500,7 +4506,9 @@ for( ; argc; argc-- ) add_to_strlist2( &sl, argv[argc-1], utf8_strings ); delete_keys (ctrl, sl, - cmd==aDeleteSecretKeys, cmd==aDeleteSecretAndPublicKeys); + cmd == aDeleteSecretKeys || cmd == aDeleteSecretSubkeys, + cmd == aDeleteSecretAndPublicKeys, + cmd == aDeleteSecretSubkeys); free_strlist(sl); break; diff --git a/g10/main.h b/g10/main.h --- a/g10/main.h +++ b/g10/main.h @@ -304,7 +304,7 @@ /*-- delkey.c --*/ gpg_error_t delete_keys (ctrl_t ctrl, - strlist_t names, int secret, int allow_both); + strlist_t names, int secret, int allow_both, int subkeys_only); /*-- keygen.c --*/ const char *get_default_pubkey_algo (void); diff --git a/po/pt.po b/po/pt.po --- a/po/pt.po +++ b/po/pt.po @@ -1995,6 +1995,9 @@ msgid "remove keys from the secret keyring" msgstr "remover chaves do porta-chaves secreto" +msgid "remove subkeys from the secret keyring" +msgstr "remover subchaves do porta-chaves secreto" + #, fuzzy #| msgid "sign a key" msgid "quickly sign a key"