#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#include "gpg.h"
#include "keydb.h"
#include "main.h"
#include "i18n.h"
#include "trustdb.h"
+#include "host2net.h"
/* Return true if key is disabled. Note that this is usually used via
const char *
-uid_trust_string_fixed (PKT_public_key *key, PKT_user_id *uid)
+uid_trust_string_fixed (ctrl_t ctrl, PKT_public_key *key, PKT_user_id *uid)
{
if (!key && !uid)
{
return _("[ expired]");
else if(key)
{
- switch (get_validity(key,uid)&TRUST_MASK)
+ switch (get_validity (ctrl, key, uid, NULL, 0) & TRUST_MASK)
{
case TRUST_UNKNOWN: return _("[ unknown]");
case TRUST_EXPIRED: return _("[ expired]");
case TRUST_UNDEFINED: return _("[ undef ]");
+ case TRUST_NEVER: return _("[ never ]");
case TRUST_MARGINAL: return _("[marginal]");
case TRUST_FULLY: return _("[ full ]");
case TRUST_ULTIMATE: return _("[ultimate]");
void
-check_trustdb_stale (void)
+check_trustdb_stale (ctrl_t ctrl)
{
#ifndef NO_TRUST_MODELS
- tdb_check_trustdb_stale ();
+ tdb_check_trustdb_stale (ctrl);
+#else
+ (void)ctrl;
#endif
}
void
-check_or_update_trustdb (void)
+check_or_update_trustdb (ctrl_t ctrl)
{
#ifndef NO_TRUST_MODELS
- tdb_check_or_update ();
+ tdb_check_or_update (ctrl);
+#else
+ (void)ctrl;
#endif
}
/*
* Return the validity information for PK. If the namehash is not
- * NULL, the validity of the corresponsing user ID is returned,
+ * NULL, the validity of the corresponding user ID is returned,
* otherwise, a reasonable value for the entire key is returned.
*/
unsigned int
-get_validity (PKT_public_key *pk, PKT_user_id *uid)
+get_validity (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *uid,
+ PKT_signature *sig, int may_ask)
{
int rc;
unsigned int validity;
{
char *tempkeystr = xstrdup (keystr (pk->main_keyid));
log_error ("error getting main key %s of subkey %s: %s\n",
- tempkeystr, keystr (kid), g10_errstr (rc));
+ tempkeystr, keystr (kid), gpg_strerror (rc));
xfree (tempkeystr);
validity = TRUST_UNKNOWN;
goto leave;
#ifdef NO_TRUST_MODELS
validity = TRUST_UNKNOWN;
#else
- validity = tdb_get_validity_core (pk, uid, main_pk);
+ validity = tdb_get_validity_core (ctrl, pk, uid, main_pk, sig, may_ask);
#endif
leave:
int
-get_validity_info (PKT_public_key *pk, PKT_user_id *uid)
+get_validity_info (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *uid)
{
int trustlevel;
if (!pk)
return '?'; /* Just in case a NULL PK is passed. */
- trustlevel = get_validity (pk, uid);
+ trustlevel = get_validity (ctrl, pk, uid, NULL, 0);
if ((trustlevel & TRUST_FLAG_REVOKED))
return 'r';
return trust_letter (trustlevel);
const char *
-get_validity_string (PKT_public_key *pk, PKT_user_id *uid)
+get_validity_string (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *uid)
{
int trustlevel;
if (!pk)
return "err"; /* Just in case a NULL PK is passed. */
- trustlevel = get_validity (pk, uid);
+ trustlevel = get_validity (ctrl, pk, uid, NULL, 0);
if ((trustlevel & TRUST_FLAG_REVOKED))
return _("revoked");
return trust_value_to_string (trustlevel);
u32 expire;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_SIG_EXPIRE, NULL );
- expire = p? sig->timestamp + buffer_to_u32(p) : 0;
+ expire = p? sig->timestamp + buf32_to_u32(p) : 0;
if (expire==0 || expire > curtime )
{
kbnode_t node;
u32 keyid[2];
- assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
+ log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
keyid_from_pk (keyblock->pkt->pkt.public_key, keyid);
compacted. To "compact" a user ID, we simply remove ALL signatures
except the self-sig that caused the user ID to be remove-worthy.
We don't actually remove the user ID packet itself since it might
- be ressurected in a later merge. Note that this function requires
+ be resurrected in a later merge. Note that this function requires
that the caller has already done a merge_keys_and_selfsig().
TODO: change the import code to allow importing a uid with only a
PKT_user_id *uid = uidnode->pkt->pkt.user_id;
int deleted = 0;
- assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
- assert (uidnode->pkt->pkttype==PKT_USER_ID);
+ log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
+ log_assert (uidnode->pkt->pkttype==PKT_USER_ID);
/* Skip valid user IDs, compacted user IDs, and non-self-signed user
IDs if --allow-non-selfsigned-uid is set. */
clean_one_uid (kbnode_t keyblock, kbnode_t uidnode, int noisy, int self_only,
int *uids_cleaned, int *sigs_cleaned)
{
- int dummy;
+ int dummy = 0;
- assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
- assert (uidnode->pkt->pkttype==PKT_USER_ID);
+ log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
+ log_assert (uidnode->pkt->pkttype==PKT_USER_ID);
if (!uids_cleaned)
uids_cleaned = &dummy;