5 years agoAdd global flags disable-gpgconf, gpgconf-name, and gpg-name.
Werner Koch [Mon, 6 Jan 2014 16:16:52 +0000 (17:16 +0100)]
Add global flags disable-gpgconf, gpgconf-name, and gpg-name.

* src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf",
"gpgconf-name", and "gpg-name".
* src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New.
(get_gpgconf_item): Minor debug info change.
* src/posix-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.
(walk_path): Add debug output on failure.
* src/w32-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(replace_slashes): New.
(get_basename): New.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.

* tests/t-engine-info.c (main): Add --verbose and --set-global-flag

Note that the Windows part has not been tested.

5 years agoLocate engine names only at runtime and prefer GnuPG-2.
Werner Koch [Fri, 27 Dec 2013 15:08:20 +0000 (16:08 +0100)]
Locate engine names only at runtime and prefer GnuPG-2.

(NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related
checks.  Do not check for any engine version.
(HAVE_ASSUAN): Remove AM conditional.
* src/ Remove separate component vars and always build all
engines but uiserver.
* src/dirinfo.c (WANT_GPGCONF_NAME): New.
(struct dirinfo): Add field gpgconf_name.
(_gpgme_get_default_gpgconf_name): Use WANT_GPGCONF_NAME.
(get_gpgconf_item): Set gpgconf name and adjust for _gpgme_get_*_path
now returning a malloced string.
* src/engine.c (engine_ops): Always init all engines except for
* src/posix-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path):
Remove unused functions.
(walk_path): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path ): Re-implement using
* src/w32-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove
unused functions.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Return a malloced
* src/engine-g13.c (g13_get_req_version): Use a hardwired string with
the required version.  This info belongs into this file.
* src/engine-gpg.c (gpg_get_req_version): Ditto.
* src/engine-gpgconf.c (gpgconf_get_req_version): Ditto.
* src/engine-gpgsm.c (gpgsm_get_req_version): Ditto.
* tests/t-engine-info.c: Replace now useless test by an info output.
* tests/gpg/ (GPG, GPG_AGENT): Hardwire gpg and gpg-agent.
* tests/gpgsm/ (GPGSM): Hardwire gpgsm.

Signed-off-by: Werner Koch <>
6 years agoDocument API change for GPGME_EVENT_DONE from 2009.
Werner Koch [Mon, 19 Aug 2013 18:43:19 +0000 (20:43 +0200)]
Document API change for GPGME_EVENT_DONE from 2009.

* doc/gpgme.texi (I/O Callback Interface): Fix description for the
event arg.

With commit c8e934b2 (2009-10-26) gpgme_io_event_done_data_t was
introduced to replace the use of gpg_error_t with GPGME_EVENT_DONE.
Unfortunately this was not documented.  Maybe at that time the event
code was considered internal and its use in GPA was not known.  Too

6 years agoFix possible segv in the gpgme_op_card_edit.
Werner Koch [Mon, 19 Aug 2013 18:40:10 +0000 (20:40 +0200)]
Fix possible segv in the gpgme_op_card_edit.

* src/edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): Do not
deref a NULL KEY in TRACE_BEG.

6 years agotests: Fix NULL ptr deref in gpgsm/t-verify.
Werner Koch [Mon, 19 Aug 2013 18:38:36 +0000 (20:38 +0200)]
tests: Fix NULL ptr deref in gpgsm/t-verify.

* tests/gpgsm/t-verify.c (check_result): Do not dereference a sig or
sig->fpr if NULL.

6 years agoRelease 1.4.3. gpgme-1.4.3
Werner Koch [Mon, 12 Aug 2013 12:33:49 +0000 (14:33 +0200)]
Release 1.4.3.

* Change LT version to C22/A11/R0.

6 years agoMake test suite workable with GnuPG 2.1.
Werner Koch [Mon, 12 Aug 2013 12:32:21 +0000 (14:32 +0200)]
Make test suite workable with GnuPG 2.1.

* tests/gpg/start-stop-agent: New.
* tests/gpg/initial.test: New.
* tests/gpg/final.test: New.
* tests/gpg/ (c_tests): New.
(TESTS): Move all to c_tests.  Add initial.test, final.test, and
(private_keys): New.
(EXTRA_DIST): Add new files.
(./private-keys-v1.d/gpg-sample.stamp): Copy private keys.
(all-local): Depend on gpg-sample.stamp.
* tests/gpg/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F: New.
* tests/gpg/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD: New.
* tests/gpg/76F7E2B35832976B50A27A282D9B87E44577EB66: New.
* tests/gpg/7A030357C0F253A5BBCD282FFC4E521B37558F5C: New.
* tests/gpg/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.

GnuPG 2.1 requires that the agent knows the private keys.  Thus we
need to install them.  The code should still work with GnuPG < 2.1.

To make the whole testing using a agent more robust, the way to start
the agent has also be changed.

6 years agoImprove detection of default gpg by configure.
Werner Koch [Mon, 12 Aug 2013 12:24:34 +0000 (14:24 +0200)]
Improve detection of default gpg by configure.

* Move test for gpgconf before test for gpg.
(GPG, GPGSM, G13): Use gpgconf instead of AC_PATH_PROG if possible.

This change is required so that the t-engine-info test does not
fail.  In any case, it is a good idea to use gpgconf for these test
because this is how it works at runtime.

6 years agoAdd function gpgme_data_identify.
Werner Koch [Fri, 9 Aug 2013 17:19:26 +0000 (19:19 +0200)]
Add function gpgme_data_identify.

* src/ (gpgme_data_type_t): New.
(gpgme_data_identify): New prototype.
* src/data-identify.c: New.
* src/parsetlv.c, src/parsetlv.h: New.  Take from gpa.
* src/libgpgme.vers, src/gpgme.def: Add gpgme_data_identify.
* src/gpgme-tool.c (status): Add STATUS_IDENTIFY_RESULT.
(gt_identify): New.
(cmd_identify): New.

(hlp_passwd): Move close to cmd_passwd.

It is often useful to have a way to identify the data which needs
processing.  This is such a common task that it makes sense to
implement this in gpgme to avoid diverging implementations.

6 years agoPrefer GnuPG-2 engines over GnuPG-1.
Werner Koch [Fri, 2 Aug 2013 13:25:23 +0000 (15:25 +0200)]
Prefer GnuPG-2 engines over GnuPG-1.

* src/util.h: Move some prototypes to ...
* src/sys-util.h: New.
* src/ (main_sources): Add sys-util.h.
* src/dirinfo.c: Include sys-util.h.
(dirinfo): Add corresponding fields.
(parse_output): Add arg COMPONENTS and set new fields.
(read_gpgconf_dirs): Add arg components and act upon it.
(get_gpgconf_item): Call read_gpgconf_dirs two times.  Add debug
(_gpgme_get_default_gpg_name): New.
(_gpgme_get_default_gpgsm_name): New.
(_gpgme_get_default_g13_name): New.
(_gpgme_get_default_gpgconf_name): New.
(_gpgme_get_default_uisrv_socket): New.
* src/engine-gpg.c, src/engine-g13.c, src/engine-gpgconf.c
* src/engine-gpgsm.c, src/engine-uiserver.c: Change to use
_gpgme_get_default_ instead of those from sys-util.h.
* src/posix-util.c (_gpgme_get_gpg_path): Include sys-util.h.
(_gpgme_get_uiserver_socket_path): Remove.
* src/w32-util.c (_gpgme_get_gpg_path): Include sys-util.h.
(_gpgme_get_uiserver_socket_path): Remove.

The default engines names are now taken from the output of gpgconf.
If gpgconf is not installed gpg 1 is assumed and locate the same was
as gpgconf.

6 years agow32: Try to locate gpg in the gpgme installation dir.
Werner Koch [Fri, 2 Aug 2013 10:48:30 +0000 (12:48 +0200)]
w32: Try to locate gpg in the gpgme installation dir.

* src/w32-util.c (my_hmodule): New.
(wchar_to_utf8): New.
(DllMain): New.
(_gpgme_get_inst_dir): New.
(find_program_in_dir): New.
(find_program_in_inst_dir): Add arg INST_DIR.
(_gpgme_get_gpg_path): Get inst_dir before acquiring the lock.
(_gpgme_get_gpgconf_path): Ditto.
(_gpgme_get_g13_path): Ditto.
(_gpgme_get_w32spawn_path): Ditto.

6 years agodoc: Add --binary option for the OUTPUT command of an uiserver.
Werner Koch [Wed, 31 Jul 2013 15:32:02 +0000 (17:32 +0200)]
doc: Add --binary option for the OUTPUT command of an uiserver.

6 years agodoc: Fix variable name.
Werner Koch [Tue, 18 Jun 2013 08:46:04 +0000 (10:46 +0200)]
doc: Fix variable name.

GnuPG-bug-id: 1507

6 years agoAdd function gpgme_signers_count.
Werner Koch [Tue, 18 Jun 2013 08:27:46 +0000 (10:27 +0200)]
Add function gpgme_signers_count.

* src/signers.c (gpgme_signers_count): New.
* src/libgpgme.vers, src/gpgme.def: Add as external symbol.
* src/ Add prototype.

6 years agoPost release version bump.
Werner Koch [Tue, 28 May 2013 10:05:43 +0000 (12:05 +0200)]
Post release version bump.


6 years agoRelease 1.4.2. gpgme-1.4.2
Werner Koch [Tue, 28 May 2013 09:05:43 +0000 (11:05 +0200)]
Release 1.4.2.

* Set LT version to C21/A10/R0.

6 years agoAdd convenience macro GPGME_PROTOCOL_OPENPGP.
Werner Koch [Tue, 28 May 2013 08:53:43 +0000 (10:53 +0200)]
Add convenience macro GPGME_PROTOCOL_OPENPGP.


6 years agodoc: rename gpgme_sub_key_t to gpgme_subkey_t to match gpgme.h
Hans-Christoph Steiner [Fri, 24 May 2013 15:51:16 +0000 (11:51 -0400)]
doc: rename gpgme_sub_key_t to gpgme_subkey_t to match gpgme.h


6 years agow32: Fix installing of .def file.
Werner Koch [Thu, 18 Apr 2013 12:40:43 +0000 (14:40 +0200)]
w32: Fix installing of .def file.

* src/ (install-def-file): Create libdir first.

6 years agoFix libtool 2.4.2 to correctly detect .def files.
Werner Koch [Thu, 18 Apr 2013 12:40:43 +0000 (14:40 +0200)]
Fix libtool 2.4.2 to correctly detect .def files.

* build-aux/ (sed_uncomment_deffile): New.
(orig_export_symbols): Uncomment def file before testing for EXPORTS.
* m4/libtool.m4: Do the same for the generated code.

The old code was not correct in that it only looked at the first line
and puts an EXPORTS keyword in front if missing.  Binutils 2.22
accepted a duplicated EXPORTS keyword but at least 2.23.2 is more
stringent and bails out without this fix.

There is no need to send this upstream.  Upstream's git master has a
lot of changes including a similar fix for this problems.  There are
no signs that a libtool 2.4.3 will be released to fix this problem and
thus we need to stick to our copy of 2.4.2 along with this patch.

Signed-off-by: Werner Koch <>
6 years agoSupport --no-encrypt-to also with gpgme_op_encrypt_sign.
Werner Koch [Wed, 22 May 2013 14:35:12 +0000 (15:35 +0100)]
Support --no-encrypt-to also with gpgme_op_encrypt_sign.

* src/engine-gpg.c (gpg_encrypt_sign): Support the

6 years agoAllow symmetric encryption with gpgme_op_encrypt_sign.
Werner Koch [Wed, 22 May 2013 14:30:12 +0000 (15:30 +0100)]
Allow symmetric encryption with gpgme_op_encrypt_sign.

* src/encrypt-sign.c (encrypt_sym_status_handler): New.
(encrypt_sign_start): Handle recp == NULL case.
* src/engine-gpg.c (gpg_encrypt_sign): Implement symmetric encryption.
* tests/gpg/t-encrypt-sign.c (main): Add a test case for this.

Co-authored-by: Kyle L. Huff <>
GnuPG-bug-id: 1440

6 years agogpgme-tool: Allow for symmetric encryption.
Werner Koch [Wed, 22 May 2013 08:50:12 +0000 (09:50 +0100)]
gpgme-tool: Allow for symmetric encryption.

* src/gpgme-tool.c (gt_sign_encrypt): Pass NULL for recp if no
recipients are given.

6 years agotests: Print auditlog in plain text format.
Werner Koch [Wed, 22 May 2013 08:50:12 +0000 (09:50 +0100)]
tests: Print auditlog in plain text format.

* tests/gpgsm/t-verify.c (show_auditlog): Use plain text format.

The HTML output is not very helpful on the console and a pain to the

6 years agoImprove C++ compatibility of previous patch.
Werner Koch [Thu, 25 Apr 2013 11:00:16 +0000 (12:00 +0100)]
Improve C++ compatibility of previous patch.

* src/ Move gpgme_sssize_t and gpgme_off_t typedefs into
the extern "C" scope.

Frankly, this does not help very much because g++ still does not
interpret gpgme_data_seek_cb_t as compatible with the C++ ssize_t.  I
am sorry for that API change but C and C++ are too different to always
get both of them under one umbrella.  However, the ABI should now be
identical to older gpgme versions.

6 years agoMake definition of off_t robust against misbehaving w32 toolchains.
Werner Koch [Thu, 25 Apr 2013 11:00:16 +0000 (12:00 +0100)]
Make definition of off_t robust against misbehaving w32 toolchains.

* (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/ Replace all ssize_t and off_t by ac_subst macros.
* src/assuan-support.c, src/ath-pthread.c, src/ath.c, src/ath.h
* src/data-compat.c, src/data-fd.c, src/data-mem.c, src/data-stream.c
* src/data-user.c, src/data.c, src/data.h, src/engine-gpgsm.c
* src/engine-uiserver.c, src/gpgme-tool.c, src/gpgme.c: Replace off_t
by gpgme_off_t and sszie_t by gpgme_ssize_t.
* src/ath-pthread.c, src/ath.h: Include gpgme.h.

For a detailed description, see the gpgme.texi diff.

6 years agow32: Change the way the I/O threads are cleaned up.
Werner Koch [Thu, 25 Apr 2013 11:00:16 +0000 (12:00 +0100)]
w32: Change the way the I/O threads are cleaned up.

* src/w32-io.c (reader_context_s, create_reader)
(writer_context_s, create_writer): Rename STOPPED to CLOSE_EV.
(reader, writer): Remove setting of STOPPED.  Wait for CLOSE_EV and
then release the context.
(destroy_reader, destroy_writer): Do not wait but set the CLOSE_EV.
(kill_reader, kill_writer): Remove.
(_gpgme_io_close): Add code from kill_reader and kill_writer.

The old code was prone to deadlocks which were actually exhibited at
Kleopatra startup.  The new code is much more straightforward and
easier to understand.  The reason for the complex old code was
probably due to our former idea to allow re-use of the I/O threads.
However we have long given up on this.

6 years agoFix hang in socket closing.
Werner Koch [Thu, 25 Apr 2013 11:00:16 +0000 (12:00 +0100)]
Fix hang in socket closing.

* src/w32-io.c (destroy_reader): Call shutdown.
(reader): Do not print an error in the shutdown case.

6 years agoImprove debug output of the I/O reader and writer.
Werner Koch [Mon, 6 May 2013 18:23:47 +0000 (20:23 +0200)]
Improve debug output of the I/O reader and writer.

* src/w32-io.c (reader, writer): Also print file_sock.

6 years agoSimplify a debug code function.
Werner Koch [Mon, 6 May 2013 18:22:23 +0000 (20:22 +0200)]
Simplify a debug code function.

* src/debug.c (_gpgme_debug): Remove static space string.

6 years agoPost release version bump.
Werner Koch [Wed, 1 May 2013 12:27:08 +0000 (14:27 +0200)]
Post release version bump.


6 years agoRelease 1.4.1. gpgme-1.4.1
Werner Koch [Wed, 1 May 2013 11:51:27 +0000 (13:51 +0200)]
Release 1.4.1.

* Bump LT version to C20/A9/R1.

6 years agoDisable fd-passing for Apple.
Werner Koch [Wed, 1 May 2013 11:47:41 +0000 (13:47 +0200)]
Disable fd-passing for Apple.

* Disable fd-passing by default for Apple.

We have not yet tracked down the problem, thus we revert to the
pre-1.4 behaviour for Apple.

GnuPG-bug-id: 1483

6 years agoAllow reading of long gpgconf output lines.
Werner Koch [Tue, 30 Apr 2013 16:09:13 +0000 (18:09 +0200)]
Allow reading of long gpgconf output lines.

* src/engine-gpgconf.c (gpgconf_read): Rewrite to allow for line
lengths up to 64k.

6 years agoSyntax fix for gpgme.texi.
Werner Koch [Tue, 30 Apr 2013 16:05:04 +0000 (18:05 +0200)]
Syntax fix for gpgme.texi.


This fixes commit 12374cbecede047accd2d2267bba5927037ed16c.

6 years agoFix for i686-w64-mingw32.
Werner Koch [Mon, 29 Apr 2013 07:58:57 +0000 (09:58 +0200)]
Fix for i686-w64-mingw32.

* (NEED__FILE_OFFSET_BITS): Do not define under Windows.

6 years agoExplain the GPGME_DEBUG variable.
Werner Koch [Tue, 16 Apr 2013 16:30:20 +0000 (18:30 +0200)]
Explain the GPGME_DEBUG variable.


6 years agoPost release version number bump.
Werner Koch [Tue, 26 Feb 2013 17:32:08 +0000 (18:32 +0100)]
Post release version number bump.


6 years agoRelease 1.4.0. gpgme-1.4.0
Werner Koch [Tue, 26 Feb 2013 16:28:04 +0000 (17:28 +0100)]
Release 1.4.0.

* Bump LT version to C20/A9/R0.

6 years agoEnable FD passing and thus building of the UI-server.
Werner Koch [Tue, 26 Feb 2013 16:25:20 +0000 (17:25 +0100)]
Enable FD passing and thus building of the UI-server.

* Make --enable-fd-passing the default.
* src/engine-uiserver.c (_gpgme_engine_ops_uiserver): Syntax fix.

6 years agow32: Hacks for building with 32 bit mingw64.
Werner Koch [Tue, 26 Feb 2013 16:06:39 +0000 (17:06 +0100)]
w32: Hacks for building with 32 bit mingw64.

* (INSERT__TYPEDEFS_FOR_GPGME_H): Add hacks for 32 bit
* src/util.h [W32]: Include winsock2.h before windows to make mingw64
* src/w32-util.c (_WIN32_IE): Need to use 5.1 for mingw64.

It is not clear to me what mingw64 wants to achieve with their POSIX
hacks. In particular the off64_t stuff looks quite strange given that
Windows has a pretty stable API for close to 2 decades.  Thus I can't
say whether it will really work when build with that toolchain.

6 years agoImprove missing libgpg-error reporting in configure.
Werner Koch [Tue, 26 Feb 2013 14:58:51 +0000 (15:58 +0100)]
Improve missing libgpg-error reporting in configure.

* (NEED_GPG_ERROR_VERSION): New.  Improve reporting for
missing libgpg-error.

6 years agoChange the various version numbers to the new scheme.
Werner Koch [Tue, 26 Feb 2013 16:10:18 +0000 (17:10 +0100)]
Change the various version numbers to the new scheme.

* Rename my_foo variables to mym4_foo variables to make
clear that they are processed by m4.
(VERSION_NUMBER): New ac_subst.
work similar to libgpg-error et al.
* src/ Remove use of BUILD_NUMBER and get it in line
with gpg-error et al.
* src/version.c (cright_blurb): New.
(gpgme_check_version_internal): Add magic to display the above
* tests/t-version.c (main): Add option --verbose.

6 years agoUpdate GnuPG related m4 files.
Werner Koch [Tue, 26 Feb 2013 12:33:28 +0000 (13:33 +0100)]
Update GnuPG related m4 files.

* m4/gpg-error.m4: Update from libgpg-error.
* m4/libassuan.m4: Update from libassuan.

6 years agoUpdate helper scripts.
Werner Koch [Tue, 26 Feb 2013 15:14:52 +0000 (16:14 +0100)]
Update helper scripts.

* Use AC_CONFIG_AUX_DIR.  Remove args from
* compile, config.guess, config.sub, depcomp, install-sh,
* mkinstalldirs, texinfo.texi: Move to build-aux/ and update from
gnulib (c042abf).
* build-aux/mdate-sh, build-aux/missing: Install via automake -a -c.
Update for changed config dir.
* Adjust for scripts dir change.  Update W32 toolprefix

6 years agoRemove included gitlog-to-changelog.
Werner Koch [Mon, 25 Feb 2013 13:40:36 +0000 (14:40 +0100)]
Remove included gitlog-to-changelog.

* build-aux/gitlog-to-changelog: Remove.
* (GITLOG_TO_CHANGELOG): Default to just

6 years agoDeclare next version to be 1.4.0
Werner Koch [Tue, 12 Feb 2013 13:06:07 +0000 (14:06 +0100)]
Declare next version to be 1.4.0


6 years agoAdd macro GPGME_VERSION_NUMBER.
Werner Koch [Tue, 12 Feb 2013 13:02:08 +0000 (14:02 +0100)]

* (my_version_major, my_version_minor)
(my_version_micro): New m4 macros.
(my_version): Build from new m4 macros.
(VERSION_NUMBER): New ac_subst.

6 years agoAdd public function gpgme_get_pinentry_mode.
Werner Koch [Tue, 12 Feb 2013 09:42:54 +0000 (10:42 +0100)]
Add public function gpgme_get_pinentry_mode.

* src/gpgme.c (gpgme_get_pinentry_mode): New.

6 years agogpgme_tool: Support GPG's new pinentry-mode.
Werner Koch [Thu, 7 Feb 2013 20:03:02 +0000 (21:03 +0100)]
gpgme_tool: Support GPG's new pinentry-mode.

* src/gpgme-tool.c (log_error): Do not always print the error source.
(gt_set_pinentry_mode): New.
(server_passphrase_cb): New.
(cmd_pinentry_mode): New.
(register_commands): Add cmd_pinentry_mode.
(options): Add option --gpg-binary.
(struct args): Add field gpg-binary.
(parse_options, main): Implement that option.

6 years agoAdd public function gpgme_set_pinentry_mode.
Werner Koch [Thu, 7 Feb 2013 19:59:16 +0000 (20:59 +0100)]
Add public function gpgme_set_pinentry_mode.

* src/gpgme.c (gpgme_set_pinentry_mode): New.
* src/ (gpgme_pinentry_t): New.
(gpgme_set_pinentry_mode): New.
* src/context.h (struct gpgme_context): Add field pinentry_mode.
* src/engine-backend.h (struct engine_ops): Add field
* src/engine-gpg.c (struct engine_gpg): Add field pinentry_mode.
(build_argv): Implement pinentry_mode.
(gpg_set_pinentry_mode): New.
(_gpgme_engine_ops_gpg): Register gpg_set_pinentry_mode.


Note that this new fucntion may only be used with gpg 2.1.

6 years agoAdd public function gpgme_io_writen.
Werner Koch [Thu, 7 Feb 2013 19:51:29 +0000 (20:51 +0100)]
Add public function gpgme_io_writen.

* src/gpgme.c (gpgme_io_read): New.

This is a writen style variant for gpgme_io_write.  It is often easier
to use this one in passphrase and edit callbacks.

6 years agoUse gpg_error_from_syserror instead of directly accessing errno.
Werner Koch [Wed, 6 Feb 2013 16:35:40 +0000 (17:35 +0100)]
Use gpg_error_from_syserror instead of directly accessing errno.


Also fixed a couple of minor thing; e.g. save the error before calling
cleanup functions.  Do not save the errno if only free is called
in between.

6 years agoImprove parsing of the GIT revision number.
Werner Koch [Fri, 16 Nov 2012 12:50:58 +0000 (13:50 +0100)]
Improve parsing of the GIT revision number.

* (git_revision): Use git rev-parse.

6 years agoFix non-portable use of chmod in
Werner Koch [Fri, 16 Nov 2012 12:45:14 +0000 (13:45 +0100)]
Fix non-portable use of chmod in

* Remove option -c from chmod.

6 years agoMake _gpgme_encode_percent_string work for memory buffers.
Werner Koch [Thu, 15 Nov 2012 10:14:58 +0000 (11:14 +0100)]
Make _gpgme_encode_percent_string work for memory buffers.

* src/conversion.c (D_gpgme_encode_percent_string): Remove stray
semicolon.  Reported by Xi Wang.
Obviously this function is not used with a supplied LEN argument != 0.

6 years agoMake local variables configure hack more robust
Werner Koch [Wed, 24 Oct 2012 14:51:47 +0000 (16:51 +0200)]
Make local variables configure hack more robust

* (emacs_local_vars_begin): Use extra m4 quoting so that
newer Emscasen won't take it up as Local Variables for this file.

6 years agoFix ttyname problem on Android.
Werner Koch [Wed, 24 Oct 2012 14:44:34 +0000 (16:44 +0200)]
Fix ttyname problem on Android.

* Define macro and conditional HAVE_ANDROID_SYSTEM.
* m4/gnupg-ttyname.m4: Force use of replacement on Android.
* src/ttyname_r.c: Ditto.

Android's bionic lib has no working ttyname_r() nor ttyname().  Using
them anyway will print

  FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:466

Thus we force the use of our replacement code which simply return

6 years agotests: Adhere to the docs and call gpgme_check_version.
Werner Koch [Wed, 24 Oct 2012 14:07:31 +0000 (16:07 +0200)]
tests: Adhere to the docs and call gpgme_check_version.

* tests/t-engine-info.c: Call gpgme_check_version.

6 years agoTrace the use of GPG_ERR_INV_ENGINE.
Werner Koch [Fri, 19 Oct 2012 09:23:39 +0000 (11:23 +0200)]
Trace the use of GPG_ERR_INV_ENGINE.

* src/debug.h: Include "gpgme.h"
(_gpgme_trace_gpgme_error): New.
(trace_gpg_error): New macro.  Use it in all files where we return
GPG_ERR_INV_ENGINE; also "include debug.h" as needed.

This is a pretty common error code but often it is hard to figure out
the actual cause.  With debug level 4 we now print the file name and
line number where this error code is generated by gpgme.  Along with
the git revision printed in the first log lines, this should give us
an easier way to track down the problems related to this error code.

6 years agoAvoid warning about initialized but not used variable
Werner Koch [Fri, 19 Oct 2012 09:18:08 +0000 (11:18 +0200)]
Avoid warning about initialized but not used variable

* src/engine-gpgsm.c (gpgsm_set_fd): Do not set DIR if not needed.

7 years agogpgme-tool: Use membuf functions to build up strings.
Werner Koch [Thu, 11 Oct 2012 15:02:50 +0000 (17:02 +0200)]
gpgme-tool: Use membuf functions to build up strings.

* src/gpgme-tool.c (clear_membuf, init_membuf, put_membuf)
(put_membuf_str, get_membuf, peek_membuf): Add membuf functions.
Take from GnuPG master's common/membuf.[ch] and patch for our use.
(result_xml_escape): Rewrite using new functions.

First counting, then allocating, and finally copying data is prone to
errors.  We better use the membuf functions which make it much easier.

7 years agogpgme-tool: Change license from LPGLv2+ to GPLv3+
Werner Koch [Thu, 11 Oct 2012 14:54:58 +0000 (16:54 +0200)]
gpgme-tool: Change license from LPGLv2+ to GPLv3+

* src/gpgme-tool.c: Change license notice.

gpgme-tool.c is a standalone program, thus it makes no sense to keep
it under the LGPL.  We already had the manual under GPLv3+.

7 years agogpgme-tool: escape special characters in output XML data (<, >, and &).
W. Trevor King [Sat, 6 Oct 2012 15:30:21 +0000 (11:30 -0400)]
gpgme-tool: escape special characters in output XML data (<, >, and &).

[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (result_xml_escape_replacement, result_xml_escape):
(result_xml_tag_data): Use result_xml_escape() to escape data.
(result_add_error): Use unescaped < and >.

This is a general solution for generating valid XML, but the specific
output that inspired the change was from the KEYLIST command:

  <uid>William Trevor King <></uid>

Now the uids are properly escaped:

   <uid>William Trevor King &lt;;</uid>

Signed-off-by: W. Trevor King <>
7 years agogpgme-tool: Fix chain_id -> chain-id in KEYLIST XML.
W. Trevor King [Sat, 6 Oct 2012 13:33:30 +0000 (09:33 -0400)]
gpgme-tool: Fix chain_id -> chain-id in KEYLIST XML.

[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (cmd_keylist): Use <chain-id> instead of <chain_id>.
All the other tags map struct attribute underscores to hyphens, so
fixing <chain_id> follows the priciple of least surprise.

Signed-off-by: W. Trevor King <>
7 years agogpgme-tool: Return more detailed XML from KEYLIST
W. Trevor King [Fri, 28 Sep 2012 06:31:13 +0000 (08:31 +0200)]
gpgme-tool: Return more detailed XML from KEYLIST

src/gpgme-tool.c (cmd_keylist): Convert output from a list of
to more detailed XML.
(xml_preamble1, xml_preamble2, xml_end): Make global.
(result_add_protocol, result_add_validity): New functions for
generating XML from GPGME types.
(result_add_string): Treat NULL strings as "".
(result_xml_tag_data): Make 'data' a 'const char' so we can use the
value returned by gpgme_get_protocol_name directly.

This is a first pass at returning most of the gpgme_key_t data from the

Signed-off-by: W. Trevor King <>
7 years agogpgme-tool: Initialize input_fd and output_fd
W. Trevor King [Wed, 26 Sep 2012 23:26:00 +0000 (19:26 -0400)]
gpgme-tool: Initialize input_fd and output_fd

* src/gpgme-tool.c (gpgme_server): Initialize input_fd and output_fd.

Signed-off-by: W. Trevor King <>
7 years agogpgme-tool: Fix handling of file descriptors
Werner Koch [Wed, 26 Sep 2012 07:37:22 +0000 (09:37 +0200)]
gpgme-tool: Fix handling of file descriptors

* src/gpgme-tool.c (server_reset_fds): Use close/CloseHandle instead
of the assuan close functions.
(_cmd_decrypt_verify, _cmd_sign_encrypt, cmd_verify, cmd_import)
(cmd_export, cmd_genkey, cmd_getauditlog): Use SERVER object instead
of assuan_get_*_fd functions.

Although we used our own handlers for INPUT and OUTPUT, we still used
assuan_get_input_fd, assuan_get_output_fd and their close functions.
That clearly can't work because libassuan does not have any values for

7 years agoAdd DCO file
Werner Koch [Tue, 25 Sep 2012 17:21:00 +0000 (19:21 +0200)]
Add DCO file


7 years agoDocument contribution rules.
Werner Koch [Tue, 25 Sep 2012 17:19:13 +0000 (19:19 +0200)]
Document contribution rules.

* doc/HACKING (License policy): New.
* doc/DCO: New.
* AUTHORS: Change maintainer address.

7 years agoAdd gpgme_set_global_flag to help debugging
Werner Koch [Tue, 25 Sep 2012 13:38:26 +0000 (15:38 +0200)]
Add gpgme_set_global_flag to help debugging

* src/gpgme.c (gpgme_set_global_flag): New.
* src/ (gpgme_set_global_flag): New.
* src/gpgme.def, src/libgpgme.vers: Add new public function.
* src/debug.c (envvar_override): New.:
(_gpgme_debug_set_debug_envvar): New.
(debug_init): Take ENVVAR_OVERRIDE in account.

On Android envvars can't be used, thus we need another way to enable
GPGME debugging.  The new function allows this and may be used in the
future to implement similar things.

7 years agoRemove all trailing whitespace from source files
Werner Koch [Tue, 25 Sep 2012 13:29:49 +0000 (15:29 +0200)]
Remove all trailing whitespace from source files

Command used:  sed -i 's,[ \t]*$,,' FILE

7 years agoAdd two recent contributors.
Marcus Brinkmann [Sat, 28 Jul 2012 20:09:01 +0000 (22:09 +0200)]
Add two recent contributors.

7 years agoFix sign error in position calculation for mem_seek.
Marcus Brinkmann [Sat, 28 Jul 2012 20:06:09 +0000 (22:06 +0200)]
Fix sign error in position calculation for mem_seek.

* data-mem.c (mem_seek): Fix sign error in position calculation.

7 years agoAllow null context on gpgme_set_locale.
Marcus Brinkmann [Fri, 27 Jul 2012 23:17:03 +0000 (01:17 +0200)]
Allow null context on gpgme_set_locale.

* gpgme.c (gpgme_set_locale): Allow CTX to be a null pointer.

7 years agoDo not include the removed file status-table.h
Werner Koch [Fri, 13 Jul 2012 12:00:22 +0000 (14:00 +0200)]
Do not include the removed file status-table.h

* src/engine-uiserver.c: Remove status-table.h which is not anymore
built.  Fixes bug#1412.

The file was actually removed from the code by 885243e0 but for
unknown reasons the missing file was not reported by "make distcheck".

7 years agoMake handling of new conf values more robust (bug#1413).
Werner Koch [Fri, 13 Jul 2012 08:59:22 +0000 (10:59 +0200)]
Make handling of new conf values more robust (bug#1413).

* src/engine-gpgconf.c (arg_to_data): Allow for NULL as value.string.

I was not able to replicate the problem.  However this patch makes the
code more robust and tolerates errors by the user.  IT should fix the
problem at hand.

7 years agoPost release updates.
Werner Koch [Wed, 2 May 2012 09:30:57 +0000 (11:30 +0200)]
Post release updates.


7 years agoRelease 1.3.2. gpgme-1.3.2
Werner Koch [Wed, 2 May 2012 08:58:52 +0000 (10:58 +0200)]
Release 1.3.2.

* Bump LT version to C19/A8/R1.

* (gen-ChangeLog): Use it.

7 years agoRemove unused pth stuff from gpgme-config.
Werner Koch [Wed, 2 May 2012 08:43:22 +0000 (10:43 +0200)]
Remove unused pth stuff from gpgme-config.

* src/ Remove unused pth stuff.

7 years agoFix minor documentation problem.
Werner Koch [Wed, 2 May 2012 08:35:47 +0000 (10:35 +0200)]
Fix minor documentation problem.

Fixes bug#1404.
(There is mentioned data field “recipient”, but actual data field
name is “recipients”.)

7 years agoUpdate signature summary for the case of missing X.509 keys.
Werner Koch [Wed, 2 May 2012 08:30:09 +0000 (10:30 +0200)]
Update signature summary for the case of missing X.509 keys.

* src/verify.c (gpgme_op_verify_result): Update summary field.

This is actually a hack to solve the problem that GPGME currently does
not emit ERRSIG for a missing public key.

7 years agoFix timestamp parsing for y2038 hack.
Werner Koch [Mon, 30 Apr 2012 15:46:15 +0000 (17:46 +0200)]
Fix timestamp parsing for y2038 hack.

* src/conversion.c (_gpgme_parse_timestamp): Set ENDP before year 2038

7 years agoRemove trailing white space
Werner Koch [Mon, 30 Apr 2012 15:42:53 +0000 (17:42 +0200)]
Remove trailing white space


7 years ago.gitignore: flesh out rules and add subdirectory-.gitignores.
W. Trevor King [Thu, 12 Apr 2012 17:51:48 +0000 (13:51 -0400)]
.gitignore: flesh out rules and add subdirectory-.gitignores.

7 years agostatus-table.c: include string.h for strcmp.
W. Trevor King [Thu, 12 Apr 2012 17:51:49 +0000 (13:51 -0400)]
status-table.c: include string.h for strcmp.

* status-table.c: include string.h to avoid `warning: implicit
declaration of function 'strcmp'`.

7 years agogpgme-tool: add help messages for a number of commands.
W. Trevor King [Tue, 27 Mar 2012 19:10:02 +0000 (15:10 -0400)]
gpgme-tool: add help messages for a number of commands.

* src/gpgme-tool.c (hlp_engine, hlp_sub_protocol, hlp_armor, hlp_textmode,
hlp_include_certs, hlp_keylist_mode, hlp_input, hlp_output, hlp_message,
hlp_recipient, hlp_signer, hlp_signers_clear, hlp_decrypt, hlp_decrypt_verify,
hlp_encrypt, hlp_sign_encrypt, hlp_sign, hlp_verify, hlp_import): New strings.
(hlp_protocol): Fix typo.
(register_commands): Add documentation strings.
(doc): Mention Assuan.

7 years agouiserver.texi: fix decryption -> encryption typo in PREP_ENCRYPT discussion.
W. Trevor King [Tue, 27 Mar 2012 19:10:01 +0000 (15:10 -0400)]
uiserver.texi: fix decryption -> encryption typo in PREP_ENCRYPT discussion.

* doc/uiserver.texi (PREP_ENCRYPT): Fix documentation.

7 years agoUpdate Werner Koch's distribution signing key in the README.
W. Trevor King [Tue, 27 Mar 2012 19:10:00 +0000 (15:10 -0400)]
Update Werner Koch's distribution signing key in the README.

* README: Update signing key.

7 years agoDo not rely on glibc name of syscall.
Marcus Brinkmann [Mon, 12 Mar 2012 15:37:26 +0000 (16:37 +0100)]
Do not rely on glibc name of syscall.

* src/ath.c (ath_self): Use __NR_gettid, not SYS_gettid.

7 years agoUpdate config.guess and config.sub to latest version.
Marcus Brinkmann [Mon, 12 Mar 2012 15:00:29 +0000 (16:00 +0100)]
Update config.guess and config.sub to latest version.

* config.guess, config.sub: Update to latest version.

7 years agoRework status table to be less dynamically generated.
Marcus Brinkmann [Tue, 14 Feb 2012 12:03:46 +0000 (13:03 +0100)]
Rework status table to be less dynamically generated.

* src/ (EXTRA_DIST): Remove mkstatus.
(main_sources): Remove status-table.h, extra-stati.h.
Add status-table.c.
(status-table.h): Remove rules for built source.
* src/decrypt.c: Don't include extra-stati.h.
* src/engine-gpg.c: Don't include status-table.h.
(status_cmp): Remove function.
(read_status): Use _gpgme_parse_status.
* src/engine-gpgsm.c: Don't include status-table.h.
(status_cmp, parse_status): Remove function.
(gpgsm_assuan_simple_command, status_handler): Use _gpgme_parse_status.
* src/engine-uiserver.c: Don't include status-table.h.
(status_cmp, parse_status): Remove function.
(uiserver_assuan_simple_command, status_handler): Use
* src/ (gpgme_status_code_t): Add
* src/util.h (_gpgme_status_init,_gpgme_parse_status): New declaration.
* src/status-table.c: New file.
* src/extra-stati.h, src/mkstatus: Files removed.
* version.c (do_subsystem_inits): Call _gpgme_status_init.

7 years agoUse gpgme interface for error handling to avoid linking with gpg-error.
Marcus Brinkmann [Wed, 8 Feb 2012 14:26:17 +0000 (15:26 +0100)]
Use gpgme interface for error handling to avoid linking with gpg-error.

* tests/t-data.c, tests/run-export.c, tests/run-keylist.c,
tests/run-support.h, tests/run-verify.c, tests/gpg/t-decrypt-verify.c,
tests/gpg/t-edit.c, tests/gpg/t-eventloop.c, tests/gpg/t-keylist-sig.c,
tests/gpg/t-keylist.c, tests/gpg/t-support.h, tests/gpg/t-trustlist.c,
tests/gpg/t-verify.c, tests/gpg/t-wait.c, tests/gpgsm/cms-decrypt.c,
tests/gpgsm/cms-keylist.c, tests/gpgsm/t-keylist.c,
tests/gpgsm/t-support.h, tests/gpgsm/t-verify.c,
tests/opassuan/t-command.c: Use gpgme interface for gpg-error functions.

7 years agoLink the thread test to pthread.
Marcus Brinkmann [Wed, 8 Feb 2012 14:19:33 +0000 (15:19 +0100)]
Link the thread test to pthread.

* tests/gpg/ (t_thread1_LDADD): Add -lpthread.

7 years agoLink gpgme-tool directly to libassuan, as it uses its interface.
Marcus Brinkmann [Wed, 8 Feb 2012 14:18:11 +0000 (15:18 +0100)]
Link gpgme-tool directly to libassuan, as it uses its interface.

* src/ (gpgme_tool_LDADD): Add @LIBASSUAN_LIBS@.

7 years agoSupport the mingw-w64 toolchain.
Werner Koch [Thu, 19 Jan 2012 17:44:39 +0000 (18:44 +0100)]
Support the mingw-w64 toolchain.

* (build-w32): Add i686-w64-mingw32 to the toolprefix.

7 years agoFix Solaris problems with ttyname_r.
Werner Koch [Thu, 19 Jan 2012 17:43:10 +0000 (18:43 +0100)]
Fix Solaris problems with ttyname_r.

* m4/gnupg-ttyname.m4: New.  Based on ttyname_r from gnulib.
* src/ttyname_r.c (_gpgme_ttyname_r): Rename from ttyname_r.
Implement hacks required for Solaris and possible other non-fully
Posix systems.
* src/util.h: Include unistd.h.  Redefine ttyname_r depending on
REPLACE_TTYNAME_R and put it into the gpgme name space.

Unfortunately we cant not use the ttyname_r replacement from gnulib
because we want to keep GPGME LGPLv2+.

7 years agoTry to make a bit smaller.
Werner Koch [Thu, 19 Jan 2012 15:05:31 +0000 (16:05 +0100)]
Try to make a bit smaller.

* Move header checks.

7 years agoFor W32 use a build number instead of abbreviated commit id.
Werner Koch [Thu, 19 Jan 2012 15:04:19 +0000 (16:04 +0100)]
For W32 use a build number instead of abbreviated commit id.

We would need to use a shortened commit id so that it fits into an 16
bit Windows variable.  Further it is a random number and not something
increasing.  Thus a build number made up from the day of the year and
the hour is much more useful to describe a build number for a specific
* src/ Ditto.

7 years agoAdjust for modern autoconf.
Werner Koch [Thu, 19 Jan 2012 14:57:09 +0000 (15:57 +0100)]
Adjust for modern autoconf.

* Minor cleanups.