summaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-07-22 11:43:10 +0200
committerWerner Koch <wk@gnupg.org>2009-07-22 11:43:10 +0200
commit5d310a8de75e513ac0d44b2960966a631dae9670 (patch)
treeea684db1398d32be5f22613b259770eb861571aa /g10
parentFix i18n bug. (diff)
downloadgnupg2-5d310a8de75e513ac0d44b2960966a631dae9670.tar.xz
gnupg2-5d310a8de75e513ac0d44b2960966a631dae9670.zip
Print verbose instructions in case of a corrupted trustdb.
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/gpg.c6
-rw-r--r--g10/tdbio.c7
-rw-r--r--g10/tdbio.h1
-rw-r--r--g10/trustdb.c21
-rw-r--r--g10/trustdb.h1
6 files changed, 35 insertions, 8 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 0d472ac63..55be0eff9 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -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.
diff --git a/g10/gpg.c b/g10/gpg.c
index 2f9acb63d..7f3163186 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -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:
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 231f451e7..c0dd5abf4 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -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);
}
diff --git a/g10/tdbio.h b/g10/tdbio.h
index d6af98fd0..ddc5afccf 100644
--- a/g10/tdbio.h
+++ b/g10/tdbio.h
@@ -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*/
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 902089c2d..1d083a738 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -408,6 +408,27 @@ setup_trustdb( int level, const char *dbname )
}
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()
{
int level = trustdb_args.level;
diff --git a/g10/trustdb.h b/g10/trustdb.h
index 65eb8d1bb..e2202f38f 100644
--- a/g10/trustdb.h
+++ b/g10/trustdb.h
@@ -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 );