mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-21 10:09:57 +01:00
gpg: Fix adding the list of ultimate trusted keys.
* g10/keygen.c (do_generate_keypair): Remove another call to update_ownertrust. * g10/trust.c (update_ownertrust): Add call to tdb_update_utk. * g10/trustdb.c (tdb_update_utk): New. * g10/trustdb.h (tdb_update_utk): New. -- GnuPG-bug-id: 5742 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
b66854ac93
commit
4aeeaa65ad
@ -5617,8 +5617,6 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
|
||||
|
||||
pk = find_kbnode (pub_root, PKT_PUBLIC_KEY)->pkt->pkt.public_key;
|
||||
|
||||
update_ownertrust (ctrl, pk, TRUST_ULTIMATE);
|
||||
|
||||
if (!opt.flags.no_auto_trust_new_key)
|
||||
update_ownertrust (ctrl, pk,
|
||||
((get_ownertrust (ctrl, pk) & ~TRUST_MASK)
|
||||
|
@ -267,7 +267,11 @@ update_ownertrust (ctrl_t ctrl, PKT_public_key *pk, unsigned int new_trust)
|
||||
(void)pk;
|
||||
(void)new_trust;
|
||||
#else
|
||||
u32 keyid[2];
|
||||
|
||||
tdb_update_ownertrust (ctrl, pk, new_trust, 0);
|
||||
keyid_from_pk (pk, keyid);
|
||||
tdb_update_utk (keyid, (new_trust & TRUST_ULTIMATE));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,49 @@ add_utk (u32 *kid)
|
||||
}
|
||||
|
||||
|
||||
/* Add/remove KID to/from the list of ultimately trusted keys. */
|
||||
void
|
||||
tdb_update_utk (u32 *kid, int add)
|
||||
{
|
||||
struct key_item *k, *k_prev;
|
||||
|
||||
k_prev = NULL;
|
||||
for (k = utk_list; k; k = k->next)
|
||||
if (k->kid[0] == kid[0] && k->kid[1] == kid[1])
|
||||
break;
|
||||
else
|
||||
k_prev = k;
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (!k)
|
||||
{
|
||||
k = new_key_item ();
|
||||
k->kid[0] = kid[0];
|
||||
k->kid[1] = kid[1];
|
||||
k->ownertrust = TRUST_ULTIMATE;
|
||||
k->next = utk_list;
|
||||
utk_list = k;
|
||||
if ( opt.verbose > 1 )
|
||||
log_info(_("key %s: accepted as trusted key\n"), keystr(kid));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k)
|
||||
{
|
||||
if (k_prev)
|
||||
k_prev->next = k->next;
|
||||
else
|
||||
utk_list = NULL;
|
||||
|
||||
xfree (k->trust_regexp);
|
||||
xfree (k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Verify that all our secret keys are usable and put them into the utk_list.
|
||||
*/
|
||||
|
@ -80,6 +80,7 @@ int tdb_keyid_is_utk (u32 *kid);
|
||||
/* Return the list of ultimately trusted keys. The caller must not
|
||||
* modify this list nor must it free the list. */
|
||||
struct key_item *tdb_utks (void);
|
||||
void tdb_update_utk (u32 *kid, int add);
|
||||
void check_trustdb (ctrl_t ctrl);
|
||||
void update_trustdb (ctrl_t ctrl);
|
||||
int setup_trustdb( int level, const char *dbname );
|
||||
|
Loading…
x
Reference in New Issue
Block a user