mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-12 18:23:04 +01:00
gpg: Simplify default key listing.
* g10/mainproc.c (list_node): Rework. -- The old code still merged the first user id into the key packet line which resulted in all kind of complexity. --fixed-list-mode is meanwhile the default and thus we also change this part of the code. GnuPG-bug-id: 1640
This commit is contained in:
parent
684b0bd4bf
commit
ce989354fb
103
g10/mainproc.c
103
g10/mainproc.c
@ -917,7 +917,6 @@ print_userid( PACKET *pkt )
|
|||||||
static void
|
static void
|
||||||
list_node( CTX c, KBNODE node )
|
list_node( CTX c, KBNODE node )
|
||||||
{
|
{
|
||||||
int any=0;
|
|
||||||
int mainkey;
|
int mainkey;
|
||||||
|
|
||||||
if( !node )
|
if( !node )
|
||||||
@ -945,47 +944,55 @@ list_node( CTX c, KBNODE node )
|
|||||||
if( mainkey && !opt.fast_list_mode )
|
if( mainkey && !opt.fast_list_mode )
|
||||||
putchar( get_ownertrust_info (pk) );
|
putchar( get_ownertrust_info (pk) );
|
||||||
putchar(':');
|
putchar(':');
|
||||||
if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) {
|
|
||||||
putchar('\n'); any=1;
|
|
||||||
if( opt.fingerprint )
|
|
||||||
print_fingerprint( pk, NULL, 0 );
|
|
||||||
printf("rtv:1:%u:\n",
|
|
||||||
node->next->pkt->pkt.ring_trust->trustval );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%s %4u%c/%s %s%s",
|
{
|
||||||
|
printf("%s %4u%c/%s %s",
|
||||||
mainkey? "pub":"sub", nbits_from_pk( pk ),
|
mainkey? "pub":"sub", nbits_from_pk( pk ),
|
||||||
pubkey_letter( pk->pubkey_algo ), keystr_from_pk( pk ),
|
pubkey_letter( pk->pubkey_algo ), keystr_from_pk( pk ),
|
||||||
datestr_from_pk( pk ), mainkey?" ":"");
|
datestr_from_pk (pk));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pk->is_revoked)
|
||||||
|
{
|
||||||
|
printf(" [");
|
||||||
|
printf(_("revoked: %s"),revokestr_from_pk(pk));
|
||||||
|
printf("]\n");
|
||||||
|
}
|
||||||
|
else if (pk->expiredate && !opt.with_colons)
|
||||||
|
{
|
||||||
|
printf(" [");
|
||||||
|
printf(_("expires: %s"),expirestr_from_pk(pk));
|
||||||
|
printf("]\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
putchar ('\n');
|
||||||
|
|
||||||
|
if ((mainkey && opt.fingerprint) || opt.fingerprint > 1)
|
||||||
|
print_fingerprint (pk, NULL, 0);
|
||||||
|
|
||||||
|
if (opt.with_colons)
|
||||||
|
{
|
||||||
|
if (node->next && node->next->pkt->pkttype == PKT_RING_TRUST)
|
||||||
|
printf("rtv:1:%u:\n", node->next->pkt->pkt.ring_trust->trustval);
|
||||||
|
}
|
||||||
|
|
||||||
if( mainkey ) {
|
if( mainkey ) {
|
||||||
/* and now list all userids with their signatures */
|
/* and now list all userids with their signatures */
|
||||||
for( node = node->next; node; node = node->next ) {
|
for( node = node->next; node; node = node->next ) {
|
||||||
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
if( !any ) {
|
|
||||||
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
|
||||||
puts("[revoked]");
|
|
||||||
else
|
|
||||||
putchar('\n');
|
|
||||||
any = 1;
|
|
||||||
}
|
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
||||||
if( any ) {
|
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
printf("%s:::::::::",
|
printf("%s:::::::::",
|
||||||
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
||||||
else
|
else
|
||||||
printf( "uid%*s", 28, "" );
|
printf( "uid%*s", 28, "" );
|
||||||
}
|
|
||||||
print_userid( node->pkt );
|
print_userid( node->pkt );
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
putchar(':');
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint && !any )
|
|
||||||
print_fingerprint( pk, NULL, 0 );
|
|
||||||
if( opt.with_colons
|
if( opt.with_colons
|
||||||
&& node->next
|
&& node->next
|
||||||
&& node->next->pkt->pkttype == PKT_RING_TRUST ) {
|
&& node->next->pkt->pkttype == PKT_RING_TRUST ) {
|
||||||
@ -993,38 +1000,12 @@ list_node( CTX c, KBNODE node )
|
|||||||
node->next->pkt->pkt.ring_trust?
|
node->next->pkt->pkt.ring_trust?
|
||||||
node->next->pkt->pkt.ring_trust->trustval : 0);
|
node->next->pkt->pkt.ring_trust->trustval : 0);
|
||||||
}
|
}
|
||||||
any=1;
|
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
||||||
if( !any ) {
|
|
||||||
putchar('\n');
|
|
||||||
any = 1;
|
|
||||||
}
|
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* of subkey */
|
|
||||||
if( pk->is_revoked )
|
|
||||||
{
|
|
||||||
printf(" [");
|
|
||||||
printf(_("revoked: %s"),revokestr_from_pk(pk));
|
|
||||||
printf("]");
|
|
||||||
}
|
|
||||||
else if( pk->expiredate )
|
|
||||||
{
|
|
||||||
printf(" [");
|
|
||||||
printf(_("expires: %s"),expirestr_from_pk(pk));
|
|
||||||
printf("]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !any )
|
|
||||||
putchar('\n');
|
|
||||||
if( !mainkey && opt.fingerprint > 1 )
|
|
||||||
print_fingerprint( pk, NULL, 0 );
|
|
||||||
}
|
}
|
||||||
else if( (mainkey = (node->pkt->pkttype == PKT_SECRET_KEY) )
|
else if( (mainkey = (node->pkt->pkttype == PKT_SECRET_KEY) )
|
||||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
@ -1040,55 +1021,39 @@ list_node( CTX c, KBNODE node )
|
|||||||
sk->pubkey_algo,
|
sk->pubkey_algo,
|
||||||
(ulong)keyid[0],(ulong)keyid[1],
|
(ulong)keyid[0],(ulong)keyid[1],
|
||||||
colon_datestr_from_sk( sk ),
|
colon_datestr_from_sk( sk ),
|
||||||
colon_strtime (sk->expiredate)
|
colon_strtime (sk->expiredate));
|
||||||
/* fixme: add LID */ );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%s %4u%c/%s %s ", mainkey? "sec":"ssb",
|
printf("%s %4u%c/%s %s ", mainkey? "sec":"ssb",
|
||||||
nbits_from_sk( sk ), pubkey_letter( sk->pubkey_algo ),
|
nbits_from_sk( sk ), pubkey_letter( sk->pubkey_algo ),
|
||||||
keystr_from_sk( sk ), datestr_from_sk( sk ));
|
keystr_from_sk( sk ), datestr_from_sk( sk ));
|
||||||
|
|
||||||
|
putchar ('\n');
|
||||||
|
if ((mainkey && opt.fingerprint) || opt.fingerprint > 1)
|
||||||
|
print_fingerprint (NULL, sk,0);
|
||||||
|
|
||||||
if( mainkey ) {
|
if( mainkey ) {
|
||||||
/* and now list all userids with their signatures */
|
/* and now list all userids with their signatures */
|
||||||
for( node = node->next; node; node = node->next ) {
|
for( node = node->next; node; node = node->next ) {
|
||||||
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
if( !any ) {
|
|
||||||
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
|
||||||
puts("[revoked]");
|
|
||||||
else
|
|
||||||
putchar('\n');
|
|
||||||
any = 1;
|
|
||||||
}
|
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
||||||
if( any ) {
|
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
printf("%s:::::::::",
|
printf("%s:::::::::",
|
||||||
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
||||||
else
|
else
|
||||||
printf( "uid%*s", 28, "" );
|
printf( "uid%*s", 28, "" );
|
||||||
}
|
|
||||||
print_userid( node->pkt );
|
print_userid( node->pkt );
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
putchar(':');
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint && !any )
|
|
||||||
print_fingerprint( NULL, sk, 0 );
|
|
||||||
any=1;
|
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
if( !any ) {
|
|
||||||
putchar('\n');
|
|
||||||
any = 1;
|
|
||||||
}
|
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !any )
|
|
||||||
putchar('\n');
|
|
||||||
if( !mainkey && opt.fingerprint > 1 )
|
|
||||||
print_fingerprint( NULL, sk, 0 );
|
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
PKT_signature *sig = node->pkt->pkt.signature;
|
PKT_signature *sig = node->pkt->pkt.signature;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user