mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: Fix output in case of a corrupted trustdb.
* g10/tdbdump.c (list_trustdb): Add arg FP and change callers to pass es_stdout. * g10/tdbio.c (upd_hashtable): On a corrupted trustdb call list_trustdb only in verbose > 1 mode and let it dump to stderr. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
840f807a90
commit
bf06d04f53
@ -4167,10 +4167,10 @@ main (int argc, char **argv)
|
||||
#ifndef NO_TRUST_MODELS
|
||||
case aListTrustDB:
|
||||
if( !argc )
|
||||
list_trustdb(NULL);
|
||||
list_trustdb (es_stdout, NULL);
|
||||
else {
|
||||
for( ; argc; argc--, argv++ )
|
||||
list_trustdb( *argv );
|
||||
list_trustdb (es_stdout, *argv );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -61,11 +61,11 @@ write_record( TRUSTREC *rec )
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Dump the entire trustdb or only the entries of one key.
|
||||
/*
|
||||
* Dump the entire trustdb to FP or only the entries of one key.
|
||||
*/
|
||||
void
|
||||
list_trustdb (const char *username)
|
||||
list_trustdb (estream_t fp, const char *username)
|
||||
{
|
||||
TRUSTREC rec;
|
||||
|
||||
@ -78,12 +78,12 @@ list_trustdb (const char *username)
|
||||
ulong recnum;
|
||||
int i;
|
||||
|
||||
es_printf ("TrustDB: %s\n", tdbio_get_dbname() );
|
||||
for(i=9+strlen(tdbio_get_dbname()); i > 0; i-- )
|
||||
es_putc ('-', es_stdout);
|
||||
es_putc ('\n', es_stdout);
|
||||
for(recnum=0; !tdbio_read_record( recnum, &rec, 0); recnum++ )
|
||||
tdbio_dump_record (&rec, es_stdout);
|
||||
es_fprintf (fp, "TrustDB: %s\n", tdbio_get_dbname ());
|
||||
for (i = 9 + strlen (tdbio_get_dbname()); i > 0; i-- )
|
||||
es_fputc ('-', fp);
|
||||
es_putc ('\n', fp);
|
||||
for (recnum=0; !tdbio_read_record (recnum, &rec, 0); recnum++)
|
||||
tdbio_dump_record (&rec, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1132,7 +1132,8 @@ upd_hashtable (ulong table, byte *key, int keylen, ulong newrecnum)
|
||||
{
|
||||
log_error ("hashtbl %lu: %lu/%d points to an invalid record %lu\n",
|
||||
table, hashrec, (msb % ITEMS_PER_HTBL_RECORD), item);
|
||||
list_trustdb (NULL); /*FIXME: Bad - prints to stdout!!! */
|
||||
if (opt.verbose > 1)
|
||||
list_trustdb (es_stderr, NULL);
|
||||
return GPG_ERR_TRUSTDB;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void tdb_update_ownertrust (PKT_public_key *pk, unsigned int new_trust);
|
||||
int tdb_clear_ownertrusts (PKT_public_key *pk);
|
||||
|
||||
/*-- tdbdump.c --*/
|
||||
void list_trustdb(const char *username);
|
||||
void list_trustdb (estream_t fp, const char *username);
|
||||
void export_ownertrust(void);
|
||||
void import_ownertrust(const char *fname);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user