gpgme.git
7 months 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

7 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.

7 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.

7 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>
8 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.

8 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>
8 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>
8 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.

8 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>
8 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>
8 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>
8 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>
8 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.

9 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

9 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>
9 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>
9 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>
9 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>
9 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>
9 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>
9 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>
9 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.

9 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>
9 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>
10 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.

10 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>
10 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.

10 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.

10 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.

10 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).

10 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.

10 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>
10 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>
10 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

10 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

10 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.

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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.

10 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>
10 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>
10 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

10 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>
10 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>
10 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.

10 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>
10 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>
10 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>
10 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.

10 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>
10 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.

10 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.

10 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>
10 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>
10 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.

10 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>
10 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.

10 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>
10 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>
10 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>
10 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>
10 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.

10 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

10 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.

11 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.

11 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.

11 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.

11 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..

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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

11 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.

11 months agotests: Add json testrunner
Andre Heinecke [Wed, 14 Nov 2018 10:47:59 +0000 (11:47 +0100)]
tests: Add json testrunner

* configure.ac: Configure makefile.
* tests/Makefile.am: Run json tests if gpg tests are run.
* tests/json/t-json.c: New testrunner for json tests.
* tests/json/t-config.in, tests/json/t-config.out: First test.
--
The idea of this test runner is that it only looks for parts
in the output. This should allow it to write robust tests
that check for the basics in the output but don't fail when
the output is extended or slightly changed.

11 months agobuild: Update gpg-error.m4 and libassuan.m4.
NIIBE Yutaka [Tue, 13 Nov 2018 02:44:24 +0000 (11:44 +0900)]
build: Update gpg-error.m4 and libassuan.m4.

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

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agoFix the previous commit.
NIIBE Yutaka [Mon, 12 Nov 2018 10:11:49 +0000 (19:11 +0900)]
Fix the previous commit.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agobuild: Make gpgme.m4 use gpgrt-config with *.pc.
NIIBE Yutaka [Mon, 12 Nov 2018 01:01:16 +0000 (10:01 +0900)]
build: Make gpgme.m4 use gpgrt-config with *.pc.

* src/gpgme.m4 (_AM_PATH_GPGME_CONFIG): Use gpgrt-config with gpgme.pc
when possible.
(AM_PATH_GPGME_GLIB): Likewise with gpgme-glib.pc.

--

Keeping AM_PATH_GPGME_PTHREAD, as is, untouched.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agobuild: Provide gpgme-glib.pc too.
NIIBE Yutaka [Mon, 12 Nov 2018 00:59:05 +0000 (09:59 +0900)]
build: Provide gpgme-glib.pc too.

* src/gpgme-glib.pc.in: New.
* src/gpgme.pc.in (avail_lang): Remove.

--

Provide gpgme-glib.pc for gpgme-glib library.  The avial_lang
information is no use because *.pc is for C.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agobuild: Provide gpgme.pc, generated by configure.
NIIBE Yutaka [Mon, 12 Nov 2018 00:03:49 +0000 (09:03 +0900)]
build: Provide gpgme.pc, generated by configure.

* configure.ac: Generate src/gpgme.pc.
* src/Makefile.am (pkgconfigdir, pkgconfig_DATA): New.
(EXTRA_DIST): Add gpgme.pc.in.
* src/gpgme.pc.in: New.
* src/gpgme-config.in: Use variables.

--

Some usages of gpgme-config is not compatible to pkg-config style;
The --glib option and --thread option which affect the output
by --cflags or --libs are not supported by gpgme.pc.

gpgme-config's embedding information for gpg-error and libassuan at
the build time of gpgme is considered inflexible than pkg-config
style.  It is now handled by dependency of gpgme.pc (Requires field).

To use gpgme.pc, newer libgpg-error (>= 1.33) and libassuan (>= 2.5.3)
are required, which provide gpg-error.pc and libassuan.pc respectively.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agospelling: fix misspellings
Daniel Kahn Gillmor [Thu, 8 Nov 2018 05:34:27 +0000 (12:34 +0700)]
spelling: fix misspellings

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 months agodocs: python bindings
Ben McGinnes [Tue, 6 Nov 2018 05:22:50 +0000 (16:22 +1100)]
docs: python bindings

* Continued restructuring as part of moving beyond mere;y the HOWTO
  file.
* Generated the alternative source files for reST and Texinfo.
* Fixed some errors and updated links after moving the what's new
  section to two new files (yes, two).

11 months agopython examples: another importer
Ben McGinnes [Tue, 6 Nov 2018 03:58:15 +0000 (14:58 +1100)]
python examples: another importer

* Fixed a similar type of bug with the non-protonmail importer.

11 months agopython examples: protonmail hkp scripts
Ben McGinnes [Tue, 6 Nov 2018 03:11:01 +0000 (14:11 +1100)]
python examples: protonmail hkp scripts

* fixed a bug in the import try statement for both versions.

11 months agogpg: Avoid error diagnostics with --override-session-key.
Werner Koch [Mon, 5 Nov 2018 09:30:27 +0000 (10:30 +0100)]
gpg: Avoid error diagnostics with --override-session-key.

* src/engine-gpg.c (gpg_decrypt): Add --no-keyring.
--

GnuPG-bug-id: 3464
Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agodocs: typo
Ben McGinnes [Sat, 3 Nov 2018 07:12:25 +0000 (18:12 +1100)]
docs: typo

* lang/python/doc/src/gpgme-python-howto: s/Revokinging/Revoking/g

11 months agow32: Fix a few compiler warnings.
Werner Koch [Fri, 2 Nov 2018 11:54:22 +0000 (12:54 +0100)]
w32: Fix a few compiler warnings.

* src/debug.h (TRACE_SYSERR_NR): New.
* src/w32-io.c: Fix compiler warnings.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Log all errors from CloseHandle and WFSO in w32-io.
Werner Koch [Fri, 2 Nov 2018 11:28:17 +0000 (12:28 +0100)]
w32: Log all errors from CloseHandle and WFSO in w32-io.

* src/w32-io.c (close_handle, _close_handle): New macro and function;
use in place of all CloseHandle calls.
(wait_for_single_object, _wait_for_single_object): Likewise.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Don't use CloseHandle on an arbitrary integer.
Werner Koch [Fri, 2 Nov 2018 10:26:19 +0000 (11:26 +0100)]
w32: Don't use CloseHandle on an arbitrary integer.

* src/assuan-support.c (my_waitpid): Do not close the PID = it is not
a handle.
--

At some time in the distant past we might have used the process object
as pid which obviously required a close.  However this was changed and
so what we did here was to close an arbitrary handle (one which
matches the pid).

GnuPG-bug-id: 4237
Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Revamp the closing of system objects.
Werner Koch [Fri, 2 Nov 2018 08:14:07 +0000 (09:14 +0100)]
w32: Revamp the closing of system objects.

* src/w32-io.c (hddesc_t): New.
(reader_context_s, writer_context_s): Replace file_sock and file_hd by
the hddesc_t hdd.
(fd_table): Ditto.  Add want_reader and want_writer.
(hddesc_lock): New lock variable.
(new_hddesc, ref_hddesc): New.
(release_hddesc): New.
(reader, writer): Call release_hddesc.
(create_reader, create_writer): Change for new hddesc scheme.
(destroy_reader, destroy_writer): Replace closing by a call to
release_hddesc.
(_gpgme_io_pipe): Change for new hddesc scheme.
(_gpgme_io_close): Ditto.
(_gpgme_io_dup): Ditto.  Use want_reader and want_writer.
(_gpgme_io_socket): Change for new hddesc scheme.
--

GnuPG-bug-id: 4237
Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agocore: Print a dump of the I/O data only at level 8.
Werner Koch [Fri, 2 Nov 2018 08:03:43 +0000 (09:03 +0100)]
core: Print a dump of the I/O data only at level 8.

* src/debug.h (TRACE_SUC3): New.
(TRACE_LOGBUFX): New.
* src/posix-io.c: Use TRACE_LOGBUFX instead of TRACE_LOGBUF.
* src/w32-glib-io.c: Ditto.
--

This will also be changed for w32-io as part of another commit.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Fix and improve CancelSynchronousIo use.
Werner Koch [Fri, 2 Nov 2018 07:47:44 +0000 (08:47 +0100)]
w32: Fix and improve CancelSynchronousIo use.

* src/w32-util.c (_gpgme_w32_cancel_synchronous_io): Fix name of DLL
and print trace info only on error.
--

Fixes-commit: 63ba09b541dabbe838253926896e721cb9be564a
Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Use CancelSynchronousIo in destroy_reader.
Werner Koch [Thu, 1 Nov 2018 08:55:24 +0000 (09:55 +0100)]
w32: Use CancelSynchronousIo in destroy_reader.

* src/w32-util.c (_gpgme_w32_cancel_synchronous_io): New.
* src/w32-io.c (destroy_reader): Use it here.
--

This has not been tested but should on Vista and later help to fix a
possible hang.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agow32: Merge all the object tables of w32-io into one.
Werner Koch [Thu, 1 Nov 2018 08:53:48 +0000 (09:53 +0100)]
w32: Merge all the object tables of w32-io into one.

* src/w32-io.c (fd_table_size): New.  Used in most places instead of
the MAX_SLAFD constant.
(reader_table, writer_table, notify_table): Merge them into ...
(fd_table): this table.  Chnage all affected code to take just one
lock.

Signed-off-by: Werner Koch <wk@gnupg.org>