From 5ecf0cbd79f6175cf5429f6710cf8c15296ecd65 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Wed, 13 Nov 2002 13:14:40 +0000 Subject: [PATCH] * keyedit.c (show_key_with_all_names_colon): Make --with-colons --edit display match the validity and trust of --with-colons --list-keys. * passphrase.c (agent_send_all_options): Fix compile warning. * keylist.c (list_keyblock_colon): Validity for subkeys should match that of the primary key, and not that of the last user ID. --- g10/ChangeLog | 11 +++++++++ g10/keyedit.c | 60 +++++++++++++++++++++++++++++++++++++----------- g10/keylist.c | 12 ++++++---- g10/passphrase.c | 2 +- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index a79b1c97c..699cc8d08 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,14 @@ +2002-11-13 David Shaw + + * keyedit.c (show_key_with_all_names_colon): Make --with-colons + --edit display match the validity and trust of --with-colons + --list-keys. + + * passphrase.c (agent_send_all_options): Fix compile warning. + + * keylist.c (list_keyblock_colon): Validity for subkeys should + match that of the primary key, and not that of the last user ID. + 2002-11-12 David Shaw * getkey.c (merge_selfsigs): Revoked/expired/invalid primary keys diff --git a/g10/keyedit.c b/g10/keyedit.c index 7c5aec4b9..0ee74e0b0 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1563,8 +1563,9 @@ static void show_key_with_all_names_colon (KBNODE keyblock) { KBNODE node; - int i, j; + int i, j, ulti_hack=0; byte pk_version=0; + PKT_public_key *primary=NULL; /* the keys */ for ( node = keyblock; node; node = node->next ) @@ -1573,14 +1574,12 @@ show_key_with_all_names_colon (KBNODE keyblock) || (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) ) { PKT_public_key *pk = node->pkt->pkt.public_key; - int otrust='-', trust='-'; u32 keyid[2]; if (node->pkt->pkttype == PKT_PUBLIC_KEY) { - trust = get_validity_info (pk, NULL); - otrust = get_ownertrust_info (pk); pk_version = pk->version; + primary=pk; } keyid_from_pk (pk, keyid); @@ -1592,8 +1591,14 @@ show_key_with_all_names_colon (KBNODE keyblock) putchar ('r'); else if (pk->has_expired) putchar ('e'); - else - putchar (trust); + else if (!(opt.fast_list_mode || opt.no_expensive_trust_checks )) + { + int trust = get_validity_info (pk, NULL); + if(trust=='u') + ulti_hack=1; + putchar (trust); + } + printf (":%u:%d:%08lX%08lX:%lu:%lu:", nbits_from_pk (pk), pk->pubkey_algo, @@ -1603,7 +1608,9 @@ show_key_with_all_names_colon (KBNODE keyblock) if (pk->local_id) printf ("%lu", pk->local_id); putchar (':'); - putchar (otrust); + if (node->pkt->pkttype==PKT_PUBLIC_KEY + && !(opt.fast_list_mode || opt.no_expensive_trust_checks )) + putchar(get_ownertrust_info (pk)); putchar(':'); putchar('\n'); @@ -1636,19 +1643,44 @@ show_key_with_all_names_colon (KBNODE keyblock) if ( node->pkt->pkttype == PKT_USER_ID ) { PKT_user_id *uid = node->pkt->pkt.user_id; - int trustletter = '?'; ++i; + if(uid->attrib_data) - { - printf ("uat:%c::::::::%u %lu", trustletter, - uid->numattribs,uid->attrib_len); - } + printf("uat:"); + else + printf("uid:"); + + if ( uid->is_revoked ) + printf("r::::::::"); + else if ( uid->is_expired ) + printf("e::::::::"); + else if ( opt.fast_list_mode || opt.no_expensive_trust_checks ) + printf("::::::::"); else { - printf ("uid:%c::::::::", trustletter); - print_string (stdout, uid->name, uid->len, ':'); + byte namehash[20]; + int uid_validity; + + if( primary && !ulti_hack ) + { + if( uid->attrib_data ) + rmd160_hash_buffer(namehash, + uid->attrib_data, uid->attrib_len); + else + rmd160_hash_buffer( namehash, uid->name, uid->len ); + uid_validity = get_validity_info( primary, namehash ); + } + else + uid_validity = 'u'; + printf("%c::::::::",uid_validity); } + + if(uid->attrib_data) + printf ("%u %lu",uid->numattribs,uid->attrib_len); + else + print_string (stdout, uid->name, uid->len, ':'); + putchar (':'); /* signature class */ putchar (':'); diff --git a/g10/keylist.c b/g10/keylist.c index a1a0e4c13..d6569bed8 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -650,7 +650,6 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr ) sk = NULL; keyid_from_pk( pk, keyid ); fputs( "pub:", stdout ); - trustletter = 0; if ( !pk->is_valid ) putchar ('i'); else if ( pk->is_revoked ) @@ -711,6 +710,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr ) } else { byte namehash[20]; + int uid_validity; if( pk && !ulti_hack ) { if( node->pkt->pkt.user_id->attrib_data ) @@ -721,11 +721,11 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr ) rmd160_hash_buffer( namehash, node->pkt->pkt.user_id->name, node->pkt->pkt.user_id->len ); - trustletter = get_validity_info( pk, namehash ); + uid_validity = get_validity_info( pk, namehash ); } else - trustletter = 'u'; - printf("%s:%c::::::::",str,trustletter); + uid_validity = 'u'; + printf("%s:%c::::::::",str,uid_validity); } } if(node->pkt->pkt.user_id->attrib_data) @@ -774,7 +774,9 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr ) else if ( opt.fast_list_mode || opt.no_expensive_trust_checks ) ; else { - printf("%c", trustletter ); + /* trustletter should always be defined here */ + if(trustletter) + printf("%c", trustletter ); } printf(":%u:%d:%08lX%08lX:%s:%s:", nbits_from_pk( pk2 ), diff --git a/g10/passphrase.c b/g10/passphrase.c index e48c1c85a..fe7e9670a 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -346,7 +346,7 @@ static int agent_send_all_options (int fd) { char *dft_display = NULL; - char *dft_ttyname = NULL; + const char *dft_ttyname = NULL; char *dft_ttytype = NULL; char *old_lc = NULL; char *dft_lc = NULL;