aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog12
-rw-r--r--g10/options.h2
-rw-r--r--g10/tdbio.c43
-rw-r--r--g10/tdbio.h2
-rw-r--r--g10/trustdb.c1
5 files changed, 51 insertions, 9 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index ae9bdcb1b..d30496eb7 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,17 @@
2002-12-03 David Shaw <[email protected]>
+ * tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record): Store
+ trust model in the trustdb version record.
+ (tdbio_update_version_record): New function to update version
+ record values during a trustdb check or update.
+ (tdbio_dump_record): Show trust model in dump.
+
+ * trustdb.c (validate_keys): Call tdbio_update_version_record on
+ success so that the correct options are stored in the trustdb.
+
+ * options.h: rearrange trust models so that CLASSIC is 0 and
+ OPENPGP is 1.
+
* options.h, g10.c (main), encode.c (write_pubkey_enc_from_list),
pkclist.c (algo_available), revoke.c (gen_revoke): Add --pgp8
mode. This is basically identical to --pgp7 in all ways except
diff --git a/g10/options.h b/g10/options.h
index 9917a4a61..d8857be2e 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -88,7 +88,7 @@ struct {
int skip_verify;
int compress_keys;
int compress_sigs;
- enum {TM_OPENPGP, TM_CLASSIC, TM_ALWAYS} trust_model;
+ enum {TM_CLASSIC=0, TM_OPENPGP=1, TM_ALWAYS} trust_model;
unsigned int force_ownertrust;
int pgp2;
int pgp6;
diff --git a/g10/tdbio.c b/g10/tdbio.c
index c928b76ec..45fae047c 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -418,6 +418,29 @@ cleanup(void)
}
}
+/* Caller must sync */
+int
+tdbio_update_version_record (void)
+{
+ TRUSTREC rec;
+ int rc;
+
+ memset( &rec, 0, sizeof rec );
+
+ rc=tdbio_read_record( 0, &rec, RECTYPE_VER);
+ if(rc==0)
+ {
+ rec.r.ver.created = make_timestamp();
+ rec.r.ver.marginals = opt.marginals_needed;
+ rec.r.ver.completes = opt.completes_needed;
+ rec.r.ver.cert_depth = opt.max_cert_depth;
+ rec.r.ver.trust_model = opt.trust_model;
+ rc=tdbio_write_record(&rec);
+ }
+
+ return rc;
+}
+
static int
create_version_record (void)
{
@@ -425,11 +448,12 @@ create_version_record (void)
int rc;
memset( &rec, 0, sizeof rec );
- rec.r.ver.version = 3;
- rec.r.ver.created = make_timestamp();
- rec.r.ver.marginals = opt.marginals_needed;
- rec.r.ver.completes = opt.completes_needed;
- rec.r.ver.cert_depth = opt.max_cert_depth;
+ rec.r.ver.version = 3;
+ rec.r.ver.created = make_timestamp();
+ rec.r.ver.marginals = opt.marginals_needed;
+ rec.r.ver.completes = opt.completes_needed;
+ rec.r.ver.cert_depth = opt.max_cert_depth;
+ rec.r.ver.trust_model = opt.trust_model;
rec.rectype = RECTYPE_VER;
rec.recnum = 0;
rc = tdbio_write_record( &rec );
@@ -1060,12 +1084,13 @@ tdbio_dump_record( TRUSTREC *rec, FILE *fp )
case 0: fprintf(fp, "blank\n");
break;
case RECTYPE_VER: fprintf(fp,
- "version, td=%lu, f=%lu, m/c/d=%d/%d/%d nc=%lu (%s)\n",
+ "version, td=%lu, f=%lu, m/c/d=%d/%d/%d tm=%d nc=%lu (%s)\n",
rec->r.ver.trusthashtbl,
rec->r.ver.firstfree,
rec->r.ver.marginals,
rec->r.ver.completes,
rec->r.ver.cert_depth,
+ rec->r.ver.trust_model,
rec->r.ver.nextcheck,
strtimestamp(rec->r.ver.nextcheck)
);
@@ -1158,7 +1183,8 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
rec->r.ver.marginals = *p++;
rec->r.ver.completes = *p++;
rec->r.ver.cert_depth = *p++;
- p += 4; /* lock flags */
+ rec->r.ver.trust_model = *p++;
+ p += 3;
rec->r.ver.created = buftoulong(p); p += 4;
rec->r.ver.nextcheck = buftoulong(p); p += 4;
p += 4;
@@ -1242,7 +1268,8 @@ tdbio_write_record( TRUSTREC *rec )
*p++ = rec->r.ver.marginals;
*p++ = rec->r.ver.completes;
*p++ = rec->r.ver.cert_depth;
- p += 4; /* skip lock flags */
+ *p++ = rec->r.ver.trust_model;
+ p += 3;
ulongtobuf(p, rec->r.ver.created); p += 4;
ulongtobuf(p, rec->r.ver.nextcheck); p += 4;
p += 4;
diff --git a/g10/tdbio.h b/g10/tdbio.h
index 6a28edc5a..91a73efe6 100644
--- a/g10/tdbio.h
+++ b/g10/tdbio.h
@@ -54,6 +54,7 @@ struct trust_record {
byte marginals;
byte completes;
byte cert_depth;
+ byte trust_model;
ulong created; /* timestamp of trustdb creation */
ulong nextcheck; /* timestamp of next scheduled check */
ulong reserved;
@@ -89,6 +90,7 @@ struct trust_record {
typedef struct trust_record TRUSTREC;
/*-- tdbio.c --*/
+int tdbio_update_version_record(void);
int tdbio_set_dbname( const char *new_dbname, int create );
const char *tdbio_get_dbname(void);
void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
diff --git a/g10/trustdb.c b/g10/trustdb.c
index ffdce2c16..8c732bb99 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -1912,6 +1912,7 @@ validate_keys (int interactive)
log_info (_("next trustdb check due at %s\n"),
strtimestamp (next_expire));
}
+ tdbio_update_version_record();
do_sync ();
pending_check_trustdb = 0;
}