aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-06-14core: Make the refactored user event loop work.wk/new-waitWerner Koch1-0/+7
* src/wait.c (user_io_cb_handler): Set FD signaled. -- With this patch the regression test suite now passes. Signed-off-by: Werner Koch <[email protected]>
2019-06-14core: Make the refactored global wait work.Werner Koch3-38/+113
* 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 <[email protected]>
2019-06-14core: Use a better name for the internal synchronous wait.Werner Koch24-93/+68
* 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 <[email protected]>
2019-06-13core: Refactor the wait code utilizing the new fdtable.Werner Koch15-939/+992
* 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 <[email protected]>
2019-06-12core: Use fully correct command args for gpg --verify.Werner Koch1-0/+2
* 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 <[email protected]>
2019-06-12core: At debug levels up to 9 print only an ascii dump.Werner Koch1-27/+59
* 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 <[email protected]>
2019-06-12core: Improve code by using strconcat at two places.Werner Koch1-22/+17
* src/engine-gpgsm.c (gpgsm_export): Use _gpgme_strconcat. (gpgsm_keylist): Ditto. -- Signed-off-by: Werner Koch <[email protected]>
2019-06-12core: Link all context objects and add _gpgme_get_ctx.Werner Koch3-17/+91
* 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 <[email protected]>
2019-06-07core: Introduce a context serial number.Werner Koch3-97/+135
* src/context.h: Include stdint.h. (struct gpgme_context): Add field 'serial'. (CTXSERIAL): New. * src/gpgme.c: (last_ctx_serial): New. (gpgme_new): Set serial. * src/gpgme.c: Change trace calls to use the serial. * src/wait.c (_gpgme_add_io_cb): Ditto (_gpgme_remove_io_cb): Ditto. Signed-off-by: Werner Koch <[email protected]>
2019-06-07core: Replace the posix close notify mechanism by a new generic one.Werner Koch13-148/+358
* 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 <[email protected]>
2019-06-06core: Add commented debug helper to posix-io.c.Werner Koch1-21/+71
* 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 <[email protected]>
2019-06-06core: Fix error return value of _gpgme_run_io_cb.Werner Koch1-5/+8
* 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 <[email protected]>
2019-06-05core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.Werner Koch2-6/+18
* 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 <[email protected]>
2019-06-05core: Improve the debug messages even more.Werner Koch18-140/+116
* 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 <[email protected]>
2019-06-05core: Avoid explicit locks in the debug code.Werner Koch1-46/+46
* 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 <[email protected]>
2019-06-04json: Print "nan", "-inf", "inf" if needed.Werner Koch1-1/+7
* src/cJSON.c (print_number): Print NaN and INF. -- GnuPG-bug-id: 4328 Signed-off-by: Werner Koch <[email protected]>
2019-06-04json: Improve handling of large exponents in the JSON parsor.Werner Koch1-7/+33
* 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 <[email protected]>
2019-06-04core: Implement recpstring option parsing for gpgsm.Werner Koch2-16/+26
* 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 <[email protected]>
2019-06-04core: Make gpgme_op_encrypt_ext work for CMS.Werner Koch1-1/+1
* 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 <[email protected]>
2019-04-19core: Fix duplication of close_notify_handler for gpgsm.NIIBE Yutaka1-2/+0
* 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 <[email protected]>
2019-04-19core: Fix error return.NIIBE Yutaka1-0/+1
* src/engine.c (_gpgme_set_engine_info): Add error return. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-04-09core,w32: Fix minor potential memleakAndre Heinecke1-0/+2
* src/w32-util.c (_gpgme_create_process_utf8): Free converted startup info strings.
2019-04-09core,w32: Fix new w32-util functionsAndre Heinecke1-3/+25
* 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
2019-04-09core,w32: Improve handling of Unicode pathsAndre Heinecke5-19/+128
* 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.
2019-04-09core,w32: Show w32-spawn warning only onceAndre Heinecke1-14/+19
* 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
2019-03-27core, w32: Fix format string errors on windowsAndre Heinecke1-1/+8
* 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.
2019-03-27core: Fix assuan logger-fd hack for windowsAndre Heinecke1-1/+1
* src/assuan-support.c (my_spawn): Zero is a perfectly fine fd.
2019-03-26core,w32,glib: Fix build of w32-glib-io.cAndre Heinecke1-7/+10
* src/w32-glib-io.c (_gpgme_io_pipe, _gpgme_io_connect): Do not use TRACE_SUC in a return statement.
2019-03-26core: Fix a strtoul to strtolAndre Heinecke1-1/+1
* 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.
2019-03-25core, w32: Add hack to translate diag logger-fdAndre Heinecke1-5/+53
* 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
2019-03-19core: Support GPGME_AUDITLOG_DIAG for gpgsm.Werner Koch1-18/+114
* 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 <[email protected]> Signed-off-by: Werner Koch <[email protected]>
2019-02-28json: Fix cosmetic error in the repl.Werner Koch1-1/+1
* src/gpgme-json.c (native_messaging_repl): Use correct var with sizeof. -- Signed-off-by: Werner Koch <[email protected]>
2019-02-27json: Limit recursion depthAndre Heinecke1-13/+41
* 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
2019-02-19core,w32: Fix missing sentinel in dir name builder.Werner Koch1-1/+1
* 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 <[email protected]>
2019-01-25json: Better use gpgme_freeWerner Koch1-1/+1
* 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 <[email protected]>
2019-01-25json: Fix minor memory leaks.Werner Koch1-6/+14
* 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 <[email protected]>
2018-12-17core: Silence newer compiler warnings.Werner Koch3-1/+5
* 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 <[email protected]>
2018-12-07core: Fix ERR_INV_ARG check in genkey_startAndre Heinecke1-1/+1
* 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
2018-12-03doc: Minor comment cleanups.Werner Koch1-0/+2
-- Signed-off-by: Werner Koch <[email protected]>
2018-11-19core: Fix format string errors in w32-io.c and use of TRACE_SUC.Werner Koch1-19/+23
* src/w32-io.c: Fix use of TRACE_SUC. Fix some format strung errors. Signed-off-by: Werner Koch <[email protected]>
2018-11-16core: Protect the trace macros for fun and profit.Werner Koch11-77/+114
* src/debug.h: Protect macros using. (_trace_err, _trace_sysres, _trace_syserr): New helper inline functions. Signed-off-by: Werner Koch <[email protected]>
2018-11-16core: Fix a LF problem in the new debug fucntion.Werner Koch1-3/+6
* src/debug.c (_gpgme_debug): Print a LF for an empty FORMAT unless we are in legacy mode.
2018-11-16core: Fix format string errors in trace macrosWerner Koch11-29/+30
-- Signed-off-by: Werner Koch <[email protected]>
2018-11-16core: Remove old debug helper functionWerner Koch6-95/+59
* src/debug.c (_gpgme_debug): Remove. (_gpgme_debugf): Rename to _gpgme_debug. Signed-off-by: Werner Koch <[email protected]>
2018-11-16core: Simplify the trace maros by using variadics.Werner Koch45-570/+550
* 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 <[email protected]>
2018-11-16Add SPDX identifiers to most source filesWerner Koch75-1125/+1171
-- Signed-off-by: Werner Koch <[email protected]>
2018-11-12build: Make gpgme.m4 use gpgrt-config with *.pc.NIIBE Yutaka1-10/+48
* 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 <[email protected]>
2018-11-12build: Provide gpgme-glib.pc too.NIIBE Yutaka3-3/+17
* 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 <[email protected]>
2018-11-12build: Provide gpgme.pc, generated by configure.NIIBE Yutaka3-6/+27
* 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 <[email protected]>
2018-11-08spelling: fix misspellingsDaniel Kahn Gillmor15-57/+57
Signed-off-by: Daniel Kahn Gillmor <[email protected]>