Add a fake status-fd command to create a trustdb.gpg if missing.

For some reason, in GnuPG>=2.x, a missing/corrupted trustdb is a fatal
error. This means that if the homedir was just changed, and any command which
utilizes keys is called (e.g. sign, encrypt, decrypt, etc.) GnuPG dies without
executing the command because we can't find a valid trustdb.

What's even more is that there is a new command in GnuPG>=2.x:
'--fix-trustdb'. You'd think it would, you know, *fix the trustdb*. Hah! Think
again! It prints out a series of shell commands (incorrect ones, at that, as
they don't respect the relevant env variables such as $GNUPGHOME) in a format
which is *not* exec'able (i.e. you can't do something similar to how

    $ exec `ssh-agent`

is used). Software engineering, motherfuckers. #FML.
fix/24-enc-to-file
Isis Lovecruft 2013-10-08 10:16:10 +00:00
parent 70c029b2d8
commit 9164c8dc83
No known key found for this signature in database
GPG Key ID: 5C17776E27F7E84D
2 changed files with 6 additions and 0 deletions

View File

@ -511,6 +511,10 @@ class GPGBase(object):
log.warn("%s" % value)
elif keyword.upper().startswith("FATAL"):
log.critical("%s" % value)
# Handle the gpg2 error where a missing trustdb.gpg is,
# for some stupid reason, considered fatal:
if value.find("trustdb.gpg") and value.find("No such file"):
result._handle_status('NEED_TRUSTDB', '')
else:
if self.verbose:
log.info("%s" % line)

View File

@ -1290,6 +1290,8 @@ class Crypt(Verify):
"MISSING_PASSPHRASE", "DECRYPTION_FAILED",
"KEY_NOT_CREATED"):
self.status = key.replace("_", " ").lower()
elif key == "NEED_TRUSTDB":
self._gpg._create_trustdb()
elif key == "NEED_PASSPHRASE_SYM":
self.status = 'need symmetric passphrase'
elif key == "BEGIN_DECRYPTION":