Commit Graph

124 Commits (5d03c3c5eb6289976553777d5843ffdfa66f646e)

Author SHA1 Message Date
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
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
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
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
Ruben Pollan d1025ae524 Fix list_sigs to return the list of signatures 2014-10-27 12:21:55 -06: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 7dc3b66de4
Make GnuPG>2.0.x only methods always public.
They are only effective if the binary is GnuPG>=2.0.x anyway, and the
extra code to change the method names depending on the underlying
binary will cause clutter for anyone using python-gnupg.

This change is backwards compatible with python-gnupg<=1.3.1, since the
private methods (e.g. `gnupg.GPG._create_trusttb`) are kept intact.
2014-09-26 02:23:37 +00:00
Isis Lovecruft 69cc991938
Fix bug in determining behaviours for those using GnuPG2 binaries.
This bug caused some extra behaviours which should only be invoked if
the user is using a gpg2 binary. It was caused by checking:

    if _util._is_gpg2:

which is always true, since `_util._is_gpg2` is a function which isn't
being called in this case, i.e.:

    >>> def foo(): return False
    >>> bool(foo)
    True

So instead this should be changed to actually call `_util._is_gpg2()`,
by using `gnupg.GPG.is_gpg2()` which will automatically pass in the
detected binary version number.
2014-09-24 22:13:25 +00:00
drebs a26cc9c0f4 Fix verify_file() to really treat signed data as file descriptor. 2014-08-27 12:29:14 -03:00
Isis Lovecruft ebd93db8c2
Merge remote-tracking branch 'zigg/fix/py3k-tests' into develop 2014-06-04 20:30:44 +00:00
Isis Lovecruft a508005d77
Merge remote-tracking branch 'ttanner/fix/default_key' into develop 2014-06-04 19:17:10 +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 56fab92b48
Fix issue with detached sig verification not writing verify output.
In the method `gnupg.GPG.verify_file()`, the `writer` was improperly
initialised: `_util._threaded_copy_data` was being given a filename when
it expects an open `file` object which it can read() from. Additionally,
the `writer` parameter was missing from the call to
`gnupg.GPG._collect_output()`, so even if it had been properly
initialised, the output would not have been written to the stdin of the
thread GnuPG was being called within.
2013-12-04 10:10:18 +00:00
Isis Lovecruft 641f503f4a
Cleanup docstrings in gnupg.py. 2013-12-03 22:35:17 +00:00
Isis Lovecruft e9b422ec58
Merge remote-tracking branch 'kalikaneko/bug/fix-sphinx-build' into develop 2013-12-03 13:52:23 +00:00
Thomas Tanner fa8216e1f7 bugfix: find default_key in sign 2013-11-12 12:14:56 +01:00
drebs 2f60144ad9 Fix validation of --verify argument using detached sig. 2013-10-24 18:05:18 -02:00
drebs 678d36ea62 Fix path creation. 2013-10-14 17:09:09 -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 c26f4d57ac
Add the import/export ownertrust methods if GnuPG>=2.x is detected.
We should only add these methods (or rather, link them to their corresponding
functions in the gnupg._trust module) if using GnuPG>=2.x.

 * ADD --export-ownertrust and --import-ownertrust functionality.
2013-10-08 10:13:41 +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
Isis Lovecruft 1d22ce5adb
Merge remote-tracking branch 'mmn/file_and_io_handling_diff' into develop
* ADD patch by Mikael Nordfeldth to file python3 syntax compatibility due to
   the 'file' builtin being removed.
       isinstance(foo, file) → hasattr(foo, 'read'), or,
       file = _io._IOBase
 * CLOSES issue #13.
   https://github.com/isislovecruft/python-gnupg/pull/13
2013-07-29 20:57:25 +00:00
Mikael Nordfeldth 1bdf0290ab File and IO handling in Py3 is different than Py2
Instead of checking whether data isinstance of 'file', then we check that
it is file-like _enough_ to be treated as a file (i.e. it hasattr 'read').
2013-07-28 18:35:16 +02:00
Isis Lovecruft 1e867d6e11
If using GnuPG v1.x, use {'Key-Type': 'RSA'} in GPG.gen_key_input().
* CHANGE default key type to RSA for older GnuPG versions, since they seems
   to not understand using a 'default' key type.
 * UPDATE docstring for GPG.gen_key_input().
2013-07-28 11:38:43 +00:00
Isis Lovecruft 6eccbe7048
Make default gen_key_input() Key-Type conditional on GnuPG version.
* ADD functions _util._match_version_string(), _util._is_gpg2(), and
   _util._is_gpg1() for determining whether to set the default Key-Type to
   'default' (for GnuPG v2.x) or to 'RSA' (for GnuPG v1.x).
 * ADD class attribute GPG.binary_version, which stores the GnuPG executable's
   version string, which should be in the form x.x.x, where 'x' is an integer.
2013-07-28 11:28:49 +00:00
Isis Lovecruft 420d2b590d
Remove TODO item for keyring separation in GPG.gen_key_input() and GPG.gen_key(). 2013-07-27 19:42:37 +00: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 ef022f977f Fix list_packets() call in utilities. 2013-07-09 08:35:42 +00:00
drebs 2832df8be1 Add missing param to utilities methods. 2013-07-09 08:35:42 +00:00
drebs 9db97dd184 Fix sign() and encrypt() docstrings. 2013-07-09 08:35:42 +00:00
drebs 171d3afa67 Fix delete_keys command line options. 2013-07-09 08:35:42 +00:00
Isis Lovecruft 94e591f6dc
Update docstrings for v1.1.6 Sphinx generation in gnupg.py and _parsers.py. 2013-07-03 10:24:11 +00:00
Isis Lovecruft f11ea6901c
Set gpg.temp_[key|sec]ring to None after setting key.[key|sec]ring.
* Change the returned _parsers.GenKey from gnupg.GPG.gen_key() to store the
   location of the renamed temporary keyrings as attributes. This way, one can
   do something like:

   >>> key = gpg.gen_key(key_input)
   >>> key.keyring
   './generated-keys/328A5C6C1B2F0891125ECBE4624276B5A2296478.pubring.gpg'
2013-06-28 07:09:35 +00:00
Isis Lovecruft 8232f14f2a
Remove commented out code from GPG.gen_key() for import after generation.
* Generated keys in separate keyring would not be available after switching
   back to the normal keyrings (not the ones set up for key generation), so at
   first in the unittests I imported them back into the main keyrings… this,
   however, is would be stupid, as in nullifies half the reasons for using
   separate keyrings in the first place, thus the code was commented out. Now
   that the temporary keyrings are placed in the gnupg.GPG._generated_keys
   directory, it would be nice to eventually either extend GPG.import_keys()
   or add a new helper function for doing:

       $ gpg --no-default-keyring --keyring pubring.gpg \
            --keyring ./generated-keys/<some_fingerprint>.gpg
2013-06-28 06:44:52 +00:00
Isis Lovecruft 9008faa0db
Fix a misnamed variable in gnupg.py; self._key_dir→self._keys_dir 2013-06-28 06:42:42 +00:00
Isis Lovecruft 1afcda8364
Fix a misnamed process thread variable. 2013-06-09 08:25:34 +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
Isis Lovecruft c97b51fec5
Add versioneer and restructure the repo into a src/ dir. 2013-05-12 09:32:46 +00:00
Isis Lovecruft cc7beb7185
Rewrite GPG.decrypt_file(). 2013-05-11 18:26:14 +00:00
Isis Lovecruft cfd7b38242
Add option to delete subkeys with GPG.delete_keys().
* TODO this needs unittests.
2013-05-11 18:25:17 +00:00