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