mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
* delkey.c (do_delete_key, delete_keys): Fix problem with --expert
preventing --delete-secret-and-public-keys from deleting secret keys.
This commit is contained in:
parent
e27aa939bf
commit
04f02174e1
@ -1,3 +1,9 @@
|
|||||||
|
2005-03-10 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* delkey.c (do_delete_key, delete_keys): Fix problem with --expert
|
||||||
|
preventing --delete-secret-and-public-keys from deleting secret
|
||||||
|
keys.
|
||||||
|
|
||||||
2005-03-10 Werner Koch <wk@g10code.com>
|
2005-03-10 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* keyedit.c (keyedit_menu) [W32]: Run the trustdb stale check
|
* keyedit.c (keyedit_menu) [W32]: Run the trustdb stale check
|
||||||
|
34
g10/delkey.c
34
g10/delkey.c
@ -1,6 +1,6 @@
|
|||||||
/* delkey.c - delete keys
|
/* delkey.c - delete keys
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004,
|
||||||
* 2004 Free Software Foundation, Inc.
|
* 2005 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -48,7 +48,7 @@
|
|||||||
* key can't be deleted for that reason.
|
* key can't be deleted for that reason.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
do_delete_key( const char *username, int secret, int *r_sec_avail )
|
do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
KBNODE keyblock = NULL;
|
KBNODE keyblock = NULL;
|
||||||
@ -91,25 +91,32 @@ do_delete_key( const char *username, int secret, int *r_sec_avail )
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( secret ) {
|
if( secret )
|
||||||
|
{
|
||||||
sk = node->pkt->pkt.secret_key;
|
sk = node->pkt->pkt.secret_key;
|
||||||
keyid_from_sk( sk, keyid );
|
keyid_from_sk( sk, keyid );
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
/* public */
|
||||||
pk = node->pkt->pkt.public_key;
|
pk = node->pkt->pkt.public_key;
|
||||||
keyid_from_pk( pk, keyid );
|
keyid_from_pk( pk, keyid );
|
||||||
|
|
||||||
|
if(!force)
|
||||||
|
{
|
||||||
rc = seckey_available( keyid );
|
rc = seckey_available( keyid );
|
||||||
if( !rc && !opt.expert ) {
|
if( !rc )
|
||||||
|
{
|
||||||
*r_sec_avail = 1;
|
*r_sec_avail = 1;
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
else if( rc != G10ERR_NO_SECKEY ) {
|
else if( rc != G10ERR_NO_SECKEY )
|
||||||
log_error("%s: get secret key: %s\n", username, g10_errstr(rc) );
|
log_error("%s: get secret key: %s\n", username, g10_errstr(rc) );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( rc )
|
if( rc )
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@ -180,15 +187,18 @@ do_delete_key( const char *username, int secret, int *r_sec_avail )
|
|||||||
int
|
int
|
||||||
delete_keys( STRLIST names, int secret, int allow_both )
|
delete_keys( STRLIST names, int secret, int allow_both )
|
||||||
{
|
{
|
||||||
int rc, avail;
|
int rc, avail, force=(!allow_both && !secret && opt.expert);
|
||||||
|
|
||||||
|
/* Force allows us to delete a public key even if a secret key
|
||||||
|
exists. */
|
||||||
|
|
||||||
for(;names;names=names->next) {
|
for(;names;names=names->next) {
|
||||||
rc = do_delete_key (names->d, secret, &avail );
|
rc = do_delete_key (names->d, secret, force, &avail );
|
||||||
if ( rc && avail ) {
|
if ( rc && avail ) {
|
||||||
if ( allow_both ) {
|
if ( allow_both ) {
|
||||||
rc = do_delete_key (names->d, 1, &avail );
|
rc = do_delete_key (names->d, 1, 0, &avail );
|
||||||
if ( !rc )
|
if ( !rc )
|
||||||
rc = do_delete_key (names->d, 0, &avail );
|
rc = do_delete_key (names->d, 0, 0, &avail );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error(_(
|
log_error(_(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user