[svn] GnuPG - r5087 - trunk/g10

svn author wk cvs at cvs.gnupg.org
Wed Jul 22 11:43:10 CEST 2009


Author: wk
Date: 2009-07-22 11:43:10 +0200 (Wed, 22 Jul 2009)
New Revision: 5087

Modified:
   trunk/g10/ChangeLog
   trunk/g10/gpg.c
   trunk/g10/tdbio.c
   trunk/g10/tdbio.h
   trunk/g10/trustdb.c
   trunk/g10/trustdb.h
Log:
Print verbose instructions in case of a corrupted trustdb.


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/ChangeLog	2009-07-22 09:43:10 UTC (rev 5087)
@@ -1,3 +1,10 @@
+2009-07-22  Werner Koch  <wk at 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 at g10code.com>
 
 	* keygen.c (generate_keypair): Allow Elgamal > 3072 in BOTH mode.

Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/gpg.c	2009-07-22 09:43:10 UTC (rev 5087)
@@ -3372,8 +3372,8 @@
       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 @@
 	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:

Modified: trunk/g10/tdbio.c
===================================================================
--- trunk/g10/tdbio.c	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/tdbio.c	2009-07-22 09:43:10 UTC (rev 5087)
@@ -1499,12 +1499,11 @@
 }
 
 
-
 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);
 }
 

Modified: trunk/g10/tdbio.h
===================================================================
--- trunk/g10/tdbio.h	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/tdbio.h	2009-07-22 09:43:10 UTC (rev 5087)
@@ -111,6 +111,7 @@
 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*/

Modified: trunk/g10/trustdb.c
===================================================================
--- trunk/g10/trustdb.c	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/trustdb.c	2009-07-22 09:43:10 UTC (rev 5087)
@@ -408,6 +408,27 @@
 }
 
 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;

Modified: trunk/g10/trustdb.h
===================================================================
--- trunk/g10/trustdb.h	2009-07-21 15:44:30 UTC (rev 5086)
+++ trunk/g10/trustdb.h	2009-07-22 09:43:10 UTC (rev 5087)
@@ -44,6 +44,7 @@
 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 );




More information about the Gnupg-commits mailing list