diff options
author | Werner Koch <[email protected]> | 2008-05-07 15:40:36 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2008-05-07 15:40:36 +0000 |
commit | 69ae16636cb0800d37f5d9eee6bb3d4749e645f7 (patch) | |
tree | 7b7fccd66e971375d1d3e4506a08266281935233 /g10/keylist.c | |
parent | Fixed bug#907. (diff) | |
download | gnupg-69ae16636cb0800d37f5d9eee6bb3d4749e645f7.tar.gz gnupg-69ae16636cb0800d37f5d9eee6bb3d4749e645f7.zip |
Add command --locate-key.
Fix auto-key-locate processing of "nodefault".
Diffstat (limited to 'g10/keylist.c')
-rw-r--r-- | g10/keylist.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index db4ef50f3..a98a4f9f6 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -40,6 +40,7 @@ static void list_all(int); static void list_one( strlist_t names, int secret); +static void locate_one (strlist_t names); static void print_card_serialno (PKT_secret_key *sk); struct sig_stats @@ -56,9 +57,9 @@ static FILE *attrib_fp=NULL; * If list is NULL, all available keys are listed */ void -public_key_list( strlist_t list ) +public_key_list( strlist_t list, int locate_mode ) { - if(opt.with_colons) + if (opt.with_colons) { byte trust_model,marginals,completes,cert_depth; ulong created,nextcheck; @@ -101,12 +102,15 @@ public_key_list( strlist_t list ) which is associated with the inode of a deleted file. */ check_trustdb_stale (); - if( !list ) - list_all(0); + if (locate_mode) + locate_one (list); + else if (!list) + list_all (0); else - list_one( list, 0 ); + list_one (list, 0); } + void secret_key_list( strlist_t list ) { @@ -527,6 +531,38 @@ list_one( strlist_t names, int secret ) print_signature_stats(&stats); } + +static void +locate_one (strlist_t names) +{ + int rc = 0; + strlist_t sl; + KBNODE keyblock = NULL; + struct sig_stats stats; + + memset(&stats,0,sizeof(stats)); + + for (sl=names; sl; sl = sl->next) + { + rc = get_pubkey_byname (NULL, sl->d, &keyblock, NULL, 1, 0); + if (rc) + { + if (gpg_err_code (rc) != GPG_ERR_NO_PUBKEY) + log_error ("error reading key: %s\n", g10_errstr(rc) ); + } + else + { + list_keyblock (keyblock, 0, opt.fingerprint, + opt.check_sigs? &stats : NULL ); + release_kbnode (keyblock); + } + } + + if (opt.check_sigs && !opt.with_colons) + print_signature_stats (&stats); +} + + static void print_key_data( PKT_public_key *pk ) { |