* src/fdtable.h (FDTABLE_FLAG_NOT_DONE): New flag.
* src/fdtable.c (_gpgme_fdtable_io_cb_count): Rename to ...
(_gpgme_fdtable_get_count): this and add arg 'flags'.
(_gpgme_fdtable_run_io_cbs): Add return arg 'r_owner'.
* src/wait.c (gpgme_wait_ext): Improve tracing. Act upon error codes
from running the callbacks.
* tests/gpg/t-wait.c (main): Remove the sleep.
--
Now t-wait works again. There are still problems with the user
defined events but it is another step in our refactoring work.
Signed-off-by: Werner Koch <wk@gnupg.org>
* src/wait.c (_gpgme_wait_on_condition): Rename to ...
(_gpgme_sync_wait): this. Small code refactoring.
(_gpgme_wait_one, _gpgme_wait_one_ext): Remove and change all callers
to use _gpgme_sync_wait.
* src/fdtable.c (_gpgme_fdtable_run_io_cbs): Move TRACE up.
--
Signed-off-by: Werner Koch <wk@gnupg.org>
* src/fdtable.c, src/fdtable.h: Largely extend.
* src/wait-global.c, src/wait-private.c, src/wait-user.c: Remove and
move code to ...
* src/wait.c: here.
(_gpgme_fd_table_init, fd_table_put): Remove. Do not call them.
(_gpgme_add_io_cb, _gpgme_add_io_cb_user): Change to use the fdtable.
(_gpgme_remove_io_cb, _gpgme_remove_io_cb_user): Ditto.
(_gpgme_wait_global_event_cb): Ditto.
(gpgme_wait_ext, _gpgme_wait_on_condition): Ditto.
* src/wait.h (struct io_cb_tag_s): Add fields 'serial' and 'desc'.
Change 'idx' to 'fd'.
(struct fd_table): Remove.
* src/context.h (struct gpgme_context): Remoce 'fdt'. Rename io_cbs
to user_io_cbs for clarity.
* src/engine-gpgsm.c: Unify trace output.
(start): Pass a description along with the IO handlers.
* src/priv-io.h (struct io_select_fd_s): Rename to io_select_s.
(io_select_t): New.
* src/gpgme.c (_gpgme_cancel_with_err): Replace arg 'ctx' by 'serial'.
(gpgme_cancel): Adjust.
--
This is the second part of a larger refactoring of the wait/event
code. Does currently only work on Unix and with the private wait
functions (i.e. the async operations don't yet work).
Signed-off-by: Werner Koch <wk@gnupg.org>
* src/engine-gpg.c (gpg_verify): Supply --verify for fixed gpg
versions.
--
With 2.1.something we print a warning if no explict command was
given. Since 2.1.16 this has been fixed to also allow the combination
of --verify and --output. Thus we now always use "--verify".
Signed-off-by: Werner Koch <wk@gnupg.org>
* 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>
* src/context.h (struct gpgme_context): Add field 'next_ctx'.
* src/gpgme.c (def_lc_lock): Replace by ...
(context_list_lock): new.
(context_list): New variable.
(gpgme_new): Add new context object to the list.
(gpgme_release): Remove context object from the list.
(_gpgme_get_ctx): New function.
--
To allow mapping a context serial number back to a context object and
to check whether a serialno has still a context object, we need to
link them all together. We already take a lock to setup the locale
and thus the only overhead is in freeing the context.
Signed-off-by: Werner Koch <wk@gnupg.org>
* src/fdtable.c, src/fdtable.h: New.
* src/posix-io.c (notify_table_item_s): Remove.
(notify_table, notify_table_size, notify_table_lock): Remove.
(_gpgme_io_pipe): Put new fds into the table.
(_gpgme_io_dup): Ditto.
(_gpgme_io_close): Replace notify stuff by a call to the fdtable.
(_gpgme_io_set_close_notify): Remove. Change all callers to to use
_gpgme_fdtable_add_close_notify.
* src/Makefile.am (main_sources): Add new files.
--
This is the first part or a larger change to unify the tracking of
file descriptors. Right now this has only been implemented for
Posix and thus the code will not yet build for Windows.
Signed-off-by: Werner Koch <wk@gnupg.org>
* 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>
* 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>
* 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>
* 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.
* 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: 7a1e7006d0
Signed-off-by: Werner Koch <wk@gnupg.org>
* 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>
* 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>
* 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>
* 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>
* 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: a1f76b3b54
Signed-off-by: Werner Koch <wk@gnupg.org>
* 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
* 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
* 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>
* 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>
* 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>
* 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>
* 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: dd21ec997c
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* 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: a82e3a0ae5
GnuPG-Bug-Id: T4453
* 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.
* 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
* 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.
* 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.