Commit Graph

338 Commits (fix/99-recv-keys-network-test)

Author SHA1 Message Date
Isis Lovecruft af403fe144
Move 'test_recv_keys_default' to a new test group which doesn't run.
* FIXES #99 temporarily.
2015-03-13 02:25:10 +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 2c57c0f6d0
Handle [GOOD|BAD|MISSING]_PASSPHRASE statuses in _parsers.ListPackets.
* FIXES #100.
2015-03-11 03:25:55 +00:00
Isis Lovecruft eb205774fb
Add support for PINENTRY_LAUNCHED status message.
* FIXES #98.
2015-03-09 08:50:52 +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 d31d0cf131
Handle MISSING_PASSPHRASE in _parsers.Sign.
* FIXES #91.
2015-03-09 08:12:41 +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 55b586fd18
Merge remote-tracking branch '6si/feature/allow_output_flag' into develop 2015-03-09 07:48:34 +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 572429eed9
Merge branch 'fix/89-fix-encrypting-streams' into develop 2015-03-09 07:19:36 +00:00
Isis Lovecruft ceb1c2fbbd
Add _STREAMLIKE_TYPES for determining stream-likeness in _is_stream().
* FIXES Python3 problems with various StringIO imports commit 8c261eb
   from fix for #89 in PR #92.
2015-03-09 07:01:15 +00:00
Isis Lovecruft d66b23b896
Add support for running on PyPy. 2015-02-22 22:57:59 +00:00
Garrett Robinson 6c15f25ee5 Unit test for encrypting file-like objects 2015-01-20 11:18:55 -08:00
Garrett Robinson 8c261eba30 Expand set of classes recognized by `_util._is_stream`
Adds additional commonly used stream classes from the standard library
to `_util._is_stream`. This means these classes can be used successfully
wherever `_is_stream` is used to decide whether or not to encode data
throughout the codebase, including in `_encrypt`.
2015-01-20 09:22:54 -08:00
Garrett Robinson f8ccdc5028 Fix `GPG.encrypt` for file-like objects
`GPG.encrypt_file` was refactored into `GPG.encrypt` in 295d98f, which
broke the functionality of `GPG.encrypt_file` for encrypting file-like
stream objects such as StringIO, BytesIO, etc.

The main difference between `GPG.encrypt_file` and `GPG.encrypt` is that
`GPG.encrypt` first converts its `data` argument into a binary stream
via `_make_binary_stream`. This is unnecessary when the argument is
already a stream, as was often the case in calls to `GPG.encrypt_file`.
Additionally, `_make_binary_stream` typically fails when it attempts
to encode a stream object, which means it is no longer possible to
achieve the functionality of `GPG.encrypt_file` with `GPG.encrypt` after
the refactor.

This commit only converts `data` to a binary stream if it is not already
a stream, re-using `_util._is_stream` to make that determination.
2015-01-17 16:09:39 -08:00
Viral Bajaria 8a7699236c add output as a valid option 2015-01-06 11:13:46 -08:00
Isis Lovecruft 81b2d9d9c2
Change ListPackets.key to be backwards compatible.
This also adds a new ``ListPackets.encrypted_to`` list, which contains
all the keyids which a message was encrypted to. ``ListPackets.key`` is
just the first one we discovered that it was encrypted to, for backwards
compatibility.

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

 * CHANGES the additions made in commit f70a7dc4f0 by @tomgalloway in
   PR#70 to be backwards compatible.
   f70a7dc4f0
   https://github.com/isislovecruft/python-gnupg/pull/77
2014-11-27 02:35:52 +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 906b1a7142
Fix class attribute side effects between instances of ImportResult.
This fixes an issue reported by @adulau on Github where importing KeyA
and asking for the ``ImportResult.fingerprints`` would list KeyA's
fingerprints, and then importing KeyB and asking for the
``ImportResult.fingerprints`` would list both KeyA and KeyB's
fingerprints.

This was caused by a side effect resulting from the
``ImportResult.fingerprints`` being a class-level attribute, which gets
modified by the first call to ``gnupg.GPG.import_key()``, causing later
instances of ``ImportResult`` to retain the side effect. This commit
causes the ``ImportResult`` class to be indempotent under sequential
composition calls to ``gnupg.GPG.import_keys()``, ultimately resulting
in listing, upon each key import attempt, only the fingerprints of the
keys which were listed *that* time.

 * FIXES Issue #81
   https://github.com/isislovecruft/python-gnupg/issues/81
2014-11-27 00:51:55 +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 cc959c755d
Merge remote-tracking branch 'meskio/fix_list_sigs' into develop 2014-11-26 23:38:28 +00:00
Isis Lovecruft f3515c44d7
Add ability to parse NOTIFICATION_* statuses in Verify.
* FIXES Issue #85:
   https://github.com/isislovecruft/python-gnupg/issues/85
2014-11-20 05:51:20 +00:00
Isis Lovecruft 5aaf1df5d1
Add ability to handle SIG_SUBPACKET status in Verify.
* FIXES Issue #83:
   https://github.com/isislovecruft/python-gnupg/issues/83
2014-11-19 22:50:30 +00:00
Isis Lovecruft 245cf73baf
Change versioneer parameters in gnupg/_version.py to match setup.py.
* FIXES (hopefully) Issue #80:
   https://github.com/isislovecruft/python-gnupg/issues/80
2014-11-19 21:44:53 +00:00
Isis Lovecruft 8e5b3256fa
Merge remote-tracking branch 'charles-dyfis-net/trustdb_repair_arg_fix' into develop 2014-11-19 21:29:31 +00:00
Isis Lovecruft 30c8c05f84
Merge remote-tracking branch 'charles-dyfis-net/first_usable_binary' into develop
Conflicts:
	gnupg/_util.py
2014-11-19 21:22:21 +00:00
Isis Lovecruft f9d00794ee
Merge remote-tracking branch 'charles-dyfis-net/progress_during_verify' into develop 2014-11-19 19:52:25 +00:00
Isis Lovecruft 99e597f196
Merge remote-tracking branch 'ttanner/binary-symlink' into develop 2014-11-19 19:30:29 +00:00
Isis Lovecruft 1104908ef9
Don't expect a $HOME directory to be set.
* FIXES Issue #74:
   https://github.com/isislovecruft/python-gnupg/issues/74
2014-11-19 18:31:14 +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
Isis Lovecruft fecf92c0ac
Remove expectation for UnicodeDecodeError in a unittest.
It seems that more modern versions of Python (e.g. 2.7.8), doing:

    from __future__ import print_function
    print("SIG=%s" % sig)

with some binary data doesn't actually produce a UnicodeDecodeError,
which means that Python2 is slowly getting less retarded. :D

On the downside, we probably shouldn't have been testing for things
which are Python2.x mis-design issues (and not really our fault, nor a
bug in python-gnupg) anyway.
2014-11-19 03:46:44 +00:00
Tom Galloway 350027b18c Add parameter description 2014-11-10 13:07:27 +00:00
Tom Galloway f70a7dc4f0 Update to allow multiple keys to be shown on list_packets.
Also updated test to ensure only expected keyid has been hidden.
2014-11-05 12:37: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
Ruben Pollan d1025ae524 Fix list_sigs to return the list of signatures 2014-10-27 12:21:55 -06:00
Charles Duffy 98e0fc7cf5 properly pass argument during trustdb repair 2014-10-02 04:56:56 -05:00
Charles Duffy 1b8c305829 Continue search for a usable binary if entries are symlinks
Existing code gives up searching for a GnuPG executable (returning None --
contrary to the docstring indicating that a RuntimeError will be thrown in all
cases where no binary can be found) if the first item found is a symlink or is
not accessed via an absolute path.

This refactored version moves the filtering logic down into the _which helper
-- and thus continues to search past unacceptable results -- even if the first
item found is not acceptable.
2014-09-30 20:45:44 -05:00
Charles Duffy 41c388e8f7 Ignore PROGRESS messages during verify operation
Parsing such messages would change documented behavior (which specifies a
limited set of messages, not conforming with the given status codes). Ignoring
them is thus the safer change.
2014-09-30 20:28:50 -05: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 572c911b82 Merge branch 'fix/30-hidden-recipient' into develop 2014-09-27 00:38:59 +00:00
Isis Lovecruft 4da7ec92bd
Handle KEYREVOKED status message during signature verification.
If we get a VALIDSIG, but the signing key has since been revoked, we
(mostly) ignore the KEYREVOKED status message (except to append "key
revoked" to the `Verify.status` string).

 * ADD ability to handle KEYREVOKED status to `gnupg._parsers.Verify`.

 * FIXES Issue #66
   https://github.com/isislovecruft/python-gnupg/issues/66

 * THANKS TO Tom Galloway for finding this bug.
   https://github.com/tomgalloway

 * CLOSES PR#38
   https://github.com/isislovecruft/python-gnupg/pull/38
2014-09-26 03:39:36 +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