mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-17 14:07:03 +01:00
Give sensible error messages when trying to delete secret key.
This commit is contained in:
parent
25f292ed89
commit
a286e95f3a
@ -1,3 +1,9 @@
|
|||||||
|
2011-04-29 Marcus Brinkmann <marcus@g10code.com>
|
||||||
|
|
||||||
|
* delkey.c (do_delete_key): Access public keyblock even for secret
|
||||||
|
key operations. But deleting secret key is not supported yet, so
|
||||||
|
give an error. Limit secret-key-exists error case to public keys.
|
||||||
|
|
||||||
2011-04-28 Werner Koch <wk@g10code.com>
|
2011-04-28 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* ecdh.c (pk_ecdh_encrypt_with_shared_point): Remove memory leak
|
* ecdh.c (pk_ecdh_encrypt_with_shared_point): Remove memory leak
|
||||||
|
31
g10/delkey.c
31
g10/delkey.c
@ -83,7 +83,7 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get the keyid from the keyblock */
|
/* get the keyid from the keyblock */
|
||||||
node = find_kbnode( keyblock, secret? PKT_SECRET_KEY:PKT_PUBLIC_KEY );
|
node = find_kbnode( keyblock, PKT_PUBLIC_KEY );
|
||||||
if( !node ) {
|
if( !node ) {
|
||||||
log_error("Oops; key not found anymore!\n");
|
log_error("Oops; key not found anymore!\n");
|
||||||
rc = G10ERR_GENERAL;
|
rc = G10ERR_GENERAL;
|
||||||
@ -93,7 +93,7 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
|
|||||||
pk = node->pkt->pkt.public_key;
|
pk = node->pkt->pkt.public_key;
|
||||||
keyid_from_pk( pk, keyid );
|
keyid_from_pk( pk, keyid );
|
||||||
|
|
||||||
if (!force)
|
if (!secret && !force)
|
||||||
{
|
{
|
||||||
if (have_secret_key_with_kid (keyid))
|
if (have_secret_key_with_kid (keyid))
|
||||||
{
|
{
|
||||||
@ -146,20 +146,29 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
|
|||||||
|
|
||||||
|
|
||||||
if( okay ) {
|
if( okay ) {
|
||||||
rc = keydb_delete_keyblock (hd);
|
if (secret)
|
||||||
if (rc) {
|
{
|
||||||
|
log_error (_("deleting secret key not implemented\n"));
|
||||||
|
rc = gpg_error (GPG_ERR_NOT_IMPLEMENTED); /* FIXME */
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = keydb_delete_keyblock (hd);
|
||||||
|
if (rc) {
|
||||||
log_error (_("deleting keyblock failed: %s\n"), g10_errstr(rc) );
|
log_error (_("deleting keyblock failed: %s\n"), g10_errstr(rc) );
|
||||||
goto leave;
|
goto leave;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that the ownertrust being cleared will trigger a
|
/* Note that the ownertrust being cleared will trigger a
|
||||||
revalidation_mark(). This makes sense - only deleting keys
|
revalidation_mark(). This makes sense - only deleting keys
|
||||||
that have ownertrust set should trigger this. */
|
that have ownertrust set should trigger this. */
|
||||||
|
|
||||||
if (!secret && pk && clear_ownertrusts (pk)) {
|
if (!secret && pk && clear_ownertrusts (pk)) {
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
log_info (_("ownertrust information cleared\n"));
|
log_info (_("ownertrust information cleared\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user