1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-21 14:47:03 +01:00

* getkey.c (get_seckey_byname2): Significantly simplify this function by

using key_byname to do the heavy lifting.  Note that this also fixes an
old problem when the first key on the secret keyring has an unusable stub
primary, but is still chosen.
This commit is contained in:
David Shaw 2004-04-26 01:20:03 +00:00
parent 7d74743c0e
commit 0c67c75cbe
2 changed files with 18 additions and 32 deletions

View File

@ -1,5 +1,10 @@
2004-04-25 David Shaw <dshaw@jabberwocky.com>
* getkey.c (get_seckey_byname2): Significantly simplify this
function by using key_byname to do the heavy lifting. Note that
this also fixes an old problem when the first key on the secret
keyring has an unusable stub primary, but is still chosen.
* getkey.c (key_byname): If namelist is NULL, return the first key
in the keyring.

View File

@ -1061,31 +1061,12 @@ get_seckey_byname2( GETKEY_CTX *retctx,
STRLIST namelist = NULL;
int rc;
if( !name && opt.def_secret_key && *opt.def_secret_key ) {
if( !name && opt.def_secret_key && *opt.def_secret_key )
add_to_strlist( &namelist, opt.def_secret_key );
rc = key_byname( retctx, namelist, NULL, sk, 1, 1, retblock, NULL );
}
else if( !name ) { /* use the first one as default key */
struct getkey_ctx_s ctx;
KBNODE kb = NULL;
assert (!retctx ); /* do we need this at all */
assert (!retblock);
memset( &ctx, 0, sizeof ctx );
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (1);
ctx.nitems = 1;
ctx.items[0].mode = KEYDB_SEARCH_MODE_FIRST;
rc = lookup( &ctx, &kb, 1 );
if (!rc && sk )
sk_from_block ( &ctx, sk, kb );
release_kbnode ( kb );
get_seckey_end( &ctx );
}
else {
else if(name)
add_to_strlist( &namelist, name );
rc = key_byname( retctx, namelist, NULL, sk, 1, 1, retblock, NULL );
}
free_strlist( namelist );