Commit Graph

58 Commits (9d8d6cce5c3be8fc2d12da6efb6eb16c7fbfac12)

Author SHA1 Message Date
Isis Lovecruft a7e772f10a
Make an open() file mode explicitly binary.
It already was binary, due to the `from codecs import open as open`,
however we should be more explicit.
2015-03-13 02:32:52 +00:00
Isis Lovecruft 657be31ae1
Change a str to a repr in a log message. 2015-03-13 02:21:18 +00:00
Isis Lovecruft 749ef6fa00
PEP8 whitespace fixes in gnupg/_meta.py. 2015-03-13 02:20:48 +00:00
Isis Lovecruft ae5cb33d63
Unset GPG.user_agent if using gpg2 binary.
* FIXES #96.
2015-03-09 08:42:50 +00:00
Thomas Tanner d3e6ae33b4 no-use-agent is obsolete for GPG2
(cherry picked from commit 19fd35c7232e42a4112c8f18686df1c0407c2d0d)
Signed-off-by: Isis Lovecruft <isis@leap.se>

 * FIXES #96.
 * CLOSES #96.
 * CLOSES #46.
2015-03-09 08:21:04 +00:00
Isis Lovecruft f3c193d8b4
Merge remote-tracking branch 'charles-dyfis-net/homedir-perm-check-skippable' into develop 2015-03-09 07:52:59 +00:00
Isis Lovecruft f858080148
Merge remote-tracking branch 'charles-dyfis-net/pass_through_good_options' into develop 2015-03-09 07:24:38 +00:00
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
Charles Duffy a1c45a6f63 Not sufficient to drop bad options; good ones need to be passed through.
This code was broken: Half of it required `options` to be a string, and the
other half required `options` to be a list (which the tests enforced, but the
constructor would silently drop for normal-path initialization).
2014-11-26 17:43:36 -06:00
Charles Duffy 77c6c3d0e5 Make homedir permissions check optional 2014-11-26 17:39:04 -06: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