Page MenuHome GnuPG

gpg2 corrupts trustdb.gpg with debug output
Closed, ResolvedPublic

Description

Under some circumstance gpg2 writes debug output into ~/.gnupg/trustdb.gpg,
corrupting it in the process. I've observed this with

gpg (GnuPG) 2.0.11
libgcrypt 1.4.4
gpgme 1.1.8
Kontact enterprise35 20090508.965262

Kontact still uses gpg 1.4 to handle inline pgp messages. This fails when the
gpg config file contains debug settings for watchgnupg (debug-level and
log-file). To avoid that I've started to use a separate gpg.conf-2 file for
gpg2, which only contains those debug settings.

Now, when debug-level is anything other than none, i.e. even when it's something
low, like "basic", some of the debug output of gpg2 ends up in trustdb.gpg when
configuring the keys for an identity in Kontact. Just open the Kontact
configuration dialog, open the kmail identities page, switch to the cryptography
settings and click on the "Change..." button to select an OpenPGP encryption
key. The list of keys that comes up is empty and kwatchgnupg shows:

4 - 2009-06-04 15:58:10 gpg[8042]: /powerhome/bh/.gnupg/trustdb.gpg: invalid
record type 114 at recnum 1

4 - 2009-06-04 15:58:10 gpg[8042]: /powerhome/bh/.gnupg/trustdb.gpg: invalid

record type 55 at recnum 34

4 - 2009-06-04 15:58:10 gpg[8042]: lookup_hashtable: read item failed: Trust

DB error

4 - 2009-06-04 15:58:10 gpg[8042]: trustdb: searching trust record failed:

Trust DB error

4 - 2009-06-04 15:58:10 gpg[8042]: the trustdb is corrupted; please run "gpg

--fix-trustdb".

Looking into trustdb.gpg I find some debug output from gpg2:

random usage: poolsize=600 mixed=0 polls=0/0 added=0/0

outmix=0 getlvl1=0/0 getlvl2=0/0

secmem usage: 0/32768 bytes in 0 blocks

Details

Version
2.0.11

Event Timeline

bherzog set Version to 2.0.11.
bherzog added a subscriber: bherzog.

I guess that Kontact calls gpgconf with the the standard descriptors closed.
Without debugging I can't say why stuff ends up in trustdb.gpg but it is an all
too common problem that I expect thsi cause.

Please check whether this still happens with gnupg rev 5039 or with the patch below

  • tools/gpgconf.c (revision 5038)

+++ tools/gpgconf.c (working copy)
@@ -25,6 +25,7 @@

#include "gpgconf.h"
#include "i18n.h"
+#include "sysutils.h"

/* Constants to identify the commands and options. */
enum cmd_and_opt_values
@@ -145,6 +146,7 @@

enum cmd_and_opt_values cmd = 0;
FILE *outfp = NULL;

+ gnupg_reopen_std ("gpgconf");

set_strusage (my_strusage);
log_set_prefix ("gpgconf", 1);
werner claimed this task.
werner removed a project: Restricted Project.

No response - assuming that it has been fixed.