mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
g10: Use bitfield for flags of user ids.
* g10/packet.h (is_{primary,revoked,expired}): Move to the flags bitfield. * g10/call-dirmngr.c: Update all uses using the following semantic patch. * g10/export.c: Likewise. * g10/getkey.c: Likewise. * g10/import.c: Likewise. * g10/kbnode.c: Likewise. * g10/keyedit.c: Likewise. * g10/keylist.c: Likewise. * g10/keyserver.c: Likewise. * g10/mainproc.c: Likewise. * g10/pkclist.c: Likewise. * g10/pubkey-enc.c: Likewise. * g10/tofu.c: Likewise. * g10/trust.c: Likewise. * g10/trustdb.c: Likewise. -- I used Coccinelle and the following semantic patch to update the code: @@ expression E; @@ -E->is_expired +E->flags.expired @@ expression E; @@ -E->is_primary +E->flags.primary @@ expression E; @@ -E->is_revoked +E->flags.revoked Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
a1e0d4a1e7
commit
a1a64820c3
@ -963,9 +963,9 @@ ks_put_inq_cb (void *opaque, const char *line)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
validity[i ++] = 'r';
|
validity[i ++] = 'r';
|
||||||
if (uid->is_expired)
|
if (uid->flags.expired)
|
||||||
validity[i ++] = 'e';
|
validity[i ++] = 'e';
|
||||||
validity[i] = '\0';
|
validity[i] = '\0';
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ print_pka_or_dane_records (iobuf_t out, kbnode_t keyblock, PKT_public_key *pk,
|
|||||||
continue;
|
continue;
|
||||||
uid = node->pkt->pkt.user_id;
|
uid = node->pkt->pkt.user_id;
|
||||||
|
|
||||||
if (uid->is_expired || uid->is_revoked)
|
if (uid->flags.expired || uid->flags.revoked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xfree (mbox);
|
xfree (mbox);
|
||||||
|
36
g10/getkey.c
36
g10/getkey.c
@ -274,7 +274,7 @@ get_primary_uid (KBNODE keyblock, size_t * uidlen)
|
|||||||
{
|
{
|
||||||
if (k->pkt->pkttype == PKT_USER_ID
|
if (k->pkt->pkttype == PKT_USER_ID
|
||||||
&& !k->pkt->pkt.user_id->attrib_data
|
&& !k->pkt->pkt.user_id->attrib_data
|
||||||
&& k->pkt->pkt.user_id->is_primary)
|
&& k->pkt->pkt.user_id->flags.primary)
|
||||||
{
|
{
|
||||||
*uidlen = k->pkt->pkt.user_id->len;
|
*uidlen = k->pkt->pkt.user_id->len;
|
||||||
return k->pkt->pkt.user_id->name;
|
return k->pkt->pkt.user_id->name;
|
||||||
@ -970,7 +970,7 @@ skip_unusable (void *dummy, u32 * keyid, int uid_no)
|
|||||||
if (uids_seen != uid_no)
|
if (uids_seen != uid_no)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (user_id->is_revoked || user_id->is_expired)
|
if (user_id->flags.revoked || user_id->flags.expired)
|
||||||
unusable = 1;
|
unusable = 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1494,7 +1494,7 @@ key_is_ok (const PKT_public_key *key)
|
|||||||
static int
|
static int
|
||||||
uid_is_ok (const PKT_public_key *key, const PKT_user_id *uid)
|
uid_is_ok (const PKT_public_key *key, const PKT_user_id *uid)
|
||||||
{
|
{
|
||||||
return key_is_ok (key) && ! uid->is_revoked;
|
return key_is_ok (key) && ! uid->flags.revoked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2342,26 +2342,26 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
|
|||||||
uid->created = 0; /* Not created == invalid. */
|
uid->created = 0; /* Not created == invalid. */
|
||||||
if (IS_UID_REV (sig))
|
if (IS_UID_REV (sig))
|
||||||
{
|
{
|
||||||
uid->is_revoked = 1;
|
uid->flags.revoked = 1;
|
||||||
return; /* Has been revoked. */
|
return; /* Has been revoked. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
uid->is_revoked = 0;
|
uid->flags.revoked = 0;
|
||||||
|
|
||||||
uid->expiredate = sig->expiredate;
|
uid->expiredate = sig->expiredate;
|
||||||
|
|
||||||
if (sig->flags.expired)
|
if (sig->flags.expired)
|
||||||
{
|
{
|
||||||
uid->is_expired = 1;
|
uid->flags.expired = 1;
|
||||||
return; /* Has expired. */
|
return; /* Has expired. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
uid->is_expired = 0;
|
uid->flags.expired = 0;
|
||||||
|
|
||||||
uid->created = sig->timestamp; /* This one is okay. */
|
uid->created = sig->timestamp; /* This one is okay. */
|
||||||
uid->selfsigversion = sig->version;
|
uid->selfsigversion = sig->version;
|
||||||
/* If we got this far, it's not expired :) */
|
/* If we got this far, it's not expired :) */
|
||||||
uid->is_expired = 0;
|
uid->flags.expired = 0;
|
||||||
|
|
||||||
/* Store the key flags in the helper variable for later processing. */
|
/* Store the key flags in the helper variable for later processing. */
|
||||||
uid->help_key_usage = parse_key_usage (sig);
|
uid->help_key_usage = parse_key_usage (sig);
|
||||||
@ -2375,10 +2375,10 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
|
|||||||
|
|
||||||
/* Set the primary user ID flag - we will later wipe out some
|
/* Set the primary user ID flag - we will later wipe out some
|
||||||
* of them to only have one in our keyblock. */
|
* of them to only have one in our keyblock. */
|
||||||
uid->is_primary = 0;
|
uid->flags.primary = 0;
|
||||||
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PRIMARY_UID, NULL);
|
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PRIMARY_UID, NULL);
|
||||||
if (p && *p)
|
if (p && *p)
|
||||||
uid->is_primary = 2;
|
uid->flags.primary = 2;
|
||||||
|
|
||||||
/* We could also query this from the unhashed area if it is not in
|
/* We could also query this from the unhashed area if it is not in
|
||||||
* the hased area and then later try to decide which is the better
|
* the hased area and then later try to decide which is the better
|
||||||
@ -2912,7 +2912,7 @@ merge_selfsigs_main (KBNODE keyblock, int *r_revoked,
|
|||||||
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)
|
||||||
{
|
{
|
||||||
PKT_user_id *uid = k->pkt->pkt.user_id;
|
PKT_user_id *uid = k->pkt->pkt.user_id;
|
||||||
if (uid->is_primary)
|
if (uid->flags.primary)
|
||||||
{
|
{
|
||||||
if (uid->created > uiddate)
|
if (uid->created > uiddate)
|
||||||
{
|
{
|
||||||
@ -2956,7 +2956,7 @@ merge_selfsigs_main (KBNODE keyblock, int *r_revoked,
|
|||||||
{
|
{
|
||||||
PKT_user_id *uid = k->pkt->pkt.user_id;
|
PKT_user_id *uid = k->pkt->pkt.user_id;
|
||||||
if (k != uidnode)
|
if (k != uidnode)
|
||||||
uid->is_primary = 0;
|
uid->flags.primary = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2964,7 +2964,7 @@ merge_selfsigs_main (KBNODE keyblock, int *r_revoked,
|
|||||||
{
|
{
|
||||||
/* 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. */
|
and disambiguate with the arbitrary packet comparison. */
|
||||||
uidnode2->pkt->pkt.user_id->is_primary = 1;
|
uidnode2->pkt->pkt.user_id->flags.primary = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2983,7 +2983,7 @@ merge_selfsigs_main (KBNODE keyblock, int *r_revoked,
|
|||||||
if (!uidnode)
|
if (!uidnode)
|
||||||
{
|
{
|
||||||
uidnode = k;
|
uidnode = k;
|
||||||
uidnode->pkt->pkt.user_id->is_primary = 1;
|
uidnode->pkt->pkt.user_id->flags.primary = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2991,12 +2991,12 @@ merge_selfsigs_main (KBNODE keyblock, int *r_revoked,
|
|||||||
if (cmp_user_ids (k->pkt->pkt.user_id,
|
if (cmp_user_ids (k->pkt->pkt.user_id,
|
||||||
uidnode->pkt->pkt.user_id) > 0)
|
uidnode->pkt->pkt.user_id) > 0)
|
||||||
{
|
{
|
||||||
uidnode->pkt->pkt.user_id->is_primary = 0;
|
uidnode->pkt->pkt.user_id->flags.primary = 0;
|
||||||
uidnode = k;
|
uidnode = k;
|
||||||
uidnode->pkt->pkt.user_id->is_primary = 1;
|
uidnode->pkt->pkt.user_id->flags.primary = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
k->pkt->pkt.user_id->is_primary = 0; /* just to be
|
k->pkt->pkt.user_id->flags.primary = 0; /* just to be
|
||||||
safe */
|
safe */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3310,7 +3310,7 @@ merge_selfsigs (KBNODE keyblock)
|
|||||||
{
|
{
|
||||||
if (k->pkt->pkttype == PKT_USER_ID
|
if (k->pkt->pkttype == PKT_USER_ID
|
||||||
&& !k->pkt->pkt.user_id->attrib_data
|
&& !k->pkt->pkt.user_id->attrib_data
|
||||||
&& k->pkt->pkt.user_id->is_primary)
|
&& k->pkt->pkt.user_id->flags.primary)
|
||||||
{
|
{
|
||||||
prefs = k->pkt->pkt.user_id->prefs;
|
prefs = k->pkt->pkt.user_id->prefs;
|
||||||
mdc_feature = k->pkt->pkt.user_id->flags.mdc;
|
mdc_feature = k->pkt->pkt.user_id->flags.mdc;
|
||||||
|
@ -1170,7 +1170,7 @@ impex_filter_getval (void *cookie, const char *propname)
|
|||||||
result = node->pkt->pkt.user_id->mbox;
|
result = node->pkt->pkt.user_id->mbox;
|
||||||
}
|
}
|
||||||
else if (!strcmp (propname, "primary"))
|
else if (!strcmp (propname, "primary"))
|
||||||
result = node->pkt->pkt.user_id->is_primary? "1":"0";
|
result = node->pkt->pkt.user_id->flags.primary? "1":"0";
|
||||||
else
|
else
|
||||||
result = NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
|
@ -392,10 +392,10 @@ dump_kbnode (KBNODE node)
|
|||||||
es_write_sanitized (log_get_stream (), uid->name, uid->len,
|
es_write_sanitized (log_get_stream (), uid->name, uid->len,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
log_printf ("\" %c%c%c%c\n",
|
log_printf ("\" %c%c%c%c\n",
|
||||||
uid->is_expired? 'e':'.',
|
uid->flags.expired? 'e':'.',
|
||||||
uid->is_revoked? 'r':'.',
|
uid->flags.revoked? 'r':'.',
|
||||||
uid->created? 'v':'.',
|
uid->created? 'v':'.',
|
||||||
uid->is_primary? 'p':'.' );
|
uid->flags.primary? 'p':'.' );
|
||||||
}
|
}
|
||||||
else if (node->pkt->pkttype == PKT_SIGNATURE)
|
else if (node->pkt->pkttype == PKT_SIGNATURE)
|
||||||
{
|
{
|
||||||
|
@ -1164,7 +1164,7 @@ sign_uids (ctrl_t ctrl, estream_t fp,
|
|||||||
uidnode->flag &= ~NODFLG_MARK_A;
|
uidnode->flag &= ~NODFLG_MARK_A;
|
||||||
uidnode = NULL;
|
uidnode = NULL;
|
||||||
}
|
}
|
||||||
else if (uidnode->pkt->pkt.user_id->is_revoked)
|
else if (uidnode->pkt->pkt.user_id->flags.revoked)
|
||||||
{
|
{
|
||||||
tty_fprintf (fp, _("User ID \"%s\" is revoked."), user);
|
tty_fprintf (fp, _("User ID \"%s\" is revoked."), user);
|
||||||
|
|
||||||
@ -1192,7 +1192,7 @@ sign_uids (ctrl_t ctrl, estream_t fp,
|
|||||||
tty_fprintf (fp, _(" Unable to sign.\n"));
|
tty_fprintf (fp, _(" Unable to sign.\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (uidnode->pkt->pkt.user_id->is_expired)
|
else if (uidnode->pkt->pkt.user_id->flags.expired)
|
||||||
{
|
{
|
||||||
tty_fprintf (fp, _("User ID \"%s\" is expired."), user);
|
tty_fprintf (fp, _("User ID \"%s\" is expired."), user);
|
||||||
|
|
||||||
@ -3714,9 +3714,9 @@ show_key_with_all_names_colon (ctrl_t ctrl, estream_t fp, kbnode_t keyblock)
|
|||||||
else
|
else
|
||||||
es_fputs ("uid:", fp);
|
es_fputs ("uid:", fp);
|
||||||
|
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
es_fputs ("r::::::::", fp);
|
es_fputs ("r::::::::", fp);
|
||||||
else if (uid->is_expired)
|
else if (uid->flags.expired)
|
||||||
es_fputs ("e::::::::", fp);
|
es_fputs ("e::::::::", fp);
|
||||||
else if (opt.fast_list_mode || opt.no_expensive_trust_checks)
|
else if (opt.fast_list_mode || opt.no_expensive_trust_checks)
|
||||||
es_fputs ("::::::::", fp);
|
es_fputs ("::::::::", fp);
|
||||||
@ -3764,11 +3764,11 @@ show_key_with_all_names_colon (ctrl_t ctrl, estream_t fp, kbnode_t keyblock)
|
|||||||
es_putc (':', fp);
|
es_putc (':', fp);
|
||||||
/* flags */
|
/* flags */
|
||||||
es_fprintf (fp, "%d,", i);
|
es_fprintf (fp, "%d,", i);
|
||||||
if (uid->is_primary)
|
if (uid->flags.primary)
|
||||||
es_putc ('p', fp);
|
es_putc ('p', fp);
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
es_putc ('r', fp);
|
es_putc ('r', fp);
|
||||||
if (uid->is_expired)
|
if (uid->flags.expired)
|
||||||
es_putc ('e', fp);
|
es_putc ('e', fp);
|
||||||
if ((node->flag & NODFLG_SELUID))
|
if ((node->flag & NODFLG_SELUID))
|
||||||
es_putc ('s', fp);
|
es_putc ('s', fp);
|
||||||
@ -3814,7 +3814,7 @@ show_names (ctrl_t ctrl, estream_t fp,
|
|||||||
tty_fprintf (fp, " ");
|
tty_fprintf (fp, " ");
|
||||||
else if (node->flag & NODFLG_SELUID)
|
else if (node->flag & NODFLG_SELUID)
|
||||||
tty_fprintf (fp, "(%d)* ", i);
|
tty_fprintf (fp, "(%d)* ", i);
|
||||||
else if (uid->is_primary)
|
else if (uid->flags.primary)
|
||||||
tty_fprintf (fp, "(%d). ", i);
|
tty_fprintf (fp, "(%d). ", i);
|
||||||
else
|
else
|
||||||
tty_fprintf (fp, "(%d) ", i);
|
tty_fprintf (fp, "(%d) ", i);
|
||||||
@ -4146,9 +4146,9 @@ show_basic_key_info (KBNODE keyblock)
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
tty_printf (" ");
|
tty_printf (" ");
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
tty_printf ("[%s] ", _("revoked"));
|
tty_printf ("[%s] ", _("revoked"));
|
||||||
else if (uid->is_expired)
|
else if (uid->flags.expired)
|
||||||
tty_printf ("[%s] ", _("expired"));
|
tty_printf ("[%s] ", _("expired"));
|
||||||
tty_print_utf8_string (uid->name, uid->len);
|
tty_print_utf8_string (uid->name, uid->len);
|
||||||
tty_printf ("\n");
|
tty_printf ("\n");
|
||||||
@ -4256,7 +4256,7 @@ no_primary_warning (KBNODE keyblock)
|
|||||||
{
|
{
|
||||||
uid_count++;
|
uid_count++;
|
||||||
|
|
||||||
if (node->pkt->pkt.user_id->is_primary == 2)
|
if (node->pkt->pkt.user_id->flags.primary == 2)
|
||||||
{
|
{
|
||||||
have_primary = 1;
|
have_primary = 1;
|
||||||
break;
|
break;
|
||||||
@ -4457,7 +4457,7 @@ menu_deluid (KBNODE pub_keyblock)
|
|||||||
{
|
{
|
||||||
/* Only cause a trust update if we delete a
|
/* Only cause a trust update if we delete a
|
||||||
non-revoked user id */
|
non-revoked user id */
|
||||||
if (!node->pkt->pkt.user_id->is_revoked)
|
if (!node->pkt->pkt.user_id->flags.revoked)
|
||||||
update_trust = 1;
|
update_trust = 1;
|
||||||
delete_kbnode (node);
|
delete_kbnode (node);
|
||||||
}
|
}
|
||||||
@ -4577,9 +4577,9 @@ menu_clean (KBNODE keyblock, int self_only)
|
|||||||
{
|
{
|
||||||
const char *reason;
|
const char *reason;
|
||||||
|
|
||||||
if (uidnode->pkt->pkt.user_id->is_revoked)
|
if (uidnode->pkt->pkt.user_id->flags.revoked)
|
||||||
reason = _("revoked");
|
reason = _("revoked");
|
||||||
else if (uidnode->pkt->pkt.user_id->is_expired)
|
else if (uidnode->pkt->pkt.user_id->flags.expired)
|
||||||
reason = _("expired");
|
reason = _("expired");
|
||||||
else
|
else
|
||||||
reason = _("invalid");
|
reason = _("invalid");
|
||||||
@ -6314,7 +6314,7 @@ reloop: /* (must use this, because we are modifing the list) */
|
|||||||
/* Are we revoking our own uid? */
|
/* Are we revoking our own uid? */
|
||||||
if (primary_pk->keyid[0] == sig->keyid[0] &&
|
if (primary_pk->keyid[0] == sig->keyid[0] &&
|
||||||
primary_pk->keyid[1] == sig->keyid[1])
|
primary_pk->keyid[1] == sig->keyid[1])
|
||||||
unode->pkt->pkt.user_id->is_revoked = 1;
|
unode->pkt->pkt.user_id->flags.revoked = 1;
|
||||||
pkt = xmalloc_clear (sizeof *pkt);
|
pkt = xmalloc_clear (sizeof *pkt);
|
||||||
pkt->pkttype = PKT_SIGNATURE;
|
pkt->pkttype = PKT_SIGNATURE;
|
||||||
pkt->pkt.signature = sig;
|
pkt->pkt.signature = sig;
|
||||||
@ -6348,7 +6348,7 @@ core_revuid (ctrl_t ctrl, kbnode_t keyblock, KBNODE node,
|
|||||||
{
|
{
|
||||||
PKT_user_id *uid = node->pkt->pkt.user_id;
|
PKT_user_id *uid = node->pkt->pkt.user_id;
|
||||||
|
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
{
|
{
|
||||||
char *user = utf8_to_native (uid->name, uid->len, 0);
|
char *user = utf8_to_native (uid->name, uid->len, 0);
|
||||||
log_info (_("user ID \"%s\" is already revoked\n"), user);
|
log_info (_("user ID \"%s\" is already revoked\n"), user);
|
||||||
@ -6408,7 +6408,7 @@ core_revuid (ctrl_t ctrl, kbnode_t keyblock, KBNODE node,
|
|||||||
update_trust = 1;
|
update_trust = 1;
|
||||||
#endif /*!NO_TRUST_MODELS*/
|
#endif /*!NO_TRUST_MODELS*/
|
||||||
|
|
||||||
node->pkt->pkt.user_id->is_revoked = 1;
|
node->pkt->pkt.user_id->flags.revoked = 1;
|
||||||
if (modified)
|
if (modified)
|
||||||
*modified = 1;
|
*modified = 1;
|
||||||
}
|
}
|
||||||
|
@ -852,9 +852,8 @@ dump_attribs (const PKT_user_id *uid, PKT_public_key *pk)
|
|||||||
(ulong) uid->attribs[i].len, uid->attribs[i].type, i + 1,
|
(ulong) uid->attribs[i].len, uid->attribs[i].type, i + 1,
|
||||||
uid->numattribs, (ulong) uid->created,
|
uid->numattribs, (ulong) uid->created,
|
||||||
(ulong) uid->expiredate,
|
(ulong) uid->expiredate,
|
||||||
((uid->is_primary ? 0x01 : 0) | (uid->
|
((uid->flags.primary ? 0x01 : 0) | (uid->flags.revoked ? 0x02 : 0) |
|
||||||
is_revoked ? 0x02 : 0) |
|
(uid->flags.expired ? 0x04 : 0)));
|
||||||
(uid->is_expired ? 0x04 : 0)));
|
|
||||||
write_status_text (STATUS_ATTRIBUTE, buf);
|
write_status_text (STATUS_ATTRIBUTE, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +928,7 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
|
|||||||
int indent;
|
int indent;
|
||||||
int kl = opt.keyid_format == KF_NONE? 10 : keystrlen ();
|
int kl = opt.keyid_format == KF_NONE? 10 : keystrlen ();
|
||||||
|
|
||||||
if ((uid->is_expired || uid->is_revoked)
|
if ((uid->flags.expired || uid->flags.revoked)
|
||||||
&& !(opt.list_options & LIST_SHOW_UNUSABLE_UIDS))
|
&& !(opt.list_options & LIST_SHOW_UNUSABLE_UIDS))
|
||||||
{
|
{
|
||||||
skip_sigs = 1;
|
skip_sigs = 1;
|
||||||
@ -941,7 +940,7 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
|
|||||||
if (attrib_fp && uid->attrib_data != NULL)
|
if (attrib_fp && uid->attrib_data != NULL)
|
||||||
dump_attribs (uid, pk);
|
dump_attribs (uid, pk);
|
||||||
|
|
||||||
if ((uid->is_revoked || uid->is_expired)
|
if ((uid->flags.revoked || uid->flags.expired)
|
||||||
|| ((opt.list_options & LIST_SHOW_UID_VALIDITY)
|
|| ((opt.list_options & LIST_SHOW_UID_VALIDITY)
|
||||||
&& !listctx->no_validity))
|
&& !listctx->no_validity))
|
||||||
{
|
{
|
||||||
@ -1300,9 +1299,9 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock,
|
|||||||
if (attrib_fp && uid->attrib_data != NULL)
|
if (attrib_fp && uid->attrib_data != NULL)
|
||||||
dump_attribs (uid, pk);
|
dump_attribs (uid, pk);
|
||||||
|
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
uid_validity = 'r';
|
uid_validity = 'r';
|
||||||
else if (uid->is_expired)
|
else if (uid->flags.expired)
|
||||||
uid_validity = 'e';
|
uid_validity = 'e';
|
||||||
else if (opt.no_expensive_trust_checks)
|
else if (opt.no_expensive_trust_checks)
|
||||||
uid_validity = 0;
|
uid_validity = 0;
|
||||||
@ -1559,7 +1558,7 @@ do_reorder_keyblock (KBNODE keyblock, int attr)
|
|||||||
if (node->pkt->pkttype == PKT_USER_ID &&
|
if (node->pkt->pkttype == PKT_USER_ID &&
|
||||||
((attr && node->pkt->pkt.user_id->attrib_data) ||
|
((attr && node->pkt->pkt.user_id->attrib_data) ||
|
||||||
(!attr && !node->pkt->pkt.user_id->attrib_data)) &&
|
(!attr && !node->pkt->pkt.user_id->attrib_data)) &&
|
||||||
node->pkt->pkt.user_id->is_primary)
|
node->pkt->pkt.user_id->flags.primary)
|
||||||
{
|
{
|
||||||
primary = primary2 = node;
|
primary = primary2 = node;
|
||||||
for (node = node->next; node; primary2 = node, node = node->next)
|
for (node = node->next; node; primary2 = node, node = node->next)
|
||||||
|
@ -1323,7 +1323,7 @@ keyidlist(strlist_t users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
|
|||||||
for(node=node->next;node;node=node->next)
|
for(node=node->next;node;node=node->next)
|
||||||
{
|
{
|
||||||
if(node->pkt->pkttype==PKT_USER_ID
|
if(node->pkt->pkttype==PKT_USER_ID
|
||||||
&& node->pkt->pkt.user_id->is_primary)
|
&& node->pkt->pkt.user_id->flags.primary)
|
||||||
uid=node->pkt->pkt.user_id;
|
uid=node->pkt->pkt.user_id;
|
||||||
else if(node->pkt->pkttype==PKT_SIGNATURE
|
else if(node->pkt->pkttype==PKT_SIGNATURE
|
||||||
&& node->pkt->pkt.signature->
|
&& node->pkt->pkt.signature->
|
||||||
|
@ -1960,11 +1960,11 @@ check_sig_and_print (CTX c, kbnode_t node)
|
|||||||
continue;
|
continue;
|
||||||
if (!un->pkt->pkt.user_id->created)
|
if (!un->pkt->pkt.user_id->created)
|
||||||
continue;
|
continue;
|
||||||
if (un->pkt->pkt.user_id->is_revoked)
|
if (un->pkt->pkt.user_id->flags.revoked)
|
||||||
continue;
|
continue;
|
||||||
if (un->pkt->pkt.user_id->is_expired)
|
if (un->pkt->pkt.user_id->flags.expired)
|
||||||
continue;
|
continue;
|
||||||
if (!un->pkt->pkt.user_id->is_primary)
|
if (!un->pkt->pkt.user_id->flags.primary)
|
||||||
continue;
|
continue;
|
||||||
/* We want the textual primary user ID here */
|
/* We want the textual primary user ID here */
|
||||||
if (un->pkt->pkt.user_id->attrib_data)
|
if (un->pkt->pkt.user_id->attrib_data)
|
||||||
@ -2041,12 +2041,12 @@ check_sig_and_print (CTX c, kbnode_t node)
|
|||||||
{
|
{
|
||||||
if (un->pkt->pkttype != PKT_USER_ID)
|
if (un->pkt->pkttype != PKT_USER_ID)
|
||||||
continue;
|
continue;
|
||||||
if ((un->pkt->pkt.user_id->is_revoked
|
if ((un->pkt->pkt.user_id->flags.revoked
|
||||||
|| un->pkt->pkt.user_id->is_expired)
|
|| un->pkt->pkt.user_id->flags.expired)
|
||||||
&& !(opt.verify_options & VERIFY_SHOW_UNUSABLE_UIDS))
|
&& !(opt.verify_options & VERIFY_SHOW_UNUSABLE_UIDS))
|
||||||
continue;
|
continue;
|
||||||
/* Skip textual primary user ids which we printed above. */
|
/* Skip textual primary user ids which we printed above. */
|
||||||
if (un->pkt->pkt.user_id->is_primary
|
if (un->pkt->pkt.user_id->flags.primary
|
||||||
&& !un->pkt->pkt.user_id->attrib_data )
|
&& !un->pkt->pkt.user_id->attrib_data )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2071,9 +2071,9 @@ check_sig_and_print (CTX c, kbnode_t node)
|
|||||||
{
|
{
|
||||||
const char *valid;
|
const char *valid;
|
||||||
|
|
||||||
if (un->pkt->pkt.user_id->is_revoked)
|
if (un->pkt->pkt.user_id->flags.revoked)
|
||||||
valid = _("revoked");
|
valid = _("revoked");
|
||||||
else if (un->pkt->pkt.user_id->is_expired)
|
else if (un->pkt->pkt.user_id->flags.expired)
|
||||||
valid = _("expired");
|
valid = _("expired");
|
||||||
else
|
else
|
||||||
/* Since this is just informational, don't
|
/* Since this is just informational, don't
|
||||||
|
@ -280,19 +280,19 @@ typedef struct
|
|||||||
u32 help_key_expire;
|
u32 help_key_expire;
|
||||||
int help_full_count;
|
int help_full_count;
|
||||||
int help_marginal_count;
|
int help_marginal_count;
|
||||||
int is_primary; /* 2 if set via the primary flag, 1 if calculated */
|
|
||||||
int is_revoked;
|
|
||||||
int is_expired;
|
|
||||||
u32 expiredate; /* expires at this date or 0 if not at all */
|
u32 expiredate; /* expires at this date or 0 if not at all */
|
||||||
prefitem_t *prefs; /* list of preferences (may be NULL)*/
|
prefitem_t *prefs; /* list of preferences (may be NULL)*/
|
||||||
u32 created; /* according to the self-signature */
|
u32 created; /* according to the self-signature */
|
||||||
byte selfsigversion;
|
byte selfsigversion;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/* TODO: Move more flags here */
|
|
||||||
unsigned int mdc:1;
|
unsigned int mdc:1;
|
||||||
unsigned int ks_modify:1;
|
unsigned int ks_modify:1;
|
||||||
unsigned int compacted:1;
|
unsigned int compacted:1;
|
||||||
|
unsigned int primary:2; /* 2 if set via the primary flag, 1 if
|
||||||
|
* calculated */
|
||||||
|
unsigned int revoked:1;
|
||||||
|
unsigned int expired:1;
|
||||||
} flags;
|
} flags;
|
||||||
char *mbox; /* NULL or the result of mailbox_from_userid. */
|
char *mbox; /* NULL or the result of mailbox_from_userid. */
|
||||||
/* The text contained in the user id packet, which is normally the
|
/* The text contained in the user id packet, which is normally the
|
||||||
|
@ -235,12 +235,12 @@ do_edit_ownertrust (ctrl_t ctrl, PKT_public_key *pk, int mode,
|
|||||||
{
|
{
|
||||||
if (un->pkt->pkttype != PKT_USER_ID )
|
if (un->pkt->pkttype != PKT_USER_ID )
|
||||||
continue;
|
continue;
|
||||||
if (un->pkt->pkt.user_id->is_revoked )
|
if (un->pkt->pkt.user_id->flags.revoked)
|
||||||
continue;
|
continue;
|
||||||
if (un->pkt->pkt.user_id->is_expired )
|
if (un->pkt->pkt.user_id->flags.expired)
|
||||||
continue;
|
continue;
|
||||||
/* Only skip textual primaries */
|
/* Only skip textual primaries */
|
||||||
if (un->pkt->pkt.user_id->is_primary
|
if (un->pkt->pkt.user_id->flags.primary
|
||||||
&& !un->pkt->pkt.user_id->attrib_data )
|
&& !un->pkt->pkt.user_id->attrib_data )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ is_algo_in_prefs (kbnode_t keyblock, preftype_t type, int algo)
|
|||||||
PKT_user_id *uid = k->pkt->pkt.user_id;
|
PKT_user_id *uid = k->pkt->pkt.user_id;
|
||||||
prefitem_t *prefs = uid->prefs;
|
prefitem_t *prefs = uid->prefs;
|
||||||
|
|
||||||
if (uid->created && prefs && !uid->is_revoked && !uid->is_expired)
|
if (uid->created && prefs && !uid->flags.revoked && !uid->flags.expired)
|
||||||
{
|
{
|
||||||
for (; prefs->type; prefs++)
|
for (; prefs->type; prefs++)
|
||||||
if (prefs->type == type && prefs->value == algo)
|
if (prefs->type == type && prefs->value == algo)
|
||||||
|
@ -2209,9 +2209,9 @@ build_conflict_set (tofu_dbs_t dbs,
|
|||||||
{
|
{
|
||||||
found_user_id = 1;
|
found_user_id = 1;
|
||||||
|
|
||||||
if (user_id2->is_revoked)
|
if (user_id2->flags.revoked)
|
||||||
iter->flags |= BINDING_REVOKED;
|
iter->flags |= BINDING_REVOKED;
|
||||||
if (user_id2->is_expired)
|
if (user_id2->flags.expired)
|
||||||
iter->flags |= BINDING_EXPIRED;
|
iter->flags |= BINDING_EXPIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3470,7 +3470,7 @@ tofu_register_encryption (ctrl_t ctrl,
|
|||||||
{
|
{
|
||||||
PKT_user_id *uid = n->pkt->pkt.user_id;
|
PKT_user_id *uid = n->pkt->pkt.user_id;
|
||||||
|
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
add_to_strlist (&user_id_list, uid->name);
|
add_to_strlist (&user_id_list, uid->name);
|
||||||
@ -3805,7 +3805,7 @@ tofu_set_policy (ctrl_t ctrl, kbnode_t kb, enum tofu_policy policy)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
user_id = kb->pkt->pkt.user_id;
|
user_id = kb->pkt->pkt.user_id;
|
||||||
if (user_id->is_revoked)
|
if (user_id->flags.revoked)
|
||||||
/* Skip revoked user ids. (Don't skip expired user ids, the
|
/* Skip revoked user ids. (Don't skip expired user ids, the
|
||||||
expiry can be changed.) */
|
expiry can be changed.) */
|
||||||
continue;
|
continue;
|
||||||
|
10
g10/trust.c
10
g10/trust.c
@ -145,9 +145,9 @@ uid_trust_string_fixed (ctrl_t ctrl, PKT_public_key *key, PKT_user_id *uid)
|
|||||||
uid are both NULL, or neither are NULL. */
|
uid are both NULL, or neither are NULL. */
|
||||||
return _("10 translator see trust.c:uid_trust_string_fixed");
|
return _("10 translator see trust.c:uid_trust_string_fixed");
|
||||||
}
|
}
|
||||||
else if(uid->is_revoked || (key && key->flags.revoked))
|
else if(uid->flags.revoked || (key && key->flags.revoked))
|
||||||
return _("[ revoked]");
|
return _("[ revoked]");
|
||||||
else if(uid->is_expired)
|
else if(uid->flags.expired)
|
||||||
return _("[ expired]");
|
return _("[ expired]");
|
||||||
else if(key)
|
else if(key)
|
||||||
{
|
{
|
||||||
@ -688,7 +688,7 @@ clean_uid_from_key (kbnode_t keyblock, kbnode_t uidnode, int noisy)
|
|||||||
IDs if --allow-non-selfsigned-uid is set. */
|
IDs if --allow-non-selfsigned-uid is set. */
|
||||||
if (uid->created
|
if (uid->created
|
||||||
|| uid->flags.compacted
|
|| uid->flags.compacted
|
||||||
|| (!uid->is_expired && !uid->is_revoked && opt.allow_non_selfsigned_uid))
|
|| (!uid->flags.expired && !uid->flags.revoked && opt.allow_non_selfsigned_uid))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (node=uidnode->next;
|
for (node=uidnode->next;
|
||||||
@ -708,9 +708,9 @@ clean_uid_from_key (kbnode_t keyblock, kbnode_t uidnode, int noisy)
|
|||||||
const char *reason;
|
const char *reason;
|
||||||
char *user = utf8_to_native (uid->name, uid->len, 0);
|
char *user = utf8_to_native (uid->name, uid->len, 0);
|
||||||
|
|
||||||
if (uid->is_revoked)
|
if (uid->flags.revoked)
|
||||||
reason = _("revoked");
|
reason = _("revoked");
|
||||||
else if (uid->is_expired)
|
else if (uid->flags.expired)
|
||||||
reason = _("expired");
|
reason = _("expired");
|
||||||
else
|
else
|
||||||
reason = _("invalid");
|
reason = _("invalid");
|
||||||
|
@ -1099,14 +1099,14 @@ tdb_get_validity_core (ctrl_t ctrl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the user id is revoked or expired, then skip it. */
|
/* If the user id is revoked or expired, then skip it. */
|
||||||
if (user_id->is_revoked || user_id->is_expired)
|
if (user_id->flags.revoked || user_id->flags.expired)
|
||||||
{
|
{
|
||||||
if (DBG_TRUST)
|
if (DBG_TRUST)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
if (user_id->is_revoked && user_id->is_expired)
|
if (user_id->flags.revoked && user_id->flags.expired)
|
||||||
s = "revoked and expired";
|
s = "revoked and expired";
|
||||||
else if (user_id->is_revoked)
|
else if (user_id->flags.revoked)
|
||||||
s = "revoked";
|
s = "revoked";
|
||||||
else
|
else
|
||||||
s = "expire";
|
s = "expire";
|
||||||
@ -1115,7 +1115,7 @@ tdb_get_validity_core (ctrl_t ctrl,
|
|||||||
s, user_id->name);
|
s, user_id->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_id->is_revoked)
|
if (user_id->flags.revoked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
expired = 1;
|
expired = 1;
|
||||||
@ -1604,8 +1604,8 @@ validate_one_keyblock (KBNODE kb, struct key_item *klist,
|
|||||||
resigned. -dshaw */
|
resigned. -dshaw */
|
||||||
|
|
||||||
if (node->pkt->pkttype == PKT_USER_ID
|
if (node->pkt->pkttype == PKT_USER_ID
|
||||||
&& !node->pkt->pkt.user_id->is_revoked
|
&& !node->pkt->pkt.user_id->flags.revoked
|
||||||
&& !node->pkt->pkt.user_id->is_expired)
|
&& !node->pkt->pkt.user_id->flags.expired)
|
||||||
{
|
{
|
||||||
if (uidnode && issigned)
|
if (uidnode && issigned)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user