Print verbose instructions in case of a corrupted trustdb.

This commit is contained in:
Werner Koch 2009-07-22 09:43:10 +00:00
parent 12fa2baa62
commit 5d310a8de7
6 changed files with 35 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2009-07-22 Werner Koch <wk@g10code.com>
* gpg.c (main) <aFixTrustDB>: Show commands to run.
* trustdb.c (how_to_fix_the_trustdb): New.
* tdbio.c (tdbio_invalid): Show commands to re-create the trustdb.
Fixes bug#929.
2009-07-20 Werner Koch <wk@g10code.com>
* keygen.c (generate_keypair): Allow Elgamal > 3072 in BOTH mode.

View File

@ -3372,8 +3372,8 @@ main (int argc, char **argv)
case aGenRandom:
case aDeArmor:
case aEnArmor:
case aFixTrustDB:
break;
case aFixTrustDB:
case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
default: rc = setup_trustdb(1, trustdb_name ); break;
@ -3895,9 +3895,7 @@ main (int argc, char **argv)
break;
case aFixTrustDB:
log_error("this command is not yet implemented.\n");
log_error("A workaround is to use \"--export-ownertrust\", remove\n");
log_error("the trustdb file and do an \"--import-ownertrust\".\n" );
how_to_fix_the_trustdb ();
break;
case aListTrustPath:

View File

@ -1499,12 +1499,11 @@ tdbio_search_trust_bypk (PKT_public_key *pk, TRUSTREC *rec)
}
void
tdbio_invalid(void)
{
log_error(_(
"the trustdb is corrupted; please run \"gpg --fix-trustdb\".\n") );
g10_exit(2);
log_error (_("Error: The trustdb is corrupted.\n"));
how_to_fix_the_trustdb ();
g10_exit (2);
}

View File

@ -111,6 +111,7 @@ ulong tdbio_new_recnum(void);
int tdbio_search_trust_byfpr(const byte *fingerprint, TRUSTREC *rec );
int tdbio_search_trust_bypk(PKT_public_key *pk, TRUSTREC *rec );
void tdbio_how_to_fix (void);
void tdbio_invalid(void);
#endif /*G10_TDBIO_H*/

View File

@ -407,6 +407,27 @@ setup_trustdb( int level, const char *dbname )
return 0;
}
void
how_to_fix_the_trustdb ()
{
const char *name = trustdb_args.dbname;
if (!name)
name = "trustdb.gpg";
log_info (_("You may try to re-create the trustdb using the commands:\n"));
log_info (" cd %s\n", default_homedir ());
log_info (" gpg2 --export-ownertrust > otrust.tmp\n");
#ifdef HAVE_W32_SYSTEM
log_info (" del %s\n", name);
#else
log_info (" rm %s\n", name);
#endif
log_info (" gpg2 --import-ownertrust < otrust.tmp\n");
log_info (_("If that does not work, please consult the manual\n"));
}
void
init_trustdb()
{

View File

@ -44,6 +44,7 @@ void register_trusted_key( const char *string );
void check_trustdb (void);
void update_trustdb (void);
int setup_trustdb( int level, const char *dbname );
void how_to_fix_the_trustdb (void);
void init_trustdb( void );
void check_trustdb_stale(void);
void sync_trustdb( void );