Commit Graph

16 Commits (47ddca4c03a3cd9b53be72f9c3e9f735a09a0648)

Author SHA1 Message Date
Isis Lovecruft 47ddca4c03
Clean up a log.debug() statement in gnupg.GPGBase._encrypt(). 2013-10-08 11:53:02 +00:00
Isis Lovecruft 4780f4443d
Add clearer logging to gnupg.GPGBase._read_data(). 2013-10-08 11:44:45 +00:00
Isis Lovecruft 78400df41c
Use type(data)().join() trick regardless of running py3k.
This is a rather elegant trick from upstream to deal with the differences
between bytesarrays, strings, and unicode literals between Python2.x and
Py3k. However, it doesn't actually make a difference if we're running Py3k or
not to use the trick, since it dynamically calls the builtin type for the
native string in any Python version. It works like so:

  >>> import sys
  >>> data = '{}\n2 + 2 ≠ 5'.format(sys.version[:5])
  >>> print(data)
  3.3.2
  2 + 2 ≠ 5
  >>> type(data)
  <class 'str'>
  >>> type(data)()
  ''
  >>> unicodedata = u'Mon corps et moi étions un, á cause de cette corde maudite.'
  >>> type(unicodedata)
  <class 'str'>

Also, in Python2.x:

  >>> import sys
  >>> data = '{}\n2 + 2 ≠ 5'.format(sys.version[:5])
  >>> print data
  2.7.5
  2 + 2 ≠ 5
  >>> type(data)
  <type 'str'>
  >>> type(data)()
  ''
  >>> unicodedata = u'Mon corps et moi étions un, á cause de cette corde maudite.'
  >>> type(unicodedata)
  <type 'unicode'>
  >>> type(unicodedata)()
  u''
2013-10-08 10:30:12 +00:00
Isis Lovecruft ade3ec97ee
Give gnupg.GPGBase._read_data() a better docstring. 2013-10-08 10:28:37 +00:00
Isis Lovecruft 9164c8dc83
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.
2013-10-08 10:16:10 +00:00
Isis Lovecruft 70c029b2d8
Log stderr userland messages from GnuPG at their corresponding log levels. 2013-10-08 10:14:59 +00:00
Isis Lovecruft 4955fed865
Separate gnupg.GPGBase._read_response() into multiple functions.
* ADD function _util._deprefix() for stripping a given prefix from the
   beginning of another string.
 * ADD function _util._separate_keywork() for extracting the keyword from the
   beginning of status-fd output.
 * REMOVE excess EOL whitespace.
 * CLEANUP method gnupg.GPGBase._read_response().
2013-10-08 09:58:27 +00:00
drebs 93c87bcd88 Allow choice of digest algorithm when signing. 2013-10-05 13:10:03 -03:00
Mikael Nordfeldth 314e670ada test_gpg_binary_version_str failed for non-English
This patch sets the environment variable LANGUGE to 'en', meaning English translation is used for outputs. The string comparisons in test_gpg_binary_version_str failed otherwise when using a non-English locale. Another choice may be to set LANG=C to avoid locales all-in-all.
2013-07-29 00:27:49 +02:00
Isis Lovecruft 6b154c294e
Change LICENSE to GPLv3+, after discussion with intrigeri.
* ADD docs/change-license-emails.txt, which includes email exchanges between
   myself and intrigeri, including links to Debian and LEAP mailing lists with
   arguments for and against using AGPL for a library.
 * CHANGE license header for all files.
 * CHANGE LICENSE file and gnupg/copyright.py to use GPLv3+ text.
2013-07-27 19:27:53 +00:00
drebs 9db97dd184 Fix sign() and encrypt() docstrings. 2013-07-09 08:35:42 +00:00
Isis Lovecruft 328e8fcbe0
Add a 'generated-keys' subdirectory to gnupg.GPG.homedir.
* Add GPG._generated_keys as an _utils.InheritableProperty class for storing
   a configurable (even by subclasses of GPGBase, without property overrides)
   subdirectory of whichever directory gnupg.GPG.homedir is set to. This
   subdirectory can be used via the 'separate_keyring=True' option to
   gnupg.GPG.gen_key_input(), which will switch temporarily to new pubring.gpg
   and secring.gpg keyrings during key creation, and upon finishing creation
   of the new key, will ask for the new key's fingerprint, and move the
   keyrings into this GPG._generated_keys directory, renamed in the format
   "<GPG.homedir>/<GPG._generated_keys>/<fingerprint>.[pub|sec]ring.gpg".
2013-06-28 06:29:38 +00:00
Isis Lovecruft bcaa26685b
Change several imports for installed modules to be absolute in _meta.py. 2013-06-09 08:35:17 +00:00
Isis Lovecruft 295d98fbdc
GPG.encrypt_file()→GPGBase.encrypt() and fix doctests and documentation. 2013-06-04 01:42:07 +00:00
Isis Lovecruft 785b2760bb
Move GPG._sign_file() to GPGBase since it's never called directly. 2013-06-03 21:34:39 +00:00
Isis Lovecruft 042d52a75f
Move source files to directory named for top-level package. 2013-06-03 21:16:19 +00:00