aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-06-06Cleanup spawn API implementation.NIIBE Yutaka3-95/+57
-- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-06-06Fix return type of gpgrt_b64dec_*.NIIBE Yutaka2-4/+4
* src/gpg-error.h.in (gpgrt_b64dec_proc): Return gpg_err_code_t. (gpgrt_b64dec_finish): Ditto. * src/visibility.c: Fix return type. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-06-05spawn:w32: Allow for up to 32 inherited handles.Werner Koch1-2/+2
* src/spawn-w32.c (spawn_detached): Increase array size. (_gpgrt_process_spawn): Ditto. -- The former limit of 16 might be a bit too low for some use cases.
2024-06-05spawn: Avoid bumping the error counter.Werner Koch2-20/+22
* src/spawn-posix.c: Use log_info instead of log_error. * src/spawn-w32.c: Ditto. (spawn_detached): Fix copying of hd[2] (_gpgrt_process_spawn): Ditto. -- The spawn function might be used to run helper processes which are non-critical for the operation of the program. For example to display help. Bumping the error counter via gpgrt_log_error would then let the entire program fail which might be surprising. It is better to just print an informational message and let the caller decide what to do with the returned error code.
2024-06-05spawn: Expose spawn functions API.NIIBE Yutaka9-129/+184
* src/gpg-error.def.in: Update. * src/gpg-error.vers: Update. * src/gpg-error.h.in: Add declarations. * src/visibility.c: Add implementations. * src/visibility.h: Expose them. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2024-06-04spawn:w32: Fix setting of dwFlags for CreateProcess.NIIBE Yutaka1-1/+2
* src/spawn-w32.c (_gpgrt_process_spawn): Only set STARTF_USESTDHANDLES with active handles. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-05-30spawn: Allow NULL for ACT.NIIBE Yutaka2-2/+19
* src/spawn-posix.c (_gpgrt_process_spawn): ACT may be null. * src/spawn-w32.c (_gpgrt_process_spawn): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-05-29Fix process termination check at release.NIIBE Yutaka2-2/+2
* src/spawn-posix.c (_gpgrt_process_release): When NOT terminated, terminate and wait. * src/spawn-w32.c (_gpgrt_process_release): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-05-29Fix how environment variables are specified for spawn.NIIBE Yutaka3-10/+12
* src/gpgrt-int.h (_gpgrt_spawn_actions_set_envvars) [HAVE_W32_SYSTEM]: Assume use with GetEnvironmentStrings. (_gpgrt_spawn_actions_set_environ) [!HAVE_W32_SYSTEM]: New. * src/spawn-posix.c: Follow the change. * src/spawn-w32.c: Can specify envvars now. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2024-05-29Cleaner semantics for _gpgrt_process_spawn without a callback.NIIBE Yutaka5-108/+211
* src/gpg-error.h.in (@define:struct_spawn_cb_arg@): Remove. (gpgrt_spawn_actions_t): New. (@define:spawn_actions_functions@): New. * src/gpgrt-int.h (_gpgrt_spawn_actions_new) (_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars) (_gpgrt_spawn_actions_set_redirect): New. [HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_handles): New. [!HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_fds) (_gpgrt_spawn_actions_set_atfork): New. (_gpgrt_process_spawn): Use gpgrt_spawn_actions_t. (_gpgrt_spawn_helper): Remove. * src/mkheader.c: Emit gpgrt_spawn_actions_* definition. * src/spawn-posix.c(_gpgrt_spawn_actions_new) (_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars) (_gpgrt_spawn_actions_set_redirect) (_gpgrt_spawn_actions_set_inherit_fds) (_gpgrt_spawn_actions_set_atfork): New. (spawn_detached, _gpgrt_process_spawn): Use gpgrt_spawn_actions_t. (_gpgrt_spawn_helper): Remove. * src/spawn-w32.c: Ditto, with _gpgrt_spawn_actions_set_inherit_handles, but no _gpgrt_spawn_actions_set_atfork. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2024-05-28Import spawn functions from GnuPG master.NIIBE Yutaka5-1132/+1245
* src/gpg-error.h.in (@define:gpgrt_process_t@): Remove. (@define:struct_spawn_cb_arg@): New. (enum gpgrt_process_requests): New. (GPGRT_PROCESS_DETACHED, GPGRT_PROCESS_STDIN_PIPE) (GPGRT_PROCESS_STDOUT_PIPE, GPGRT_PROCESS_STDERR_PIPE) (GPGRT_PROCESS_STDINOUT_SOCKETPAIR, GPGRT_PROCESS_STDIN_KEEP) (GPGRT_PROCESS_STDOUT_KEEP, GPGRT_PROCESS_STDERR_KEEP) (GPGRT_PROCESS_STDFDS_SETTING, GPGRT_PROCESS_STREAM_NONBLOCK): New. * src/gpgrt-int.h (_gpgrt_process_spawn, _gpgrt_process_terminate) (_gpgrt_process_get_fds, _gpgrt_process_get_streams) (_gpgrt_process_ctl, _gpgrt_process_wait, _gpgrt_process_release) (_gpgrt_process_wait_list, _gpgrt_spawn_helper): New. * src/mkheader.c: Emit definition of struct_spawn_cb_arg. * src/spawn-posix.c (_gpgrt_process_spawn, _gpgrt_process_terminate) (_gpgrt_process_get_fds, _gpgrt_process_get_streams) (_gpgrt_process_ctl, _gpgrt_process_wait, _gpgrt_process_release) (_gpgrt_process_wait_list, _gpgrt_spawn_helper): New. * src/spawn-w32.c: Ditto. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2024-04-26argparse: Fix a theoretical memory leak.Werner Koch1-3/+4
* src/argparse.c (store_alias): Free NAME because it has ownerhip here. Take care P is actually a pointer into NAME. -- Note that aliases have never been implemented. GnuPG-bug-id: 7105
2024-04-25logging: New function gpgrt_logv_domain.Werner Koch5-3/+22
* src/gpg-error.h.in (gpgrt_logv_domain): New. Also add printf attributes to the other logv functions. * src/visibility.c (gpgrt_logv_domain): New. -- This function can be used instead of gpgrt_logv to provide a somain string. As of now this has no effect but we may later add an API to allow selection of diagnostics depending on the domain. There is also a new (buffer,length) argument which will eventually be used to provide a domain based gpgrt_log_printhex.
2024-04-22core: New function gpgrt_add_post_log_func.Werner Koch7-2/+83
* src/gpg-error.h.in (gpgrt_add_post_log_func): New. * src/gpg-error.vers: Add new function * src/gpg-error.def.in: Ditto. * src/visibility.c (gpgrt_add_post_log_func): New. * src/logging.c (struct post_log_func_item_s): New. (post_log_func_list): New. (_gpgrt_add_post_log_func): new. (run_post_log_funcs): New. (_gpgrt_logv_internal): Call for fatal and bug log levels. -- This is required in case an application or library needs to do do some quick cleanups after a log_fatal.
2024-04-19logging: Indent continuation lines of log_printhex.Werner Koch1-6/+14
* src/logging.c (_gpgrt_logv_internal): Change to return the length w/o prefix. (_gpgrt_logv_printhex): Indent wrapped lines properly.
2024-04-12logging: Add a truncate keyword to log_printhex.Werner Koch1-0/+19
* src/logging.c (_gpgrt_logv_printhex): Add keyword support. -- A keyword in the format string is indicated by a leading pipe symbo, and exlamation mark, an arbitrary string of keywords, and a fina pipe sumbol. The only supprted keyword righty now is "trunc". Thus gpgrt_log_printhex (buf, buflen, "|!trunc|The buffer:") Will output not more that 32 hex bytes after "The buffer:" and instead of wrapping indicate the truncation by an Unicode horizontal ellipsis (#x2026).
2024-04-08argparser: avoid endless loop due to a conf file read error.Werner Koch1-3/+18
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add forceeof flag. (initialize): Clear. (_gpgrt_argparse): Clear. (_gpgrt_argparse): Act upon. -- Reported test case: $ mkdir /etc/gnupg/gpg.conf $ gpg --version All other ways to force a read error will also exhibit the bug. Debian-bug-id: 1068594
2024-02-21argparse: Adjust help output for command mode.Werner Koch1-1/+7
* src/argparse.c (show_help): Adjust for command style options.
2024-02-06core: Add "wipe" mode flag.Werner Koch2-9/+44
* src/gpgrt-int.h (struct _gpgrt_stream_internal): Add field "wipe". * src/estream.c (mem_free2): New. (struct estream_cookie_mem): Add flag "wipe". (func_mem_create): Add arg wipe. (func_mem_destroy): Wipe. (X_WIPE): New. (parse_mode): Parse "wipe" mode flag. (init_stream_obj): Set it. (do_close): Wipe internal struct with its static buffers. (doreadline): Pass wipe mode along to help buffer. (_gpgrt_mopen): Pass wipe mode. (_gpgrt_fopenmem): Ditto. -- GnuPG-bug-id: 6954 This is likely not complete but should wipe out buffers allocated by fopenmem.
2024-02-06core: New function gpgrt_wipememory.Werner Koch7-1/+37
* src/init.c (_gpgrt_wipememory): New. * src/visibility.c (gpgrt_wipememory): New. * src/visibility.h: Add it. * src/gpg-error.def.in: Ditto. * src/gpg-error.vers: Ditto. -- GnuPG-bug-id: 6954
2024-02-06argparser: Implement a command mode.Werner Koch2-42/+115
* src/gpg-error.h.in (ARGPARSE_FLAG_COMMAND): New. * src/argparse.c (struct _gpgrt_argparse_internal_s): Add flags explicit_cmd_mode, cmd_mode, and command_seen. (initialize): Init them. Mark default commands as commands. (handle_meta_command): New. (handle_metacmd): Add "command-mode" and "-command-mode". (find_long_option): Add arg only_commands. (arg_parse): Factor some code out to ... (handle_special_commands): new. (arg_parse): Implement the command-mode. * tests/t-argparse.c (main): Add some testing code. -- GnuPG-bug-id: 6978
2024-02-01gpgrt-config: Avoid warning about literals for curly braces.Jakub Jelen1-1/+1
* src/gpgrt-config.in: Fix the pattern match for an expression with variable in the ".pc" config file. -- GnuPG-bug-id: 6969 Signed-off-by: Jakub Jelen <[email protected]>
2024-01-16estream: Fix call to string filter for estream-printf.NIIBE Yutaka1-18/+26
* src/estream-printf.c (pr_string): Make sure to prepare NUL-terminated string to call the string filter. -- GnuPG-bug-id: 6737 Signed-off-by: NIIBE Yutaka <[email protected]>
2023-09-27estream: String filter should NOT be called with non-nul string.NIIBE Yutaka1-3/+8
* src/estream-printf.c (pr_string): Call the string filter function SF conditionally to avoid possible SEGV. -- GnuPG-bug-id: 6737 Signed-off-by: NIIBE Yutaka <[email protected]>
2023-07-28build: Support --verbose option for mkheader.NIIBE Yutaka1-4/+15
* src/mkheader.c (include_file): Only emit the notification when invoked with --verbose. (main): Add --verbose handling. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-06-09w32: Map ERROR_FILE_INVALID to EIO.Werner Koch1-0/+3
* src/estream.c (map_w32_to_errno): Add a mapping. -- We see this error sometimes when writing to an USB connected disk.
2023-05-26doc: Typo fixWerner Koch1-1/+1
--
2023-05-24core: Add hurd-amd64 supportSamuel Thibault3-0/+27
-- This supports the x86_64-pc-gnu triplet Signed-off-by: Samuel Thibault <[email protected]>
2023-05-24core: New mode flag "sequential" for gpgrt_fopen.Werner Koch1-3/+24
* src/estream.c (X_SEQUENTIAL): New. (func_file_create_w32): Add arg flags_and_attrs, (parse_mode): Parse the new "sequenial" flag. (_gpgrt_fopen): Use the sequenial flag in sysopen mode under Windows.
2023-05-17w32: Use _putenv_s when available.NIIBE Yutaka1-4/+28
* src/sysutils.c (_gpgrt_setenv): Use _putenv_s when the macro _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES is defined. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-04-10gpgrt-config: Simplify to set gpgrt_libdir.NIIBE Yutaka1-6/+3
* src/gpgrt-config.in (determine_gpgrt_libdir): Merge the two cases. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-04-06Release 1.47libgpg-error-1.47gpgrt-1.47Werner Koch2-3/+3
2023-04-06core: New error codes for PUKs and reset codes.Werner Koch2-1/+4
* src/err-codes.h.in (GPG_ERR_BAD_PUK): New (GPG_ERR_NO_RESET_CODE, GPG_ERR_BAD_RESET_CODE): New. -- Also updated the German translation
2023-04-04core: Add GPG_ERR_SOURCE_TKD.NIIBE Yutaka1-1/+2
* src/err-sources.h.in (GPG_ERR_SOURCE_TKD): New. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-04-01m4: Fix behavior with older gpg-error-config and gpgrt-config.NIIBE Yutaka1-1/+2
* src/gpg-error.m4 (_AM_PATH_GPGRT_CONFIG): Set the variable gpg_error_config_version on error with gpgrt-config. -- When detecting older gpgrt-config (<= 1.35), make sure to set the variable. Signed-off-by: NIIBE Yutaka <[email protected]>
2023-03-23m4: Fallback to $possible_libdir1, when not found with $CC.NIIBE Yutaka1-7/+4
* src/gpg-error.m4: Try $possible_libdir1 for gpgrt_libdir. -- GnuPG-bug-id: 6388 Reported-by: Andrew Collier <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]>
2023-03-21Avoid segv in logging with improper use of the "socket://" .Werner Koch2-2/+6
* src/logging.c (fun_writer): Protect calling socket_dir_cb if not set. -- If no callback has been registered the use of the "socket://" shortcut caused a segv.
2022-12-16core: Fix translations of --helpWerner Koch1-2/+7
* src/argparse.c (show_help): Do not translate the empty string. -- PO files use the empty string for meta information. However, to mark the end of the heder group we also use an empty string and that one gets translated - boom. Example of this error: [...] -u, --local-user USER-ID [...] Project-Id-Version: gnupg-2.3.0 Report-Msgid-Bugs-To: [email protected] PO-Revision-Date: 2022-10-07 09:52+0200 Last-Translator: Werner Koch <[email protected]> Language-Team: German <[email protected]> Language: de MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=n != 1; : (Auf der "man"-Seite ist eine volls[...]
2022-12-05Handle strerror_r failure on non-GNU systems.NIIBE Yutaka1-1/+15
* src/strerror.c (system_strerror_r): Make sure to fill the buffer. -- Suggested-by: John Scott <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-29gpgrt-config: Support a simple invocation.NIIBE Yutaka1-3/+73
* src/gpgrt-config.in (determine_gpgrt_libdir): New. -- GnuPG-bug-id: 6288 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-15gpg-error.m4: Factor out _AM_PATH_GPGRT_CONFIG.NIIBE Yutaka1-17/+32
* src/gpg-error.m4 (_AM_PATH_POSSIBLE_GPG_ERROR_CONFIG): New. (_AM_PATH_GPGRT_CONFIG): New. (AM_PATH_GPG_ERROR): Use _AM_PATH_POSSIBLE_GPG_ERROR_CONFIG and _AM_PATH_GPGRT_CONFIG. -- GnuPG-bug-id: 6273 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-15Revert "spawn: Expose spawn functions."NIIBE Yutaka5-19/+27
This reverts commit 43c1e85fe29a52a9debc068d97c5860a4694b821. -- It's a bit early to expose these functions. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-04spawn: Introduce gpgrt_process_t and use it for spawn API.NIIBE Yutaka6-126/+187
* configure.ac (AC_FUNC_FORK): No use. * src/gpg-error.h.in (@define:gpgrt_process_t@): New. (@define:pid_t@): Remove. (gpgrt_spawn_process, gpgrt_spawn_process_fd): Use gpgrt_process_t. (gpgrt_wait_process, gpgrt_wait_processes): Likewise. (gpgrt_kill_process, gpgrt_release_process): Likewise. * src/gpgrt-int.h (_gpgrt_spawn_process): Likewise. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. * src/mkheader.c (write_special): Handle @define:gpgrt_process_t@. Remove handling of @define:pid_t@. * src/spawn-posix.c (_gpgrt_spawn_process): Use gpgrt_process_t. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. * src/spawn-w32.c (_gpgrt_spawn_process): Use gpgrt_process_t. (_gpgrt_spawn_process_fd): Likewise. (_gpgrt_wait_process, _gpgrt_wait_processes): Likewise. (_gpgrt_kill_process, _gpgrt_release_process): Likewise. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-10-31spawn: Fix spawn_cb of gpgrt_spawn_process_fd.NIIBE Yutaka8-24/+63
* src/gpg-error.def.in (gpgrt_close_all_fds): New. * src/gpg-error.vers (gpgrt_close_all_fds): New. * src/gpg-error.h.in (GPGRT_SPAWN_INHERIT_FILE): New. (gpgrt_spawn_process_fd): SPAWN_CB having return value. * src/gpgrt-int.h (_gpgrt_spawn_process_fd): SPAWN_CB change. * src/spawn-posix.c (_gpgrt_close_all_fds): Rename from close_all_fds, and export it. (do_exec): Support the case not closing fds. (_gpgrt_spawn_process_fd): Handle return value of SPAWN_CB to determine closing all fds or not. * src/spawn-w32.c (_gpgrt_spawn_process_fd): Run SPAWN_CB. (_gpgrt_close_all_fds): New. * src/visibility.c (gpgrt_close_all_fds): New. * src/visibility.h (gpgrt_close_all_fds): New. -- Now, we have the API of gpgrt_spawn_process_fd for POSIX and Windows. Giving portable semantics for spawning a process is difficult, and it is still difficult for users to writing a function for SPAWN_CB with portability, but gpgrt_spawn_process_fd gives the feature of spawning a process. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-10-27spawn: Expose spawn functions.NIIBE Yutaka5-29/+17
* src/gpg-error.def.in: Update. * src/gpg-error.vers: Update. * src/gpg-error.h.in: Add declarations. * src/visibility.c: Add implementations. * src/visibility.h: Expose them. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-10-27Fix the comment for _gpgrt_spawn_process_fd, it's a variant.NIIBE Yutaka1-10/+9
-- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-10-20gpgrt_spawn_process, gpgrt_spawn_process_fd: Change the API.NIIBE Yutaka5-30/+39
* src/gpg-error.h.in (gpgrt_spawn_process): Remove PREEXEC argument. (gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/gpgrt-int.h (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/spawn-posix.c (do_exec): Remove PREEXEC argument. (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. (_gpgrt_spawn_process_detached): Follow the change of do_exec. * src/spawn-w32.c (_gpgrt_spawn_process): Remove PREEXEC argument. (_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. * src/visibility.c (gpgrt_spawn_process): Remove PREEXEC argument. (gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-10-19spawn: Update changes from gnupg.NIIBE Yutaka4-10/+32
* src/gpg-error.h.in (GPGRT_SPAWN_KEEP_STDIN): New. (GPGRT_SPAWN_KEEP_STDOUT, GPGRT_SPAWN_KEEP_STDERR): New. * src/gpgrt-int.h: Add comment. * src/spawn-posix.c (do_exec): Add the argument FLAGS. (_gpgrt_spawn_process): Add FLAGS. (_gpgrt_spawn_process_fd): Follow the change. (_gpgrt_spawn_process_detached): Likewise. * src/spawn-w32.c (_gpgrt_spawn_process): Handle FLAGS. -- This commit imports GnuPG master commit of: 6d6438a361d25f3b269f702e017f5e39fd1f5c38 GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-09-21m4: Fix detection of gpgrt's libdir.Damien Goutte-Gattat1-1/+5
* src/gpg-error.m4 (GPGRT_CONFIG): Handle the case where none of the system lib directories contain a pkgconfig subdirectory. -- When we look for gpgrt_libdir, there's a corner case if we had been able to obtain system libdirs (using `cc -print-search-dirs`) *but* none of those system libdirs happen to contain a valid pkgconfig subdirectory (which may be unlikely but can and does happen when cross-compiling). We do test for the case where we have not obtained any system libdir at all, in which case we fallback to `${gpgrt_prefix}/lib` (`possible_libdir1`), but we do not test if the list of libdir candidates is reduced to nothing after we have eliminated all the libdirs that do not contain a pkgconfig subdirectory. This patch adds a test for this precise case. Signed-off-by: Damien Goutte-Gattat <[email protected]>
2022-09-15Remove extra semicolons.NIIBE Yutaka2-11/+11
* src/gpgrt-int.h: Remove extra. * src/visibility.h: Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>