gpgme.git
4 months agojs: Error handling for browser errors
Maximilian Krambach [Wed, 19 Jun 2019 10:57:20 +0000 (12:57 +0200)]
js: Error handling for browser errors

--

* Connection.js
  - Add some meaningful nativeMessaging feedback for failing
    communication due to misconfiguration or other browser-originated
    fails
  - add an "isDisconnected" property
  - "isNativeHostUnknown" tries to match browser's feedback string if
    the browser does not find gpgme-json
* init.js
  - initialization will now reject with a more meaningful error if the
    configuration is not set up or other browser-based errors
    (chrome.runtime.lastError) are present. This should speed up
    the normal initialization (not having to waiting for a timeout
    any more in case of improper setup)
* errors.js
  - CONN_NATIVEMESSAGE: New error that passes the browser's
    nativeMessaging error
  - CONN_NO_CONFIG: native messaging error indicating that the
    nativeMessaging host was not set up properly
* unittests.js:
  - added the "isDisconnected" property to the startup tests
  - added tests for proper behavior of connection checks

4 months agoPost release updates
Werner Koch [Thu, 13 Jun 2019 13:35:58 +0000 (15:35 +0200)]
Post release updates

--

4 months agoRelease 1.13.1 gpgme-1.13.1
Werner Koch [Thu, 13 Jun 2019 07:00:38 +0000 (09:00 +0200)]
Release 1.13.1

* configure.ac: Bump LT versions to c=C33/A22/R1 cpp=C16/A10/R0
qt=C10/A3/R4.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agopython: Fix regression in t-decrypt-verify test.
Werner Koch [Thu, 13 Jun 2019 13:17:49 +0000 (15:17 +0200)]
python: Fix regression in t-decrypt-verify test.

* lang/python/tests/t-decrypt-verify.py: Comment recent changes.
--

Fixes-commit: bd2d282e572b5d02669238c9e087259b85638477
GnuPG-bug-id: 4276

4 months agopython: Set a default-key into gpg.conf for the tests.
Werner Koch [Thu, 13 Jun 2019 08:15:45 +0000 (10:15 +0200)]
python: Set a default-key into gpg.conf for the tests.

* lang/python/tests/Makefile.am (gpg.conf): Set a default key.

--

It seems we need to set a default key because at least t-sign.py does
not specify the key to use and we do not want to rely on the order of
keys in the keyring.

Also
Fixes-commit: f3ca2c9ce9fd4a03e293065f10b92589a7e642d6

gpg 2.0 is end-of-life and we don't need these extra options anymore.
In fact they for the use of some gpg version and don't use the version
gpgconf knows about.  This also aligns the python tests to what we use
for the C test suite.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: At debug levels up to 9 print only an ascii dump.
Werner Koch [Wed, 12 Jun 2019 10:31:44 +0000 (12:31 +0200)]
core: At debug levels up to 9 print only an ascii dump.

* src/debug.c (_gpgme_debug_buffer): Switch between two output
formats.
--

The new format is much more practical than the bunch of hex digits
followed by just 16 ascii chars.  To get the old behaviour use a debug
level of 10.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agotests: Minor fix to run-threaded.c.
Werner Koch [Thu, 6 Jun 2019 16:59:16 +0000 (18:59 +0200)]
tests: Minor fix to run-threaded.c.

* tests/run-threaded.c (random_data_close): Correct FD test.
--

An invalid DS is -1 and not 0; this fix is for correctness and does
not chnage anything in the real world.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: Add commented debug helper to posix-io.c.
Werner Koch [Thu, 6 Jun 2019 16:55:57 +0000 (18:55 +0200)]
core: Add commented debug helper to posix-io.c.

* src/posix-io.c (_gpgme_is_fd_valid): New out-commented function.
--

This code is sometimes useful to track down invalid file descriptors.
We keep it commented in the code.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: Fix error return value of _gpgme_run_io_cb.
Werner Koch [Thu, 6 Jun 2019 16:53:23 +0000 (18:53 +0200)]
core: Fix error return value of _gpgme_run_io_cb.

* src/wait.c (_gpgme_run_io_cb): Fix return code.
--

The function needs to return an gpg_error_t and not ERRNO.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agotests: Add option "allow-del" to run-threaded
Andre Heinecke [Thu, 6 Jun 2019 07:19:02 +0000 (09:19 +0200)]
tests: Add option "allow-del" to run-threaded

* tests/run-threaded.c (main): Handle allow-del.
(allow-del): New. Variable to allow deletion of keys.
(import): Delete key after import if allow-del is set.
(delete_impres): Delete keys from an import result.
(delete_fpr): Delete a key by fingerprint.

--
This is intended to test write access and locking of the
keyring by repeatedly importing and deleting pubkeys.

It is an option because it might cause keyring corruption
etc. so it should be explicitly enabled.

4 months agotests: Implement import in run-threaded
Andre Heinecke [Wed, 5 Jun 2019 15:23:59 +0000 (17:23 +0200)]
tests: Implement import in run-threaded

* tests/run-threaded.c (import): New.
(do_data_op): Call it.

4 months agocore: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.
Werner Koch [Wed, 5 Jun 2019 14:37:59 +0000 (16:37 +0200)]
core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.

* src/debug.c (_gpgme_debug): Take better care of NULL userinfo.
(_gpgme_debug_end): Rework.
(_trace_sysres): Print ERRNO and not the supplied RES.
--

The TRACE_SYSRES patch fixes
Regression-due-to: 7a1e7006d06fdbab86ea79a197c316744b09d933

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agotests: Use synced output for error in run-threaded
Andre Heinecke [Wed, 5 Jun 2019 14:14:38 +0000 (16:14 +0200)]
tests: Use synced output for error in run-threaded

* tests/run-threaded.c (do_data_op): Use synced out macro.

4 months agotests: Avoid variable named the same as a macro
Andre Heinecke [Wed, 5 Jun 2019 14:08:54 +0000 (16:08 +0200)]
tests: Avoid variable named the same as a macro

* tests/run-threaded.c (decrypt, verify): Don't use a variable name
that is also a macro.

--
It just looks confusing and strange at first glance.

4 months agotests,w32: Fix thread creation in run-threaded
Andre Heinecke [Wed, 5 Jun 2019 14:07:43 +0000 (16:07 +0200)]
tests,w32: Fix thread creation in run-threaded

* tests/run-threaded.c (create_thread): Check proper return
value and not return value of CloseHandle.

4 months agocore: Improve the debug messages even more.
Werner Koch [Wed, 5 Jun 2019 13:48:33 +0000 (15:48 +0200)]
core: Improve the debug messages even more.

* src/debug.c (_gpgme_debug): Add arg LINE.  Chnage all callers.
(_gpgme_debug_begin): Remove.
* src/debug.h (TRACE_SEQ): Use the LINE arg of _gpgme_debug.
--

This includes chnages to always print fds in decimal as weel as
tweaking the TARCE_SEQ function to make use of the new machinery.

The standard 'tag' can now always be NULL and no tag information will
be printed.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: Avoid explicit locks in the debug code.
Werner Koch [Wed, 5 Jun 2019 11:10:52 +0000 (13:10 +0200)]
core: Avoid explicit locks in the debug code.

* src/debug.c (debug_lock): Remove.  Also remove all users.
(_gpgme_debug): Use gpgrt_bsprintf to prepare the output and finally
print using standard fprintf.  Reformat to prefix to be narrower.
--

Note that the locks are now implicitly done using the systems stdio.

The threadid is now printed with 4 digits in hex and thus without the
angle brackets and the 0x.  However it is still a hex number even if it
may look like an octal number.  The hex letters are uppercase to make
searching in locks easier iff the threadid happens to have a letter in
it.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agojson: Print "nan", "-inf", "inf" if needed.
Werner Koch [Tue, 4 Jun 2019 08:56:48 +0000 (10:56 +0200)]
json: Print "nan", "-inf", "inf" if needed.

* src/cJSON.c (print_number): Print NaN and INF.
--

GnuPG-bug-id: 4328
Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agojson: Improve handling of large exponents in the JSON parsor.
Werner Koch [Tue, 4 Jun 2019 08:42:40 +0000 (10:42 +0200)]
json: Improve handling of large exponents in the JSON parsor.

* src/cJSON.c: Include stdint.h.
(parse_number): Avoid overflob in SUBSCALE and cap integer values.
--

GnuPG-bug-id: 4330
Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: Implement recpstring option parsing for gpgsm.
Werner Koch [Tue, 4 Jun 2019 07:29:09 +0000 (09:29 +0200)]
core: Implement recpstring option parsing for gpgsm.

* src/engine-gpg.c (append_args_from_recipients_string): Detect bad
options.
* src/engine-gpgsm.c (set_recipients_from_string): Implement option
parsing.
--

The only option we actually implement is "--" but the code layout is
now very simlar to engine-gpg and can easily be extended if ever
needed.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agocore: Make gpgme_op_encrypt_ext work for CMS.
Werner Koch [Mon, 3 Jun 2019 16:26:51 +0000 (18:26 +0200)]
core: Make gpgme_op_encrypt_ext work for CMS.

* src/engine-gpgsm.c (gpgsm_encrypt): Fix argument check.
--

It is pretty obvious thar the string based new encrypt function has
never been tested for S/MIME.  The fix was easy.  A followup patch
will extend it to allow for keywords in the future.

GnuPG-bug-id: 4556
Fixes-commit: a1f76b3b54b75a150fe272b804d85ffd40a507a6
Signed-off-by: Werner Koch <wk@gnupg.org>
4 months agopython: Fix typo in DecryptionError exception.
NIIBE Yutaka [Tue, 4 Jun 2019 01:38:17 +0000 (10:38 +0900)]
python: Fix typo in DecryptionError exception.

* lang/python/src/errors.py (DecryptionError): Rename from
DeryptionError.
(UnsupportedAlgorithm): Use DecryptionError.

--

GnuPG-bug-id: 4478
Reported-by: Jan Girlich
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
4 months agoAdd NEWS for 1.13.1
Andre Heinecke [Mon, 3 Jun 2019 11:01:37 +0000 (13:01 +0200)]
Add NEWS for 1.13.1

* NEWS: Add news for 1.13.1

--

5 months agopython: Make EXTRA_DIST files explicit
Andre Heinecke [Mon, 6 May 2019 14:08:26 +0000 (16:08 +0200)]
python: Make EXTRA_DIST files explicit

* configure.ac: Configure new Makefiles.
* lang/python/Makefile.am: Remove dirs from extra dist and use
subdirs.
* lang/python/examples/Makefile.am, lang/python/src/Makefile.am,
lang/python/doc/Makefile.am: New. Files that list EXTRA_DIST files.

--
This is similar to what lang/js does by explicitly listing the
files. This ensures that we have clean distribution tarballs
without accidentall additions that just lay in the directory.

GnuPG-Bug-Id: T4481

5 months agoPython, doc: Minor style improvement
Andre Heinecke [Mon, 6 May 2019 06:36:26 +0000 (08:36 +0200)]
Python, doc: Minor style improvement

* lang/python/src/core.py (Context): Retab and shorten
max line length.

5 months agoMerge remote-tracking branch 'origin/dkg/fix-T4276'
Andre Heinecke [Mon, 6 May 2019 06:10:03 +0000 (08:10 +0200)]
Merge remote-tracking branch 'origin/dkg/fix-T4276'

5 months agoAlways use maintainer mode -Wno cflags
Andre Heinecke [Fri, 3 May 2019 08:56:03 +0000 (10:56 +0200)]
Always use maintainer mode -Wno cflags

* configure.ac (CFLAGS): Move -Wno flags out of the maintainer mode.

--
It makes sense to have more warnings in maintainer mode and
not more warnings in release builds.

GnuPG-Bug-Id: T4477

5 months agocpp: Fix initialization warning
Andre Heinecke [Fri, 3 May 2019 06:49:34 +0000 (08:49 +0200)]
cpp: Fix initialization warning

* lanc/cpp/src/gpggencardkeyinteractor.cpp
(GpgGenCardKeyInteractor::Private): Fix initialization warning.

5 months agopython: stop raising BadSignatures from decrypt(verify=True) dkg/fix-T4276
Daniel Kahn Gillmor [Fri, 3 May 2019 03:28:11 +0000 (23:28 -0400)]
python: stop raising BadSignatures from decrypt(verify=True)

* src/core.py (decrypt): filter out signatures with errors from the
returned verify_result, but avoid raising BadSignatures
* tests/t-decrypt-verify.py: ensure that only a single signature is
returned when evaluating cipher-3.asc, since the other signature is
unknown.

--

This change preserves the invariant that decrypt() only ever returns
valid signatures in the verify_result, but it avoids unnecessary
errors in the face of the presence of an additional bad signature.

GnuPG-bug-id: 4276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 months agopython/tests: try to decrypt and verify new test data
Daniel Kahn Gillmor [Fri, 3 May 2019 02:16:51 +0000 (22:16 -0400)]
python/tests: try to decrypt and verify new test data

* lang/python/tests/t-decrypt.py: test decryption of cipher-3.asc and
cipher-no-sig.asc
* lang/python/tests/t-decrypt-verify.py: test decryption and
verification of cipher-3.asc and cipher-no-sig.asc

--

note that this introduces a failed test -- decrypt-verify.py
misbehaves on cipher-3.asc by throwing a BadSignature even though

GnuPG-bug-id: 4276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 months agotests: add two new types of encrypted data
Daniel Kahn Gillmor [Wed, 5 Dec 2018 17:31:07 +0000 (20:31 +0300)]
tests: add two new types of encrypted data

* tests/gpg/cipher-3.asc: add an encrypted file containing signatures
(one from a known key, and one from an unknown key)
* tests/gpg/cipher-no-sig.asc: add an encrypted file containing no
signatures at all

--

We currently aren't using these files yet, but they should be useful
for exercising the library in unusual circumstances (where the bugs
are).

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 months agopython: make it easier to run a limited number of tests
Daniel Kahn Gillmor [Wed, 5 Dec 2018 17:17:43 +0000 (20:17 +0300)]
python: make it easier to run a limited number of tests

* lang/python/tests/Makefile.am: prefer py_tests from the environment
if present.

--

I'm trying to make it nicer/quicker to hack on the testsuite for
python bindings. With this change, if you're improving the python
bindings test suite, you can selectively run only a few specific tests
like so:

   lang/python$ make check py_tests='t-decrypt.py t-decrypt-verify.py'

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 months agotests: Add cms mode to run-import
Andre Heinecke [Thu, 2 May 2019 08:26:44 +0000 (10:26 +0200)]
tests: Add cms mode to run-import

* tests/run-import.c (show_usage): Add doc for cms / openpgp.
(main): Handle protocol.

5 months agocpp: Add wrapper for gpgme_set_global_flag
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

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

6 months 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

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

6 months 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

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

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

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

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

--

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

6 months 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

6 months 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

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

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

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

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

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