mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* parse-packet.c (parse_key): Clear disabled flag when parsing a new key.
Just in case someone forgets to clear the whole key. * getkey.c (merge_selfsigs_main): Add an "if all else fails" path for setting a single user ID primary when there are multiple set primaries all at the same second, or no primaries set and the most recent user IDs are at the same second, or no signed user IDs at all. This is arbitrary, but deterministic. * exec.h, photoid.h: Add copyright message.
This commit is contained in:
parent
c28abad3b6
commit
020ace9330
5 changed files with 118 additions and 19 deletions
80
g10/getkey.c
80
g10/getkey.c
|
@ -1,5 +1,6 @@
|
|||
/* getkey.c - Get a key from the database
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
|
||||
* 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
|
@ -1331,7 +1332,6 @@ fixup_uidnode ( KBNODE uidnode, KBNODE signode, u32 keycreated )
|
|||
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES, &n);
|
||||
if (p && n && (p[0] & 0x01))
|
||||
uid->mdc_feature = 1;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1694,14 +1694,38 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked )
|
|||
if ( k->pkt->pkttype == PKT_USER_ID &&
|
||||
!k->pkt->pkt.user_id->attrib_data) {
|
||||
PKT_user_id *uid = k->pkt->pkt.user_id;
|
||||
if ( uid->is_primary && uid->created > uiddate ) {
|
||||
uiddate = uid->created;
|
||||
uidnode = k;
|
||||
}
|
||||
if ( !uid->is_primary && uid->created > uiddate2 ) {
|
||||
uiddate2 = uid->created;
|
||||
uidnode2 = k;
|
||||
}
|
||||
if (uid->is_primary)
|
||||
{
|
||||
if(uid->created > uiddate)
|
||||
{
|
||||
uiddate = uid->created;
|
||||
uidnode = k;
|
||||
}
|
||||
else if(uid->created==uiddate && uidnode)
|
||||
{
|
||||
/* The dates are equal, so we need to do a
|
||||
different (and arbitrary) comparison. This
|
||||
should rarely, if ever, happen. It's good to
|
||||
try and guarantee that two different GnuPG
|
||||
users with two different keyrings at least pick
|
||||
the same primary. */
|
||||
if(cmp_user_ids(uid,uidnode->pkt->pkt.user_id)>0)
|
||||
uidnode=k;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(uid->created > uiddate2)
|
||||
{
|
||||
uiddate2 = uid->created;
|
||||
uidnode2 = k;
|
||||
}
|
||||
else if(uid->created==uiddate2 && uidnode2)
|
||||
{
|
||||
if(cmp_user_ids(uid,uidnode2->pkt->pkt.user_id)>0)
|
||||
uidnode2=k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( uidnode ) {
|
||||
|
@ -1716,23 +1740,43 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked )
|
|||
}
|
||||
}
|
||||
else if( uidnode2 ) {
|
||||
/* none is flagged primary - use the latest user ID we have */
|
||||
/* none is flagged primary - use the latest user ID we have,
|
||||
and disambiguate with the arbitrary packet comparison. */
|
||||
uidnode2->pkt->pkt.user_id->is_primary = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* None of our uids were self-signed, so pick the first one to
|
||||
be the primary. This is the best we can do here since
|
||||
there are no self sigs to date the uids. */
|
||||
/* None of our uids were self-signed, so pick the one that
|
||||
sorts first to be the primary. This is the best we can do
|
||||
here since there are no self sigs to date the uids. */
|
||||
|
||||
uidnode = NULL;
|
||||
|
||||
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
|
||||
k = k->next )
|
||||
{
|
||||
if(k->pkt->pkttype==PKT_USER_ID &&
|
||||
!k->pkt->pkt.user_id->attrib_data)
|
||||
if(k->pkt->pkttype==PKT_USER_ID
|
||||
&& !k->pkt->pkt.user_id->attrib_data)
|
||||
{
|
||||
k->pkt->pkt.user_id->is_primary=1;
|
||||
break;
|
||||
if(!uidnode)
|
||||
{
|
||||
uidnode=k;
|
||||
uidnode->pkt->pkt.user_id->is_primary=1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cmp_user_ids(k->pkt->pkt.user_id,
|
||||
uidnode->pkt->pkt.user_id)>0)
|
||||
{
|
||||
uidnode->pkt->pkt.user_id->is_primary=0;
|
||||
uidnode=k;
|
||||
uidnode->pkt->pkt.user_id->is_primary=1;
|
||||
}
|
||||
else
|
||||
k->pkt->pkt.user_id->is_primary=0; /* just to be
|
||||
safe */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue