Commit Graph

1667 Commits

Author SHA1 Message Date
Justus Winter
11314f0db6 python: Share generated methods between objects.
* lang/python/pyme/util.py (GpgmeWrapper.__getattr__): Monkey-patch
the class.
* lang/python/tests/t-wrapper.py: Demonstrate the sharing.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 18:29:04 +02:00
Justus Winter
c5d118b2a7 python: Raise exceptions on write errors.
* lang/python/pyme/core.py (Data.write): Handle errors.
* lang/python/pyme/errors.py (GPGMEError.fromSyserror): New function.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 18:01:24 +02:00
Justus Winter
f7094d8358 python: Fix writing to data buffers.
* lang/python/gpgme.i: Add typemap for buffers.
* lang/python/pyme/core.py (Data.write): Fix function.
* lang/python/tests/Makefile.am: Add new test.
* lang/python/tests/t-data.py: New file.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 17:59:21 +02:00
Justus Winter
e64bffe030 python: Add a test suite.
* configure.ac: Add new Makefile.
* lang/python/Makefile.am: Add subdirectory.
* lang/python/tests/Makefile.am: New file.
* lang/python/tests/t-wrapper.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 15:37:00 +02:00
Justus Winter
ed0ce84fbd python: Cache generated wrapper functions.
* lang/python/util.py (GpgmeWrap.__getattr__): Cache generated wrapper
functions.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 14:57:42 +02:00
Justus Winter
e3d3d366bd python: Fix function invocation.
* lang/python/pyme/core.py (Data.new_from_fd): Fix function
invocation.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 12:59:05 +02:00
Justus Winter
af9371eb63 python: Fix name of exception, make slot methods explicit.
* lang/python/pyme/util.py (GpgmeWrapper._getctype): Fix exception,
add docstring.
(GpgmeWrapper._getnameprepend): New function.
(GpgmeWrapper._errorcheck): Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 12:59:05 +02:00
Justus Winter
ce5121ad53 python: Handle interpreter shutdown.
* lang/python/pyme/core.py: Avoid races at interpreter shutdown.  This
silences the most annoying occurrences, however this problem also
affects the SWIG generated code, which might indicate that the real
problem is somewhere else.  If so, this change can be easily reverted.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 11:53:43 +02:00
Justus Winter
c89d3a71ad python: Make test case more robust.
* lang/python/examples/t-edit.py: Check if key is found.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 11:51:21 +02:00
Justus Winter
d60deb8a12 python: Fix type translation.
* lang/python/gpgme.i: Adjust to Python3's string type being
'Unicode', not 'bytes'.  Fix type checking.
* lang/python/core.py (Data.write): Add docstring mentioning the
expected type of parameter 'buffer'.
(Data.read): Adjust read loop.  Also, use a saner chunk size, and join
all chunks at the end instead of adding them.
* lang/python/examples/simple.py: Adjust example.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-12 11:49:17 +02:00
Justus Winter
bbeee5e1a0 python: Fix simple example.
* lang/python/examples/simple.py: Flush stdout, encode name as
UTF-8 before passing it to GPGME.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-11 13:51:40 +02:00
Justus Winter
a29babd07c python: Integrate into the build system.
* configure.ac: Make Python bindings configurable, add new Makefile.
* lang/python/Makefile.am: New file.
* lang/python/setup.py: Integrate into the build system.
* m4/ax_pkg_swig.m4: New file from the autoconf archive.
* m4/m4_ax_swig_python.m4: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-11 13:33:05 +02:00
Justus Winter
11392a80d9 python: PEP8 fixes.
Cherry picked from 0267c151.

Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-10 14:45:44 +02:00
Justus Winter
aade53a12b python: Delete trailing whitespace.
--
Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-10 13:30:30 +02:00
Justus Winter
000dbb5b9a python: Drop Debian packaging.
--
Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-10 13:21:34 +02:00
Justus Winter
f4ba16b31e python: Rename bindings.
--
Signed-off-by: Justus Winter <justus@gnupg.org>
2016-05-10 13:19:26 +02:00
Justus Winter
f531608539 Merge branch 'master' into justus/pyme3 2016-05-10 13:03:34 +02:00
Werner Koch
fc38c15136
Allow cc to detect missing cases in a switch.
* src/delete.c (delete_status_handler): Remove default case from a
switch so that cc can check the use of all enum values.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-10 10:27:54 +02:00
Werner Koch
e79199468a
Fix possible _SC_OPEN_MAX max problem on AIX.
* src/posix-io.c [HAVE_STDINT_H]: Include stdint.h.
(get_max_fds): Limit returned value for too high values.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-01-15 16:16:38 +01:00
Werner Koch
83415dffae
w32: Avoid conflict with Mingw-w64 version 4.0.4-1
* src/w32-util.c (mkstemp): Rename to my_mkstemp.  Change caller.
--

For some reason the linker seems to use the mkstemp now provided by
mingw instead of our static symbol.  Strange.

Reported-by: Andrej Kacian <andrej@kacian.sk>
Signed-off-by: Werner Koch <wk@gnupg.org>
2015-12-09 11:39:26 +01:00
Daiki Ueno
67d7f7a938
Return on user cancellation of delete operation
* src/delete.c (delete_status_handler): Return on ERROR status, if the
error location is set to "delete_key.secret" and the code is either
CANCELED or FULLY_CANCELED, which indicates a situation that the user
selected "No" on the confirmation dialog.
2015-12-04 16:35:37 +01:00
Daiki Ueno
3b6e9a3d0a
doc: Fix minor errors
* doc/gpgme.texi: Fix errors and typos in the cancellation and
gpgme_import_result_t documentation.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
2015-12-04 16:25:01 +01:00
Justus Winter
8c61cbfb8f Fix typos found by codespell.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2015-12-02 11:28:07 +01:00
Ben Kibbey
dfa79f9300 Make use of user passphrase handler during passwd.
* src/passwd.c (passwd_start): set engine passphrase command handler.

--
This allows for inquiring a passphrase when changing a passphrase rather
than requiring a pinentry.
2015-10-29 18:05:10 -04:00
Werner Koch
bb2d11c1ee
w32: Add extra diagnostic about possible missing gpgme-w32spawn.exe.
* src/w32-io.c (_gpgme_io_spawn): Add a new diagnostic.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-10-28 16:28:48 +01:00
Werner Koch
a82e9b182f
w32: Improve locating gpgconf on 64 bit systems.
* src/w32-util.c (find_program_at_standard_place): Fallback to
CSIDL_PROGRAM_FILESX86.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-10-28 16:28:48 +01:00
Werner Koch
bb600aa8fd
w32: Add new global flag "w32-inst-dir".
* src/gpgme.c (gpgme_set_global_flag): Add flag "w32-inst-dir";
* src/posix-util.c (_gpgme_set_override_inst_dir): New stub.
* src/w32-util.c (override_inst_dir): New var.
(_gpgme_get_inst_dir): Return this var is set.
(_gpgme_set_override_inst_dir): New.
--

See
https://lists.gnupg.org/pipermail/gnupg-devel/2015-September/030267.html
for background.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-10-28 16:28:48 +01:00
NIIBE Yutaka
0d9d0a6b5b cleanup: Fix type mismatch around gpgme_error_t.
* src/data-compat.c (gpgme_error_to_errno): Use gpg_err_code
to get error code from gpgme_error_t.
* src/gpgme.c (gpgme_new): Don't use gpgme_error.
2015-10-16 09:51:42 +09:00
Werner Koch
f0ccce855b
gpgme-tool: Switch to argparse.c for option parsing.
* src/argparse.c, src/argparse.h: New. Taken from current gnupg.
* src/Makefile.am (gpgme_tool_SOURCES): New.
* src/gpgme-tool.c: Remove all argp.h stuff.
(my_strusage): New.
(main): Change to use argparse.
--

As a GnuPG related tool the user should get the same experience in
option parsing as with gpg et al.  Thus we use the same parser.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-31 20:34:00 +02:00
Werner Koch
c4b6b35bfa
Add gpgme_pubkey_algo_string
* src/gpgme.h.in (GPGME_PK_EDDSA): New.
(gpgme_pubkey_algo_string): New.
* src/conversion.c (_gpgme_map_pk_algo): Add new algo.
* src/gpgme.c (gpgme_pubkey_algo_string): New.
(gpgme_pubkey_algo_name): Reformat.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-30 19:04:44 +02:00
Werner Koch
c8e7870281
Post release updates
--
2015-08-26 10:16:39 +02:00
Werner Koch
107bff70ed
Release 1.6.0
* configure.ac: Set LT version to C25/A14/R0.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-26 10:06:00 +02:00
Werner Koch
c4f4b5c0a6
Make use of GPGRT macros is available.
* src/gpgme.h.in (_GPGME_INLINE): Define using GPGRT_INLINE if
possible.  Fix problem with -Wundef by adding an extra "defined()".
(_GPGME_GCC_VERSION): Define using GPGRT_ macro if possible.
2015-08-26 09:16:36 +02:00
Werner Koch
3f53d3d5d9
Avoid -Wundef warnings if gpgme.h is used by g++.
* src/gpgme.h.in (_GPGME_INLINE): Move definition into the
extern-C-scope.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 21:04:15 +02:00
Werner Koch
ff91e699f7
Add configure option --enable-build-timestamp.
* configure.ac (BUILD_TIMESTAMP): Set to "<none>" by default.
--

This is based on
libgpg-error commit d620005fd1a655d591fccb44639e22ea445e4554
but changed to be disbaled by default.  Check there for some
background.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 20:40:06 +02:00
Daiki Ueno
028a0ef333
Relax ttyname_r error checks
* src/engine-assuan.c (llass_new): Don't treat ttyname_r error as
fatal.
* src/engine-g13.c (g13_new): Likewise.
* src/engine-gpg.c (gpg_new): Likewise.
* src/engine-gpgsm.c (gpgsm_new): Likewise.
* src/engine-uiserver.c (uiserver_new): Likewise.

--
Even though isatty() returns 1, ttyname_r() may fail in many ways, e.g.,
when /dev/pts is not accessible under chroot.  Since all our uses of
ttyname_r() require that the function works, we can treat the failure as
if isatty() fails.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
2015-08-25 19:11:30 +02:00
Werner Koch
97f1f3e883
Cleanup layout of gpgme.h
* src/gpgme.h.in: Reorder prototypes.  Chnage some comments.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 18:10:14 +02:00
Werner Koch
8ddc5801ad
Improve error return by checking the FAILURE status.
* src/gpgme.h.in (GPGME_STATUS_FAILURE): New.
* src/status-table.c (FAILURE): New.
* src/op-support.c (_gpgme_parse_failure): New.
* src/passphrase.c (_gpgme_passphrase_status_handler): Forward FAILURE
status line to the status callback.

* src/decrypt.c (op_data_t): Add field failure_code.
(_gpgme_decrypt_status_handler): Parse that code and act upon it on EOF.
* src/encrypt.c (op_data_t): Add field failure_code.
(_gpgme_encrypt_status_handler): Parse that code and act upon it on EOF.
* src/genkey.c (op_data_t): Add field failure_code.
(genkey_status_handler): Parse that code and act upon it on EOF.
* src/passwd.c (op_data_t): Add field failure_code.
(passwd_status_handler): Parse that code and act upon it on EOF.
* src/sign.c (op_data_t): Add field failure_code.
(_gpgme_sign_status_handler): Parse that code and act upon it on EOF.
* src/verify.c (op_data_t): Add field failure_code.
(_gpgme_verify_status_handler): Parse that code and act upon it on EOF.

--

This requires GnuPG 2.1.8 to actually make a difference.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 13:23:51 +02:00
Werner Koch
208f029746
tests: Build test programs in tests/ without wrappers.
--
2015-08-25 10:37:02 +02:00
Werner Koch
491fcd91b8
tests: Allow using run-sign to test loopback pinentry problems.
* tests/run-sign.c: Add options --status and --loopback.
2015-08-25 09:05:33 +02:00
Werner Koch
ad46f4f655
Call status_cb for an ERROR status seen in the passphrase handler.
* src/passphrase.c (_gpgme_passphrase_status_handler): Call status_cb.
--

Frankly, we should have a more generic way of feeding the status_cb
handler than our current ad-hoc method.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 21:17:21 +02:00
Werner Koch
a7dbab23ea
w32: Look for gpgconf in the new GnuPG 2.1 install dir.
* src/w32-util.c (_gpgme_get_gpgconf_path): Try another location of
gpgconf.exe.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 19:59:43 +02:00
Werner Koch
06d6fd8ca0
w32: Expect gpgme-w32spawn.exe only in the gpgme installation dir.
* src/w32-util.c (find_program_at_standard_place): Remove.
(_gpgme_get_gpg_path): Make the search order more explicit.
(_gpgme_get_gpgconf_path): Ditto.
(_gpgme_get_w32spawn_path): Search only in the inst_dir.
--

This tries to avoid possible unclear bug reports by removing the
fallback to the current gpg4win installation directory for the gpgme
helper.  It is expected that users of gpgme installing their own gpgme
version also install the matching helper.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 16:34:29 +02:00
Werner Koch
df098d6a43
w32: Print the installation directory in debug mode.
* src/debug.c (debug_init) [W32]: Show libgpgme installation dir.
--

I expect that gpgme will be distributed by applications and thus it
will be helpful to see in the debug log which gpgme is actually used.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 15:03:20 +02:00
Werner Koch
2b632bbb78
Add an export secret key feature.
* src/gpgme.h.in (GPGME_EXPORT_MODE_SECRET): New.
(GPGME_EXPORT_MODE_RAW): New.
(GPGME_EXPORT_MODE_PKCS12): New.
* src/export.c (export_start, export_ext_start): Allow new flags.
* src/engine-gpg.c (export_common): Support secret key export.
* src/engine-gpgsm.c (gpgsm_export, gpgsm_export_ext): Ditto.

* src/gpgme-tool.c (cmd_export): Add options --secret, --raw,
and --pkcs12.
* tests/run-export.c (main): Likewise.
--

Note that exporting secret X.509 keys requires GnuPG 2.1.8.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 12:41:24 +02:00
Ben Kibbey
ccbaccbf2e Parse INQUIRE_MAXLEN in the passphrase callback.
* src/passphrase.c (_gpgme_passphrase_status_handler): Parse
GPGME_STATUS_INQUIRE_MAXLEN.
* src/passphrase.c (_gpgme_passphrase_command_handler): Send the
INQUIRE_MAXLEN status message.

--
Fixes passing this status message along when decrypting symmetric data
from gpg.
2015-08-16 12:54:50 -04:00
Ben Kibbey
70b3e5964e Fix gpgme_{get,set}_status_cb to match documentation.
* doc/gpgme.texi: Minor fixes.
* src/gpgme.c (gpgme_get_status_cb): Set return variables to NULL and
check for a valid ctx pointer.
2015-08-15 18:19:27 -04:00
Ben Kibbey
6dd24c3c61 Parse the INQUIRE_MAXLEN status message.
* src/gpgme.h.in: (gpgme_status_code_t): Add INQUIRE_MAXLEN.
* src/status-table.c (status_table_s): Ditto.
* src/genkey.c (genkey_status_handler): Parse INQUIRE_MAXLEN.
* src/decrypt.c (_gpgme_decrypt_status_handler): Ditto.
* src/sign.c (_gpgme_sign_status_handler): Ditto.

This status message informs the client of the maximum length of an
inquired line. It is sent from gpg and forwarded to the client via
gpgme_status_cb_t.
2015-08-15 18:19:27 -04:00
Ben Kibbey
4fadcf06ec Add gpgme_set/get_status_cb().
* src/gpgme.h.in (gpgme_set_status_cb): New.
(gpgme_get_status_cb): New.
(gpgme_status_cb_t): New.
* src/gpgme.c (gpgme_set_status_cb): New.
(gpgme_get_status_cb): New.
* src/context.h (status_cb): New.
(status_cb_value): New.
* src/gpgme.def: Export new symbols.
* src/libgpgme.vers: Ditto.
* doc/gpgme.texi: Document these new functions.

--
This callback function is used to forward status messages from gpg back
to the client.
2015-08-15 18:19:27 -04:00
Ben Kibbey
2b6ae3dadf Make use of user passphrase handler during genkey.
* src/genkey.c (genkey_start): set engine passphrase command handler.

--
This allows for inquiring a new passphrase during key generation rather
than requiring a pinentry. Needs a patch to gnupg to make use of
--command-fd with --gen-key.
2015-08-15 18:17:06 -04:00