* 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.
This commit is contained in:
David Shaw 2002-12-04 00:05:11 +00:00
parent e357092285
commit 3b7ca1faa5
5 changed files with 51 additions and 9 deletions

View File

@ -1,5 +1,17 @@
2002-12-03 David Shaw <dshaw@jabberwocky.com>
* 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

View File

@ -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;

View File

@ -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;

View File

@ -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 );

View File

@ -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;
}