gpgme.git
46 hours agocpp: Add wrapper for gpgme_set_global_flag master
Andre Heinecke [Wed, 24 Apr 2019 10:34:48 +0000 (12:34 +0200)]
cpp: Add wrapper for gpgme_set_global_flag

* lang/cpp/src/context.cpp (setGlobalFlag): New.
* lang/cpp/src/global.h (setGlobalFlag): Export it.

--
GnuPG-Bug-Id: T4471

7 days agocore: Fix duplication of close_notify_handler for gpgsm.
NIIBE Yutaka [Fri, 19 Apr 2019 05:54:52 +0000 (14:54 +0900)]
core: Fix duplication of close_notify_handler for gpgsm.

* src/engine-gpgsm.c [!USE_DESCRIPTOR_PASSING] (gpgsm_new): Remove
last call to _gpgme_io_set_close_notify.

--

It is called just after the code in question for all cases.

GnuPG-bug-id: 4456
Fixes-commit: dd21ec997cf4b6ba18538c63c728478110ad1f60
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
7 days agocore: Fix error return.
NIIBE Yutaka [Fri, 19 Apr 2019 02:32:29 +0000 (11:32 +0900)]
core: Fix error return.

* src/engine.c (_gpgme_set_engine_info): Add error return.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 weeks agocore,w32: Fix minor potential memleak
Andre Heinecke [Tue, 9 Apr 2019 12:24:17 +0000 (14:24 +0200)]
core,w32: Fix minor potential memleak

* src/w32-util.c (_gpgme_create_process_utf8): Free converted
startup info strings.

2 weeks agocore,w32: Fix new w32-util functions
Andre Heinecke [Tue, 9 Apr 2019 12:11:21 +0000 (14:11 +0200)]
core,w32: Fix new w32-util functions

* src/w32-util.c (_gpgme_access): Respect mode parameter.
(_gpgme_create_process_utf8): Convert startupinfo, too.

--
This both did not show up in testing as we only use
mode F_OK and STARTUPINFOA is basically the same as
STARTUPINFOW.

Fixes commit: a82e3a0ae57a48ba173e282a050680751006c074

GnuPG-Bug-Id: T4453

2 weeks agocore,w32: Improve handling of Unicode paths
Andre Heinecke [Tue, 9 Apr 2019 11:42:58 +0000 (13:42 +0200)]
core,w32: Improve handling of Unicode paths

* src/dirinfo.c (get_gpgconf_item): Use _gpgme_access.
* src/posix-util.c (_gpgme_access): Add forward to normal access.
* src/sys-util.h (_gpgme_access): New for posix and w32.
* src/w32-io.c (_gpgme_io_spawn): Use _gpgme_crate_process_utf8.
* src/w32-util.c (utf8_to_wchar, utf8_to_wchar0): The usual w32 conv.
(find_program_in_dir): Use _gpgme_access.
(find_program_at_standard_place): Use wchar API and convert to UTF-8.
(_gpgme_access): Convert UTF-8 to wchar and use wchar API.
(_gpgme_create_process_utf8): Convert UTF-8 to wchar and use wchar API.

--
While we should not say that we have full support for unicode path
installations of GnuPG, this ensures that GPGME works if GPGME
itself is installed in a unicode path. e.g.: Libreoffice supports
this.

GnuPG-Bug-Id: T4453

Based on a patch provided by Egor Pugin. Thanks.

2 weeks agocore,w32: Show w32-spawn warning only once
Andre Heinecke [Tue, 9 Apr 2019 11:25:08 +0000 (13:25 +0200)]
core,w32: Show w32-spawn warning only once

* src/w32-io.c (_gpgme_io_spawn): Show MessageBox only once.

--
This prevents multiple message boxes from showing when
the GPGME installation is unworkable.

GnuPG-Bug-Id: T4453

4 weeks agocore, w32: Fix format string errors on windows
Andre Heinecke [Wed, 27 Mar 2019 16:47:41 +0000 (17:47 +0100)]
core, w32: Fix format string errors on windows

* src/debug.c (_gpgme_debug): Use gpgrt_vasprintf instead of
vfprintf to have a more portable format.

--
This fixes crashes on Windows because "%zu" is used which
is not natively supported on Windows but which gpgrt supports.

4 weeks agocore: Fix assuan logger-fd hack for windows
Andre Heinecke [Wed, 27 Mar 2019 15:12:38 +0000 (16:12 +0100)]
core: Fix assuan logger-fd hack for windows

* src/assuan-support.c (my_spawn): Zero is a perfectly fine fd.

4 weeks agocore,w32,glib: Fix build of w32-glib-io.c
Andre Heinecke [Tue, 26 Mar 2019 18:22:44 +0000 (19:22 +0100)]
core,w32,glib: Fix build of w32-glib-io.c

* src/w32-glib-io.c (_gpgme_io_pipe, _gpgme_io_connect): Do not
use TRACE_SUC in a return statement.

4 weeks agoPost release updates.
Werner Koch [Tue, 26 Mar 2019 17:42:26 +0000 (18:42 +0100)]
Post release updates.

--

4 weeks agoRelease GPGME 1.13.0 gpgme-1.13.0
Werner Koch [Tue, 26 Mar 2019 15:56:39 +0000 (16:56 +0100)]
Release GPGME 1.13.0

* configure.ac: Bump LT versions.
                For C to C33/A22/R0.
                For C++ to C15/A9/R0.
                For Qt to C10/A3/R3.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 weeks agocore: Fix a strtoul to strtol
Andre Heinecke [Tue, 26 Mar 2019 15:35:13 +0000 (16:35 +0100)]
core: Fix a strtoul to strtol

* src/assuan-support.c (my_spawn): Fix using strtoul for
a long.

--
This was commented on in129def87b262 and is correct.
It is signed here to better handle cases where an
invalid handle value (-1) would be passed.

4 weeks agocpp: Fix GenCardKeyInteractor and extend it
Andre Heinecke [Tue, 26 Mar 2019 11:02:28 +0000 (12:02 +0100)]
cpp: Fix GenCardKeyInteractor and extend it

* NEWS: Mention interface change.
* lang/cpp/src/gpggencardkeyinteractor.cpp
(GpgGenCardKeyInteractor::setAlgo): New.
(GpgGenCardKeyInteractor::action),
(GpgGenCardKeyInteractor::nextState: Handle new interface.

--
Tested that this workes with the old interface of GnuPG 2.2.5
and the new interface since GnuPG 2.2.6

GnuPG-Bug-Id: T4428

4 weeks agocore, w32: Add hack to translate diag logger-fd
Andre Heinecke [Mon, 25 Mar 2019 13:56:37 +0000 (14:56 +0100)]
core, w32: Add hack to translate diag logger-fd

* src/assuan-support.c (my_spawn): Add hack to
mark the logger fd for w32spawn translation.

--
The w32 spawn code needs to modify argv with
an updated fd that matches the real id
in the spawned process.

It uses spawn_fd_item_s.arg_loc for that.
We hack it here so that the arg_loc is set
for gpgsm's logger-fd without changing
the assuan API.

GnuPG-Bug-Id: T4426

5 weeks agoqt: Handle diagnostic audit log for CMS
Andre Heinecke [Wed, 20 Mar 2019 08:56:38 +0000 (09:56 +0100)]
qt: Handle diagnostic audit log for CMS

* lang/qt/src/threadedjobmixin.cpp(_detail::audit_log_as_html):
Handle CMS audit log.

5 weeks agocore: Support GPGME_AUDITLOG_DIAG for gpgsm.
Werner Koch [Tue, 19 Mar 2019 18:53:22 +0000 (19:53 +0100)]
core: Support GPGME_AUDITLOG_DIAG for gpgsm.

* src/engine-gpgsm.c (struct engine_gpgsm): Add fields diag_cb and
diagnostics.
(close_notify_handler): Close the diag fd on status fd close.
Handle diag close.
(gpgsm_cancel): Handle diag.
(gpgsm_release): Free DIAGNOSTICS.
(gpgsm_new): Support the diag feature.
(start): Set a handler for the diag fd.
(gpgsm_getauditlog): Support GPGME_AUDITLOG_DIAG.
--

Co-authored-by: Andre Heinecke <aheinecke@gnupg.org>
Signed-off-by: Werner Koch <wk@gnupg.org>
6 weeks agocpp: Fix Error::hasSystemError
Andre Heinecke [Wed, 13 Mar 2019 11:00:22 +0000 (12:00 +0100)]
cpp: Fix Error::hasSystemError

* lang/cpp/src/context.cpp (Error::hasSystemError): Invert logic to
do what it says.

--
This is safe because according to codesearch it is only used
in QGpgME

8 weeks agojson: Fix cosmetic error in the repl.
Werner Koch [Thu, 28 Feb 2019 13:05:06 +0000 (14:05 +0100)]
json: Fix cosmetic error in the repl.

* src/gpgme-json.c (native_messaging_repl): Use correct var with sizeof.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
8 weeks agotests: Let run-verify print the de-vs flag.
Werner Koch [Thu, 28 Feb 2019 12:59:04 +0000 (13:59 +0100)]
tests: Let run-verify print the de-vs flag.

* tests/run-verify.c (print_result): Chack is_de_vs.
* tests/run-import.c (main): Fix bad parameter for format string.

Signed-off-by: Werner Koch <wk@gnupg.org>
8 weeks agojson: Limit recursion depth
Andre Heinecke [Wed, 27 Feb 2019 13:27:47 +0000 (14:27 +0100)]
json: Limit recursion depth

* src/cJSON.c (MAX_DEPTH): New. Maximum recursion depth.
(parse_value, parse_array, parse_object): Carry and check
depth argument.
(cJSON_ParseWithOpts): Initialize depth.

--
This fixes a stack overflow if we get weird recursive
json data.

GnuPG-Bug-Id: T4331

2 months agocpp: Add ostream operators for import result
Andre Heinecke [Thu, 21 Feb 2019 12:05:55 +0000 (13:05 +0100)]
cpp: Add ostream operators for import result

* lang/cpp/src/importresult.cpp: Add ostream operators.
* lang/cpp/src/importresult.h: Update accordingly.

2 months agocpp: Make GpgME::Data::toKeys really const
Andre Heinecke [Thu, 21 Feb 2019 12:04:54 +0000 (13:04 +0100)]
cpp: Make GpgME::Data::toKeys really const

* lang/cpp/src/data.cpp (GpgME::Data::toKeys): Rewind afterards.

--
This fixes unexpected behavior that the seek pointer is changed
after calling the const toKeys.

2 months agocore,w32: Fix missing sentinel in dir name builder.
Werner Koch [Tue, 19 Feb 2019 11:11:22 +0000 (12:11 +0100)]
core,w32: Fix missing sentinel in dir name builder.

* src/w32-util.c (_gpgme_get_gpgconf_path): Add NULL top strconcat.
--

Fortunately this is called early and the stack like cleared out so
that we have not seen wrong behaviour until now.  We should really fix
all these annoying HANDLE/int cast warnings and alike so that real
bugs are not drowned by them.

GnuPG-bug-id: 4369
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agotests: Fix memleak in run-threaded
Andre Heinecke [Mon, 11 Feb 2019 14:32:49 +0000 (15:32 +0100)]
tests: Fix memleak in run-threaded

* tests/run-threaded.c (verify): Free msg.

2 months agopython: examples
Ben McGinnes [Sun, 10 Feb 2019 19:34:40 +0000 (06:34 +1100)]
python: examples

* A rather obvious variant of the existing key import examples, except
  directed at Mailvelope's keyserver.
* Yeah, Werner, I know ... but it exists because I used it and there's
  no harm in sharing.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
2 months agopython: docs
Ben McGinnes [Wed, 30 Jan 2019 18:52:59 +0000 (05:52 +1100)]
python: docs

* Version bump in preparation for whenever GPGME 1.13.0 happens.
* Ran the post_installer.py for docs preparation again.

Signed-off-by: Ben McGinnes <ben@adversary.org>
2 months agopython: post installer script
Ben McGinnes [Sun, 27 Jan 2019 05:02:24 +0000 (16:02 +1100)]
python: post installer script

* Removed auto-generated .texi files from doc/src/ so only the
  corrected versions are left.
* Which means now it is complete, but with the initial work to expand
  it with info file generation later.

2 months agopython: post installer docs fix script
Ben McGinnes [Sun, 27 Jan 2019 03:57:53 +0000 (14:57 +1100)]
python: post installer docs fix script

* Moved post_installer.py into the examples/howto/ directory.
* Added instructions for its use to the Python Bindings HOWTO.
* Ran it as intended from the lang/python/ directory in order to both
  prove it works and quickly and easily get the updated howto
  replicated.  Also to fix all those .texi files.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
2 months agojson: Better use gpgme_free
Werner Koch [Fri, 25 Jan 2019 14:20:26 +0000 (15:20 +0100)]
json: Better use gpgme_free

* src/gpgme-json.c (subkey_to_json): here
--

Avoid Windows ugliness of allowing different CRTs in the same
process.

Fixes-commit: 7f2423371964263784252cf839269023b6573bd2
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agojson: Fix minor memory leaks.
Werner Koch [Fri, 25 Jan 2019 12:31:47 +0000 (13:31 +0100)]
json: Fix minor memory leaks.

* src/gpgme-json.c (interactive_repl): Fix memleak.
(subkey_to_json): Ditto
(op_config): Delay init of j_comps to avoid a leak on error.
--

GnuPG-bug-id: 4341, 4342, 4343
Signed-off-by: Werner Koch <wk@gnupg.org>
3 months agobuild: With LD_LIBRARY_PATH defined, use --disable-new-dtags.
NIIBE Yutaka [Wed, 16 Jan 2019 01:59:25 +0000 (10:59 +0900)]
build: With LD_LIBRARY_PATH defined, use --disable-new-dtags.

* configure.ac (LDADD_FOR_TESTS_KLUDGE): New for --disable-new-dtags.
* tests/Makefile.am (LDADD): Use LDADD_FOR_TESTS_KLUDGE.
* lang/cpp/tests/Makefile.am, lang/qt/tests/Makefile.am: Likewise.
* tests/gpg/Makefile.am, tests/gpgsm/Makefile.am: Likewise.
* tests/json/Makefile.am, tests/opassuan/Makefile.am: Likewise.

--

GnuPG-bug-id: 4298
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 months agotests: Add diagnostic example to run-import.c
Andre Heinecke [Tue, 15 Jan 2019 07:36:26 +0000 (08:36 +0100)]
tests: Add diagnostic example to run-import.c

* tests/run-import.c (main): Show diagnostics in verbose mode.

3 months agoqt: Use tofu conflict test keys without expiry
Andre Heinecke [Wed, 9 Jan 2019 07:25:21 +0000 (08:25 +0100)]
qt: Use tofu conflict test keys without expiry

* lang/qt/tests/t-tofuinfo.cpp: Use new test keys without
expiry.

--
The old keys expired on 2019-01-06.

GnuPG-Bug-Id: T3815

3 months agopython docs: post installer
Ben McGinnes [Wed, 2 Jan 2019 00:19:36 +0000 (11:19 +1100)]
python docs: post installer

* Merging post installer script.
* Included ammended Sphinx config file to try to reduce the
  auto-generated EPUB validation failures it produces.

Signed-off-by: Ben McGinnes <ben@adversary.org>
3 months agopython: post installer doc fix script
Ben McGinnes [Wed, 2 Jan 2019 00:06:14 +0000 (11:06 +1100)]
python: post installer doc fix script

* Got rid of the bash bit in the comments.
* Made the final printed instructions far more obvious.

Signed-off-by: Ben McGinnes <ben@adversary.org>
3 months agopython: examples
Ben McGinnes [Wed, 26 Dec 2018 00:01:33 +0000 (11:01 +1100)]
python: examples

* Fixed inter-edit.py so it will actually work now.
* made 3 others executable.
* Fixed the semantics of assuan.py's instructions.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
3 months agopython: examples
Ben McGinnes [Wed, 26 Dec 2018 00:01:33 +0000 (11:01 +1100)]
python: examples

* Fixed inter-edit.py so it will actually work now.
* made 3 others executable.
* Fixed the semantics of assuan.py's instructions.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: docs processing
Ben McGinnes [Mon, 24 Dec 2018 13:18:10 +0000 (00:18 +1100)]
python: docs processing

* Added some EPUB specific config options to the Sphinx config file
  which might help reduce some of Sphinx's more stupid default errors
  with EPUB validation.
* Added lang/python/post_installer.py script for automating the
  generation of .texi and .rst "source" files from the real source
  files written in Org mode.  Includes recreating the Sphinx Makefile
  which is excluded due to the m4 toolchain in parent directories, it
  also handles the rewriting of the reST index file properly and
  rewrites the .texi files so they don't impale themselves on Unicode.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: docs
Ben McGinnes [Fri, 21 Dec 2018 22:39:13 +0000 (09:39 +1100)]
python: docs

* Found a bug in org-mode's export to texinfo function which will
  require either manual modification of each file or a customs sed run
  over the generated files for all updates.
* Manually updated the current files for now, but will need to add
  some post-install processing scripts for future use (I already have
  some of these for my specific setup, they just need to be made a
  little more generic and platform independent for here).

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: groups example
Ben McGinnes [Fri, 21 Dec 2018 10:01:04 +0000 (21:01 +1100)]
python: groups example

* Tightened code a little more.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython docs: house keeping
Ben McGinnes [Mon, 17 Dec 2018 17:01:04 +0000 (04:01 +1100)]
python docs: house keeping

* Dropped the ASCII copyright line, since even MS have conceded their
  battle against Unicode enough to load UTF-8.
* Fixed the drafts section since there will be less need of multiple
  output format testing from next year.

4 months agocore: Silence newer compiler warnings.
Werner Koch [Mon, 17 Dec 2018 15:47:06 +0000 (16:47 +0100)]
core: Silence newer compiler warnings.

* configure.ac: Add -Wno-format-truncation and
  -Wno-sizeof-pointer-div.
* src/b64dec.c (_gpgme_b64dec_proc): Add fallthrough annotation.
* src/cJSON.c (parse_string): Ditto.
* src/gpgme-json.c (main): Ditto.
--

gcc 8 enables a couple of new warnings.  Some of them are useless for
us.  In particular:

  util.h:42:26: warning: division 'sizeof (char *) / sizeof (char)'
  does not compute the number of array elements [-Wsizeof-pointer-div]
  #define DIM(v) (sizeof(v)/sizeof((v)[0])) ^

  trustlist.c:101:22: note:
  in expansion of macro 'DIM' if (strlen (p) == DIM(item->keyid) - 1)

Which is a real standard way to use DIM, here the right hand side is
equivalent to sizeof but nevertheless it is correct.  Yes sir, we know
C.

The format string warnings I have seen were assuming that the time
structure returns valued out of scope - but if the system is that
broken, the s_n_printf catches this.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agopython: howto and examples
Ben McGinnes [Sun, 16 Dec 2018 06:12:21 +0000 (17:12 +1100)]
python: howto and examples

* Tightening up both the documentation and some of the example code.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: examples bugfix
Ben McGinnes [Thu, 13 Dec 2018 18:17:10 +0000 (05:17 +1100)]
python: examples bugfix

* Fixed a bug in the ProtonMail importers (pmkey-*.py) where multiple
  keys found for a username would always result in the last email
  address checked being returned in the printed output for all located
  keys.

4 months agopython: new example script
Ben McGinnes [Wed, 12 Dec 2018 17:54:51 +0000 (04:54 +1100)]
python: new example script

* Though Keybase really should not be encouraged due to
  disengenuosness and FUD emanating from that souce, this new script
  will obtain a key hosted on that site and import it when supplied
  with the keybase username.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: what's new summary
Ben McGinnes [Wed, 12 Dec 2018 12:18:22 +0000 (23:18 +1100)]
python: what's new summary

* Added a little more detail to the what's new section.

4 months agopython: advanced howto example
Ben McGinnes [Wed, 12 Dec 2018 12:05:50 +0000 (23:05 +1100)]
python: advanced howto example

* Added Cython requirement to this advanced use case.

4 months agopython: howto examples equirements
Ben McGinnes [Wed, 12 Dec 2018 12:01:16 +0000 (23:01 +1100)]
python: howto examples equirements

* Added small requirements.txt file for additional modules not in the
  standard python library and not including the bindings themselves
  and not including Cython, which is for more advanced examples.

4 months agopython: hkp key importer
Ben McGinnes [Mon, 10 Dec 2018 22:55:15 +0000 (09:55 +1100)]
python: hkp key importer

* Tweaked it slightly to avoid repetition of key searches when there
  is only one search pattern to check (i.e. usually a single key ID or
  fingerprint).

4 months agopython: HKP search and import updates
Ben McGinnes [Mon, 10 Dec 2018 20:14:28 +0000 (07:14 +1100)]
python: HKP search and import updates

* Tweaked the code again so that it can also handle the cases where
  someone has included a hexadecimal string in their user ID.
* Updated the HOWTO to match.
* Exported to .rst and .texi.

4 months agopython: key import via HKP example
Ben McGinnes [Mon, 10 Dec 2018 17:41:03 +0000 (04:41 +1100)]
python: key import via HKP example

* Fixed the logic used to search for any given pattern.
* Added a sensible method of checking whether a pattern is a key ID or
  fingerprint.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: docs updates
Ben McGinnes [Mon, 10 Dec 2018 05:05:14 +0000 (16:05 +1100)]
python: docs updates

* Multiple updates, expanding on the Windows installation issues.
* Also adding to the new maintenance mode reference document.
* Includes content relating to the resolution of T4271 and T4191.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agocore: Fix ERR_INV_ARG check in genkey_start
Andre Heinecke [Fri, 7 Dec 2018 09:43:58 +0000 (10:43 +0100)]
core: Fix ERR_INV_ARG check in genkey_start

* src/genkey.c (gpgme_op_genkey_start): Fix check for
parms.

--
This fixes a regression introduced by:
174af15725d4989a840ff3098996cc8a0568f724

So that the error was triggered by usual args.

GnuPG-Bug-Id: T4265

4 months agoMerge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Wed, 5 Dec 2018 14:53:08 +0000 (01:53 +1100)]
Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme

4 months agopython: examples
Ben McGinnes [Wed, 5 Dec 2018 14:50:52 +0000 (01:50 +1100)]
python: examples

* cut some of then poor len usage.

4 months agopython: overhaul logic of Context.decrypt()
Daniel Kahn Gillmor [Tue, 4 Dec 2018 17:44:35 +0000 (20:44 +0300)]
python: overhaul logic of Context.decrypt()

* lang/python/src/core.py (Context.decrypt): simplify and clarify the
logic behind handling verify=False.
* lang/python/tests/t-decrypt.py: ensure that we test verify=False

--

The function-internal variables were pretty unclear to the reader, and
the logic caused pretty nasty breakage when verify=False.

GnuPG-Bug-Id: 4271
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: ctx.decrypt() has problematic error handling
Daniel Kahn Gillmor [Tue, 4 Dec 2018 17:29:40 +0000 (20:29 +0300)]
python: ctx.decrypt() has problematic error handling

* lang/python/src/core.py (Context.decrypt): document odd
error-handling behavior as a potential problem to be addressed.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: Clarify the meaning of ctx.decrypt(verify=[])
Daniel Kahn Gillmor [Tue, 4 Dec 2018 17:27:15 +0000 (20:27 +0300)]
python: Clarify the meaning of ctx.decrypt(verify=[])

* lang/python/src/core.py (Context.decrypt): docstring clarification
of what it means to pass an empty list to the verify argument.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: gpg.Context.decrypt verify_sigs and sink_result are bools
Daniel Kahn Gillmor [Wed, 28 Nov 2018 06:51:24 +0000 (01:51 -0500)]
python: gpg.Context.decrypt verify_sigs and sink_result are bools

Both of these function-internal variables are never used for anything
other than a binary state.  Implement them as the booleans they are.
Otherwise, casual readers of the code might think that they're
supposed to represent something other than a flag (e.g. "verify_sigs"
could mean "the signatures to verify", and "sink_result" could mean
"the place where we sink the result").

Signed-Off-By: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: clarify documentation for verify argument for Context.decrypt()
Daniel Kahn Gillmor [Wed, 28 Nov 2018 06:47:20 +0000 (01:47 -0500)]
python: clarify documentation for verify argument for Context.decrypt()

It's easy to miss that verify can take a list of keys.  Make it more
obvious to the average python dev who reads docstrings.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: simplify Context.decrypt()
Daniel Kahn Gillmor [Wed, 28 Nov 2018 06:22:13 +0000 (01:22 -0500)]
python: simplify Context.decrypt()

In the course of trying to address https://dev.gnupg.org/T4271, i
discovered that gpg.Context.decrypt() has a bit of superfluous code.
This changeset is intended to simplify the code without making any
functional changes.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4 months agopython: windows c and cython
Ben McGinnes [Tue, 4 Dec 2018 23:51:59 +0000 (10:51 +1100)]
python: windows c and cython

* added warning that he Windows C runtime issues will also affect use
  with Cython and that relying on binary installers would remove that
  possible use case.

4 months agopython: sphinx modification
Ben McGinnes [Tue, 4 Dec 2018 22:31:10 +0000 (09:31 +1100)]
python: sphinx modification

* The make.bat file incorrectly triggers the trailing whitespace check
  in the git repo (it doesn't actually have any trailing whitespace,
  but triggers the error on every line).
* Will need to add a script to handle future org-mode conversions of
  the index page anyway, so will get that script to deal with this
  problem too by generating the make.bat file if the platform is
  detected as Windows.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: Sphinx support
Ben McGinnes [Tue, 4 Dec 2018 22:17:31 +0000 (09:17 +1100)]
python: Sphinx support

* Added framework from sphinx-quickstart to lang/python/doc/rst/ so
  that Python developers already using Sphinx can use the generated
  reST files with existing documentation systems.
* Note that when generating source files from Org-mode, the index page
  will require manual intervention to match the Sphinx requirements.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agoMerge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Tue, 4 Dec 2018 21:49:41 +0000 (08:49 +1100)]
Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme

4 months agopython: docs update
Ben McGinnes [Tue, 4 Dec 2018 21:42:08 +0000 (08:42 +1100)]
python: docs update

* Expanded the section on issues with Windows installations, with
  greater detail of which versions of Visual Studio are needed
  depending on which version of CPython is to be used.
* Included a recommendation which is a bit harsh without being totally
  prickish.
* Updated all files to not link to author's key or related data in
  order to make them all consistent with the changes in commit
  649b19688132dd315e361c0f5b63ba6d8f45996d.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agobuild: Remove --with-*-prefix, which is no need any more.
NIIBE Yutaka [Tue, 4 Dec 2018 03:35:41 +0000 (12:35 +0900)]
build: Remove --with-*-prefix, which is no need any more.

* autogen.rc (configure_opts): Remove --with-*-prefix.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
4 months agoqt,cpp: Consistently use nullptr and override
Andre Heinecke [Mon, 3 Dec 2018 11:20:33 +0000 (12:20 +0100)]
qt,cpp: Consistently use nullptr and override

* lang/cpp/src/Makefile.am, lang/qt/src/Makefile.am (AM_CPPFLAGS):
Add suggest-override and zero-as-null-pointer-constant warnings.

* lang/cpp/src/*, lang/qt/src/*: Consistenly use nullptr and override.

--
This was especially important for the headers so that downstream
users of GpgME++ or QGpgME do not get flooded by warnings if
they have these warnings enabled.

It also improves compiler errors/warnings in case of accidental
mistakes.

4 months agodoc: Minor comment cleanups.
Werner Koch [Mon, 3 Dec 2018 09:40:52 +0000 (10:40 +0100)]
doc: Minor comment cleanups.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agopython: documentation fixes
Ben McGinnes [Fri, 30 Nov 2018 21:15:43 +0000 (08:15 +1100)]
python: documentation fixes

* Typographic and whitespace error correction pertaining to the
  previous update.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agopython: documentation
Ben McGinnes [Fri, 30 Nov 2018 20:45:50 +0000 (07:45 +1100)]
python: documentation

* Added long description to setup.py.in.
* Added maintenance mode details with clarification for what type of
  things would be a bug as far as MM is concerned and what wouldn't
  be.
** Includes a not too subtle hint directed towards the donations page.
* Miscellaneous tightening of documentation.

Signed-off-by: Ben McGinnes <ben@adversary.org>
4 months agotests, json: Make them run on debian stable
Andre Heinecke [Wed, 28 Nov 2018 09:44:17 +0000 (10:44 +0100)]
tests, json: Make them run on debian stable

* tests/json/t-json.c (main): Relax version check a bit.

4 months agopython docs: checking key signatures
Ben McGinnes [Mon, 26 Nov 2018 02:19:34 +0000 (13:19 +1100)]
python docs: checking key signatures

* Added instructions for checking key certifications or key
  signatures (depending on preferred terminology).
* Added pendulum module to recommended installations, but not to
  requirements.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
5 months agopython: docs update
Ben McGinnes [Thu, 22 Nov 2018 09:00:12 +0000 (20:00 +1100)]
python: docs update

* Added documentation for the new methods added to gpgme.version.
* Removed the Flask based advanced use case from the what-is-new
  section as that type of code will not be added here.

5 months agopython: version as integers
Ben McGinnes [Thu, 22 Nov 2018 07:00:22 +0000 (18:00 +1100)]
python: version as integers

* lang/python/version.py.in: added gpg.version.versionintlist
* If gpg.version.versionintlist[2] ever returns -1 then there's a
  serious problem with the build and it should be lodged as a bug if
  it's repeatable.  Seeing this should never happen, but checking for
  it is better than not doing so.

5 months agocore: Fix format string errors in w32-io.c and use of TRACE_SUC.
Werner Koch [Mon, 19 Nov 2018 11:49:40 +0000 (12:49 +0100)]
core: Fix format string errors in w32-io.c and use of TRACE_SUC.

* src/w32-io.c: Fix use of TRACE_SUC.  Fix some format strung errors.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agopython: import type
Ben McGinnes [Mon, 19 Nov 2018 10:38:50 +0000 (21:38 +1100)]
python: import type

* Fixed bug T4242 and tested that dropping "Import" in favour of
  "import_type" does indeed work just fine.

Tested-by: Ben McGinnes <ben@adversary.org>
Signed-off-by: Ben McGinnes <ben@adversary.org>
5 months agopython: import constant
Ben McGinnes [Mon, 19 Nov 2018 10:19:42 +0000 (21:19 +1100)]
python: import constant

* lang/python/src/constants/__init__.py: dropped use of Import
  capitalisation and renamed lang/python/src/constants/import.py to
  lang/python/src/constants/import_type.py to address bug T4242.
* lang/python/doc/src/gpgme-python-howto: minor docs updates.

5 months agocore: Protect the trace macros for fun and profit.
Werner Koch [Fri, 16 Nov 2018 17:17:22 +0000 (18:17 +0100)]
core: Protect the trace macros for fun and profit.

* src/debug.h: Protect macros using.
(_trace_err, _trace_sysres, _trace_syserr): New helper inline
functions.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agocore: Fix a LF problem in the new debug fucntion.
Werner Koch [Fri, 16 Nov 2018 17:15:22 +0000 (18:15 +0100)]
core: Fix a LF problem in the new debug fucntion.

* src/debug.c (_gpgme_debug): Print a LF for an empty FORMAT unless we
are in legacy mode.

5 months agocore: Fix format string errors in trace macros
Werner Koch [Fri, 16 Nov 2018 15:57:09 +0000 (16:57 +0100)]
core: Fix format string errors in trace macros

--

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agocore: Remove old debug helper function
Werner Koch [Fri, 16 Nov 2018 15:39:26 +0000 (16:39 +0100)]
core: Remove old debug helper function

* src/debug.c (_gpgme_debug): Remove.
(_gpgme_debugf): Rename to _gpgme_debug.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agocore: Simplify the trace maros by using variadics.
Werner Koch [Fri, 16 Nov 2018 15:25:49 +0000 (16:25 +0100)]
core: Simplify the trace maros by using variadics.

* src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros
and remove the TRACE_BEG1 et al.  Change all users to always pass a
format string.
(TRACE): Ditto.
* src/debug.c (_gpgme_debugf): New.
* configure.ac <GCC>: Add -Wno-format-zero-length.
--

This makes it easier for use to enable format checks.  The zero-length
format is required to allow for an empty format due to the comman
problematic of __VA_ARGS__.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agoAdd SPDX identifiers to most source files
Werner Koch [Fri, 16 Nov 2018 12:27:33 +0000 (13:27 +0100)]
Add SPDX identifiers to most source files

--

Signed-off-by: Werner Koch <wk@gnupg.org>
5 months agotests: Add run-threaded for multithread tests
Andre Heinecke [Thu, 15 Nov 2018 10:57:27 +0000 (11:57 +0100)]
tests: Add run-threaded for multithread tests

* tests/Makefile.am (run-threaded): Add.
* tests/run-threaded.c: New.

--
This test is intended to help detect race conditions
or other multithread problems. It can also be used
to put the whole GnuPG system under extreme load.

5 months agotests,json: Clean openpgp-revocs.d aheinecke/json-test
Andre Heinecke [Thu, 15 Nov 2018 09:33:35 +0000 (10:33 +0100)]
tests,json: Clean openpgp-revocs.d

* tests/json/clean-local: Remove revocs.d

5 months agotests,json: Move version check into t-json
Andre Heinecke [Thu, 15 Nov 2018 09:31:22 +0000 (10:31 +0100)]
tests,json: Move version check into t-json

* tests/gpg/t-support.h (check_gpg_version, compare_versions),
(parse_version_string, parse_version_number): Remove version
check code.
* tests/json/t-json.c (check_gpg_version, compare_versions),
(parse_version_string, parse_version_number): Add.
--

t-support header was not a good place for this. It should
go into a library e.g. gpgrt in the future. For now we
can keep it close to where it is needed.

5 months agotests,json: Add sig-notations test
Andre Heinecke [Wed, 14 Nov 2018 16:56:23 +0000 (17:56 +0100)]
tests,json: Add sig-notations test

* tests/json/t-sig-notations.in.json,
tests/json/t-sig-notations.out.json: New
* tests/json/Makefile.am (EXTRA_DIST): Add files.
* tests/json/t-json.c: Register it.

5 months agotests,json: Fix distcheck
Andre Heinecke [Wed, 14 Nov 2018 16:21:24 +0000 (17:21 +0100)]
tests,json: Fix distcheck

* tests/json/Makefile.am (EXTRA_DIST): Add inital and final scripts.
(t_json_SOURCES): Don't use cJSON.o as source.

5 months agotests,json: Add more tests
Andre Heinecke [Wed, 14 Nov 2018 16:05:25 +0000 (17:05 +0100)]
tests,json: Add more tests

* t-config-opt.in.json,
 t-config-opt.out.json,
 t-import.in.json,
 t-import.out.json,
 t-sign.in.json,
 t-sign.out.json: New.
--
These should actually have been in a previous commit as
they are already registered.

5 months agotests,json: Add missing files and chunking test
Andre Heinecke [Wed, 14 Nov 2018 14:55:02 +0000 (15:55 +0100)]
tests,json: Add missing files and chunking test

* tests/json/Makefile.am, tests/json/final.test,
tests/json/initial.test: New.
* tests/json/t-chunking.in.json, tests/json/t-chunking.out.json:
New test.
* tests/json/t-json.c: Register new test.

--
Oops..

5 months agotests,json: Fix match if the first child differs
Andre Heinecke [Wed, 14 Nov 2018 14:17:18 +0000 (15:17 +0100)]
tests,json: Fix match if the first child differs

* tests/json/t-json.c (test_contains): Try all siblings of
the haystack child.

--
This fixes the case where we don't match against the
first child because the order might have changed or
a new element was inserted at the top. Then we
have to try out also all the siblings.

5 months agotests,json: Add the bulk of tests
Andre Heinecke [Wed, 14 Nov 2018 14:15:21 +0000 (15:15 +0100)]
tests,json: Add the bulk of tests

* t-json.c (tests): Register new tests.
* t-createkey.in.json,
  t-createkey.out.json,
  t-decrypt-verify.in.json,
  t-decrypt-verify.out.json,
  t-decrypt.in.json,
  t-decrypt.out.json,
  t-delete.in.json,
  t-delete.out.json,
  t-encrypt-sign.in.json,
  t-encrypt-sign.out.json,
  t-encrypt.in.json,
  t-encrypt.out.json,
  t-export-secret-info.in.json,
  t-export-secret-info.out.json,
  t-export.in.json,
  t-export.out.json,
  t-json.c,
  t-keylist-secret.in.json,
  t-keylist-secret.out.json,
  t-keylist.in.json,
  t-keylist.out.json,
  t-verify.in.json,
  t-verify.out.json,
  t-version.in.json,
  t-version.out.json: New.

--
Except for help and getmore there is now a test for each command.

5 months agotests,json: Add wildcard string matching
Andre Heinecke [Wed, 14 Nov 2018 13:57:40 +0000 (14:57 +0100)]
tests,json: Add wildcard string matching

* tests/json/t-json.c (test_contains): When searching for "*" accept
every string.

--
This allows it to write tests that check for the existence of
a string value but don't care about the contents. E.g. for Data.

5 months agotests,json: Skip tests for older GnuPG versions
Andre Heinecke [Wed, 14 Nov 2018 13:55:09 +0000 (14:55 +0100)]
tests,json: Skip tests for older GnuPG versions

* tests/json/t-json.c (main): Skip if version is not at least
2.2.0

--
In the past new tests often failed when a modern GPGME was
used with old GnuPG's.
This should avoid the hassle for packagers without the
requirement that we test against old versions.

5 months agotests,json: Suffix .json to test pattern
Andre Heinecke [Wed, 14 Nov 2018 13:53:28 +0000 (14:53 +0100)]
tests,json: Suffix .json to test pattern

* tests/json/t-config.in, tests/json/t-config.out: Renamed.
* t-json.c (run_test): Use new naming pattern.

5 months agotests,gpg: Add version check hlp to t-support
Andre Heinecke [Wed, 14 Nov 2018 13:50:57 +0000 (14:50 +0100)]
tests,gpg: Add version check hlp to t-support

* t-support.h (parse_version_number, parse_version_string)
(compare_versions): New. Copy&Paste from src/version.c
(check_gpg_version): New helper to check for a gpg version.

--
This should make it easier to write tests that e.g.
rely on modern gnupg features.

5 months agotests,json: Improve verbose mode and add verbose 2
Andre Heinecke [Wed, 14 Nov 2018 12:14:52 +0000 (13:14 +0100)]
tests,json: Improve verbose mode and add verbose 2

* tests/json/t-json.c (main): Handle multiple verbose args.
(test-contains): Improve verbose output

5 months agotests,json: Fix and improve t-json
Andre Heinecke [Wed, 14 Nov 2018 12:05:36 +0000 (13:05 +0100)]
tests,json: Fix and improve t-json

* tests/json/t-json.c (run_test): Terminate argv array correctly.
(run_test): Note and handle empty response.