Commit Graph

1600 Commits

Author SHA1 Message Date
Werner Koch
991cde9e79 Add GPGME_ENCRYPT_NO_COMPRESS flag.
* src/gpgme.h.in (GPGME_ENCRYPT_NO_COMPRESS): New.
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Implement it.
* src/gpgme-tool.c (_cmd_sign_encrypt): Add option --no-compress.
2014-05-08 11:31:30 +02:00
Werner Koch
62711e5614 w32: Fix another memleak on error.
* src/w32-io.c (create_reader): free CTX.
--

Found by Hans-Christoph Steiner with cppcheck.
2014-04-16 10:19:54 +02:00
Werner Koch
85a07ca7e3 w32: Fix memleak in an error code paths.
* src/w32-io.c (create_writer): Free CTX in cased of bad FD.
* src/w32-util.c (_gpgme_mkstemp): Free TMPNAME in case of a failed
mkstemp.
--

Found by Hans-Christoph Steiner with cppcheck.
2014-04-15 22:18:04 +02:00
Werner Koch
2bb26185e3 Fix possible zombie processes.
* src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR.
(_gpgme_io_dup): Likewise.
(_gpgme_io_connect): Likewise.
--

GnuPG-bug-id: 1630
2014-04-15 12:25:45 +02:00
Werner Koch
d3bd8fff86 Actually implement flags for gpgme_op_spawn.
* src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow
to spawn_start and add FLAGS args along the call path.
* src/engine-spawn.c (engspawn_start): Hack to automagically provide
argv[0].
2014-04-10 14:17:19 +02:00
Werner Koch
4f2d652e60 Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.
* src/gpgme.h.in (GPGME_PROTOCOL_SPAWN): New.
(GPGME_SPAWN_DETACHED, GPGME_SPAWN_ALLOW_SET_FG): New.
* src/gpgme.c (gpgme_set_protocol): Add new protocol.
(gpgme_get_protocol_name): Ditto.
* src/spawn.c: New.
* src/libgpgme.vers, src/gpgme.def: Add new public functions.
* src/engine-spawn.c: New.
* src/Makefile.am: Add new files.
* src/engine-backend.h (struct engine_ops): Add OPSPAWN.
* src/engine.c (engine_ops): Add _gpgme_engine_ops_spawn.
(gpgme_get_engine_info): Add Spawn to the list of protocols.
(_gpgme_engine_op_spawn): New.

* src/gpgme-tool.c (gt_protocol_from_name): Add new protocol.
(gt_spawn, cmd_spawn): New.
2014-04-10 13:01:00 +02:00
Werner Koch
77931a9a14 Add gpgme_get_dirinfo.
* src/dirinfo.c (gpgme_get_dirinfo): New.
* tests/t-engine-info.c (main): Print results from that function.
2014-04-10 11:48:20 +02:00
Werner Koch
b788c36ec0 Remove compiler warning from test
--
2014-04-10 11:42:39 +02:00
Werner Koch
443f6b76a9 Make use of internal iospawn flags more flexible.
* src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others.
* src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if
IOSPAWN_FLAG_DETACHED is given.
* src/w32-qt-io.cpp (_gpgme_io_spawn): Ditto.
* src/w32-glib-io.c (_gpgme_io_spawn): Ditto.
* src/assuan-support.c (my_spawn): Pass IOSPAWN_FLAG_DETACHED flags.
* src/dirinfo.c (read_gpgconf_dirs): Ditto.
* src/engine-gpg.c (start): Ditto.
* src/engine-gpgconf.c (gpgconf_read, gpgconf_write): Ditto.
* src/version.c (_gpgme_get_program_version): Ditto.
2014-04-10 11:39:14 +02:00
Werner Koch
617d3be629 Make sure a spawned process has all standard fds connected.
* src/posix-io.c (_gpgme_io_spawn): dup /dev/null also to unsued
stdout.
--

Better be sure that stdout of a spawned process is connected to stdout
so that the process does not run into a write error if it writes to
stdout.  AFAICS we always use a connected stdout; thus this is only
for correctness.
2014-04-10 11:15:40 +02:00
Werner Koch
766355b5d4 Add configure option --enable-fixed-path.
* configure.ac: Add option --enable-fixed-path.
(FIXED_SEARCH_PATH): New ac_define.
* src/posix-util.c (walk_path): Make use of the option.  Remove
current directory from fallback PATH.
--

Note that using this option PATH is entirely ignored by GPGME and only
the given value is used instead to locate the GnuPG binaries.

On Android the use of PATH is not desirable.  Instead the GnuPG tools
are expected in a fixed directory.  By using

  ./configure --enable-fixed-path="/foo/bar"

gpg et al are expected to be installed as /foo/bar/gpg.  With

  ./configure --enable-fixed-path="/foo/bar:/bin"

gpg is expected as /foo/bar/gpg or /bin/gpg.
2014-03-13 14:24:14 +01:00
Werner Koch
dd9c8c5671 Avoid pointer arithmetic on void pointer.
* src/gpgme.c (gpgme_io_writen): Use new var buffer.
--

Reported-by: Albert Chin
2014-03-11 13:58:38 +01:00
Werner Koch
75a6255935 Change implementation return type to match the definition.
* src/gpgme.c (gpgme_get_sub_protocol): Change return type to
gpgme_protocol_t.
--

Yet another enum/int mismatch.

Reported-by: Albert Chin.
2014-03-11 13:54:21 +01:00
Daiki Ueno
40938feb3f doc: Fix documentation of struct data types
* gpgme.texi (Key Management): Document is_cardkey and card_number
members of gpgme_subkey_t.
(Decrypt): Remove description of the non-existent wrong_key_usage
member of gpgme_recipient_t.
(Verify): Document pka_address member of gpgme_signature_t.
(Creating a Signature): Add missing member names in
gpgme_new_signature_t.
(Registering I/O Callbacks): Fix reference of gpgme_io_cbs struct.
2014-03-05 08:16:20 +01:00
Werner Koch
651d9e1c6b Always pass correct name to argv[0]. Ignore GPG_AGENT_INFO for gpg2.
* src/dirinfo.c (WANT_GPG_ONE_MODE): New.
(struct dirinfo): Add field "gpg_one_mode".
(get_gpgconf_item): Set that field and return it if requested.
(_gpgme_in_gpg_one_mode): New.
* src/engine-gpg.c (build_argv): Check GPG_AGENT_INFO only in gpg-1
mode.

* src/dirinfo.c (_gpgme_get_basename): New.
* src/engine-g13.c (g13_new): Take argv[0] from the pgmname.
* src/engine-gpgsm.c (gpgsm_new): Ditto.
* src/engine-gpg.c (build_argv): Ditto. Add arg PGMNAME.
(start): Pass PGMNAME to buildargv.
2014-02-21 11:22:45 +01:00
Werner Koch
f916ab753b Fix type inconsistency between gpgme.h and gpgme.c.
* src/gpgme.c (gpgme_set_pinentry_mode): Fix type of MODE.
--

GnuPG-bug-id: 1617
2014-02-12 20:36:08 +01:00
Werner Koch
1a504aab38 Use the generic autogen.sh script.
* autogen.rc: New.
* Makefile.am (EXTRA_DIST): Add it.
* autogen.sh: Update from GnuPG.

* configure.ac (AM_SILENT_RULES): New.
2014-01-10 17:40:05 +01:00
Werner Koch
74c0075ca2 Set next version to 1.5.0
--
2014-01-07 18:08:41 +01:00
Werner Koch
ab6e718327 Make gpgconf engine work again - fixes 02ba35c1.
* src/gpgconf.c: Remove ENABLE_GPGCONF and move prototypes to ...
* src/engine-backend.h: ... here.
--

gpgconf is a required part for gpgme.
2014-01-07 17:59:59 +01:00
Werner Koch
121efcc561 Make gpgme_new return a proper error if no engines are installed.
* src/engine.c (gpgme_get_engine_info): Improve error handling.
(_gpgme_engine_info_copy): Ditto.
* src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE.
2014-01-07 13:32:08 +01:00
Werner Koch
d63058b852 Print the full PATH in the log if gpg was not found.
* src/posix-util.c (walk_path): Keep a copy of PATH.
2014-01-07 12:44:55 +01:00
Werner Koch
6564e5e78e 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
options.
--

Note that the Windows part has not been tested.
2014-01-06 17:16:52 +01:00
Werner Koch
02ba35c1b6 Locate engine names only at runtime and prefer GnuPG-2.
* configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION)
(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/Makefile.am: 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
uiserver.
* 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
walk_path.
* 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
string.
* 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/Makefile.am (GPG, GPG_AGENT): Hardwire gpg and gpg-agent.
* tests/gpgsm/Makefile.am (GPGSM): Hardwire gpgsm.

Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-27 16:08:20 +01:00
Werner Koch
b0aaa3f9ae 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
bad.
2013-08-19 20:43:19 +02:00
Werner Koch
372bd43983 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.
2013-08-19 20:40:10 +02:00
Werner Koch
eae9c32bd9 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.
2013-08-19 20:38:36 +02:00
Werner Koch
d788c35e19 Release 1.4.3.
* configure.ac: Change LT version to C22/A11/R0.
2013-08-12 14:33:49 +02:00
Werner Koch
3ca7e96e38 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/Makefile.am (c_tests): New.
(TESTS): Move all to c_tests.  Add initial.test, final.test, and
c_tests.
(TESTS_ENVIRONMENT): Add C_ALL=C
(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.
2013-08-12 14:32:21 +02:00
Werner Koch
069ac58037 Improve detection of default gpg by configure.
* configure.ac: 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.
2013-08-12 14:24:34 +02:00
Werner Koch
8579091c4f Add function gpgme_data_identify.
* src/gpgme.h.in (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.
2013-08-09 19:19:26 +02:00
Werner Koch
a4c80126ae Prefer GnuPG-2 engines over GnuPG-1.
* src/util.h: Move some prototypes to ...
* src/sys-util.h: New.
* src/Makefile.am (main_sources): Add sys-util.h.
* configure.ac (AH_VERBATIM): Add DIRSEP_C and DIRSEP_S.
* src/dirinfo.c: Include sys-util.h.
(WANT_GPG_NAME, WANT_GPGSM_NAME, WANT_G13_NAME)
(WANT_UISRV_SOCKET): New.
(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
output.
(_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.
2013-08-02 15:25:23 +02:00
Werner Koch
3881ea4e83 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.
2013-08-02 12:48:30 +02:00
Werner Koch
393a9471f2 doc: Add --binary option for the OUTPUT command of an uiserver. 2013-07-31 17:32:02 +02:00
Werner Koch
ff84d8d894 doc: Fix variable name.
--
GnuPG-bug-id: 1507
2013-06-18 10:46:24 +02:00
Werner Koch
f2eeccbdfa Add function gpgme_signers_count.
* src/signers.c (gpgme_signers_count): New.
* src/libgpgme.vers, src/gpgme.def: Add as external symbol.
* src/gpgme.h.in: Add prototype.
2013-06-18 10:27:46 +02:00
Werner Koch
5df596d6ec Post release version bump.
--
2013-05-28 12:17:45 +02:00
Werner Koch
009e26a989 Release 1.4.2.
* configure.ac: Set LT version to C21/A10/R0.
2013-05-28 11:09:07 +02:00
Werner Koch
2e8feb6016 Add convenience macro GPGME_PROTOCOL_OPENPGP.
* src/gpgme.h.in (GPGME_PROTOCOL_OPENPGP): New.
2013-05-28 10:55:35 +02:00
Hans-Christoph Steiner
d34e343487 doc: rename gpgme_sub_key_t to gpgme_subkey_t to match gpgme.h
--
2013-05-28 10:37:51 +02:00
Werner Koch
c29dad2315 w32: Fix installing of .def file.
* src/Makefile.am (install-def-file): Create libdir first.
2013-05-23 20:18:04 +02:00
Werner Koch
d739d4d8cf Fix libtool 2.4.2 to correctly detect .def files.
* build-aux/ltmain.sh (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 <wk@gnupg.org>
2013-05-23 20:15:30 +02:00
Werner Koch
d4371ed30d Support --no-encrypt-to also with gpgme_op_encrypt_sign.
* src/engine-gpg.c (gpg_encrypt_sign): Support the
GPGME_ENCRYPT_NO_ENCRYPT_TO flag.
2013-05-22 16:32:15 +02:00
Werner Koch
567e6481d7 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 <g10bts@curetheitch.com>
GnuPG-bug-id: 1440
2013-05-22 16:31:51 +02:00
Werner Koch
0c1de7abd5 gpgme-tool: Allow for symmetric encryption.
* src/gpgme-tool.c (gt_sign_encrypt): Pass NULL for recp if no
recipients are given.
2013-05-22 16:20:14 +02:00
Werner Koch
18254f88f8 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
eyes.
2013-05-22 15:03:57 +02:00
Werner Koch
e99356306d Improve C++ compatibility of previous patch.
* src/gpgme.h.in: 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.
2013-05-18 13:49:52 +02:00
Werner Koch
6d0d8e7ba0 Make definition of off_t robust against misbehaving w32 toolchains.
* configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/gpgme.h.in: 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.
2013-05-16 17:48:50 +02:00
Werner Koch
9e7df9aa6d 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.
2013-05-11 15:38:08 +02:00
Werner Koch
9f330be821 Fix hang in socket closing.
* src/w32-io.c (destroy_reader): Call shutdown.
(reader): Do not print an error in the shutdown case.
2013-05-08 20:38:50 +02:00
Werner Koch
2118f49701 Improve debug output of the I/O reader and writer.
* src/w32-io.c (reader, writer): Also print file_sock.
2013-05-08 19:10:41 +02:00