Commit Graph

49 Commits (d66b23b896851ebd0682d2f2f4627b075262f962)

Author SHA1 Message Date
Isis Lovecruft d66b23b896
Add support for running on PyPy. 2015-02-22 22:57:59 +00:00
Isis Lovecruft 513a48d876
Add throw_keyids=bool option to encrypt() method.
* FIXES part of Issue #67.
   https://github.com/isislovecruft/python-gnupg/issues/67
2014-11-27 02:19:34 +00:00
Isis Lovecruft 09c6a08637 Merge remote-tracking branch 'tomgalloway/develop' into fix/67-hidden-encrypt 2014-11-27 01:18:37 +00:00
Isis Lovecruft a1e4a8a756
Use process uids and usernames on Unix and Windows respectively.
Windows doesn't have EUIDs, so instead we'll check that the usernames
match. This doesn't seem the least bit secure to me, but it's Windows so
they're probably owned anyway. If anyone knows one of the "proper" ways
to determine if another process has the same owner on Windows, I'd love
to know about it.

 * FIXES Issue #58 but I don't have a Windows machine to test so maybe
   it's still broken.
   https://github.com/isislovecruft/python-gnupg/issues/58
2014-11-27 00:03:27 +00:00
Isis Lovecruft 59992eb8c3
Put verbosity args before other options/args.
* FIXES Issue #76:
   https://github.com/isislovecruft/python-gnupg/issues/76
2014-11-19 03:51:06 +00:00
Tom Galloway 350027b18c Add parameter description 2014-11-10 13:07:27 +00:00
Tom Galloway 327d2e5f66 Actually add test to be run and format variable correctly. 2014-10-29 14:59:43 +00:00
Tom Galloway df5fdb5aa8 Allow --hidden-recipient to be used for a list of recipients. 2014-10-29 14:47:27 +00:00
Isis Lovecruft d9116bace6
Replace UnicodeDecodeErrors caused by Python2 readline() method.
* CHANGE gnupg._meta.GPGBase.__init__() to register the builtin
   `codecs.replace_errors` handler and a global codecs "strict" error
   handler.
 * FIXES Issue #49:
   https://github.com/isislovecruft/python-gnupg/issues/49
2014-10-28 01:01:03 +00:00
Isis Lovecruft 4a8a8c8592
Close process FDs after __init__() sanity check.
* FIXES and issue discovered by ttanner (https://github.com/ttanner)
   in `gnupg._meta.GPGBase._check_sane_and_get_gpg_version()` where the
   GnuPG process wasn't closed and its file descriptors were left
   hanging.

 * FIXES part of Issue #63.
   https://github.com/isislovecruft/python-gnupg/issues/63

   There were so many hanging FD issues when I started patching
   upstream python-gnupg ― I doubt I found all of them. I probably even
   introduced some along the way. And, as ttanner pointed out, this
   patch doesn't fix the issue fully, so there are likely more.
2014-09-27 01:22:27 +00:00
Isis Lovecruft b51b0eb5ac
Only use `--debug-level=` syntax if GnuPG<=1.4.18.
* FIXES Issue #44 (again):
   https://github.com/isislovecruft/python-gnupg/issues/44#issuecomment-56907151
2014-09-26 02:43:22 +00:00
Isis Lovecruft bb5e2444ad
Cleanup logic for helping users who set a weird `verbose=` level.
* ADD new `gnupg._meta.GPGBase._set_verbose()` method, which will set
   `'basic'` as the default `--debug-level` for GnuPG, if the user did
   something weird like specifying `verbose=True` or typoing one of the
   string levels (e.g. `verbose='guruu'`).
2014-09-26 02:36:12 +00:00
Isis Lovecruft 6e228c3ef0
Move logic for sanity check and getting binary version to new method.
* CHANGE behaviour so that `gnupg.GPG.binary_version` is set in
   `gnupg._meta.GPGBase.__init__()`, instead of `gnupg.GPG.__init__()`.

 * ADD new `gnupg._meta.GPGBase._check_sane_and_get_gpg_version()`
   method, and move logic for doing a sanity check on the binary and
   getting the binary's version, which was previously in
   `gnupg.GPG.__init__()`, into this new method.

 * ADD an additional field for the `binary_version` to the logger call
   which displays initialisation settings when `gnupg.GPG.__init__()`
   is run.
2014-09-26 02:29:59 +00:00
Isis Lovecruft 5ad99acd7c
Despite what GnuPG says it expects, it actually expects `--debug-level=`.
* FIXES Issue #44:
   https://github.com/isislovecruft/python-gnupg/issues/44
2014-09-24 22:12:20 +00:00
Isis Lovecruft d5fe2d7cc4
GnuPG's `--debug-level` ints are only required to be ≥ 1.
They aren't required to be ≤ 9, as the previous check in
`gnupg._meta.GPGBase._make_args()` ensured. That is, calling GnuPG from
the commandline, doing:

  $ gpg --debug-level=100000 …

is valid, so we should also accept 10000 (even though everything > 8
means the same debug level anyway).
2014-09-24 22:07:42 +00:00
Isis Lovecruft 728b5c8ec9
Merge remote-tracking branch 'kalikaneko/feature/expand-homedir' into develop 2014-09-24 19:49:34 +00:00
Kali Kaneko bde27abcf2 expand ~ in homedir 2014-09-09 16:44:05 -05:00
Isis Lovecruft 137d3ac5c5
Fix encrypting to filenames and/or file-like objects.
* FIXES Issue#24, which prevented python-gnupg from encrypting to a
   filename given as a string to the `output` parameter of
   `gnupg.GPGMeta._encrypt()`.

 * THANKS TO by Bill Buddington of SecureDrop and Yan Zhu of the
   Electronic Frontier Foundation (EFF) for finding and reporting the
   bug. The ticket for this bug can be viewed at:
   https://github.com/isislovecruft/python-gnupg/issues/24
2014-08-02 03:33:55 +00:00
kali 36c701b08f do not expand shell on subprocess 2014-08-01 17:37:11 -05:00
Isis Lovecruft ebd93db8c2
Merge remote-tracking branch 'zigg/fix/py3k-tests' into develop 2014-06-04 20:30:44 +00:00
Thomas Tanner 1fd400b5d3 more py2.6 fixes 2014-04-23 14:49:24 +02:00
Matt Behrens 3be2697a1b WIP fixing serveral Python 3 tests for #16 2014-03-30 19:53:45 -04:00
Matt Behrens 929fad0a1a prune unused exceptions imports for Python 3 2014-03-26 22:33:03 -04:00
Isis Lovecruft 4f2dc555a5
Cleanup Sphinx directives in _meta.py. 2013-12-03 22:25:16 +00:00
Isis Lovecruft f38caae84d
Remove duplicate headings from module docstrings. 2013-12-03 22:21:36 +00:00
Isis Lovecruft e9b422ec58
Merge remote-tracking branch 'kalikaneko/bug/fix-sphinx-build' into develop 2013-12-03 13:52:23 +00:00
Isis Lovecruft b1bc36e718
Merge remote-tracking branch 'drebs/bug/fix-os.getresuid-not-supported-on-os-x' into develop 2013-12-02 23:30:02 +00:00
Isis Lovecruft 15f83fe508
Fix GPGBase._homedir_setting docstring parameter name. 2013-12-02 07:45:59 +00:00
drebs e6944488fb Replace os.getresuid() so it works on Mac OS X. 2013-10-14 14:35:01 -03:00
Kali Kaneko 15caea75b3 fix sphinx errors&warnings; some pep8 2013-10-14 01:24:17 -03:00
Kali Kaneko a115eec9ff workaround for sphinx assertion error
We were hitting sphinx bug documented at
https://bitbucket.org/birkenfeld/sphinx/issue/1160

This workaround makes those assertion error dissapear and
sphinx to finish happily.
2013-10-14 01:24:10 -03:00
Isis Lovecruft 86d02879a9
Merge remote-tracking branch 'garrettr/fix-verbose-True' into develop 2013-10-08 13:51:17 +00:00
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
Garrett Robinson faeef9c25a special case verbose=True to avoid passing invalid options to gpg --debug-level 2013-09-07 13:25:09 -07: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