aboutsummaryrefslogtreecommitdiffstats
path: root/common/exectool.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2017-04-28Spelling fixes in docs and comments.NIIBE Yutaka1-1/+1
-- In addition, fix trailing spaces in tests/inittests. GnuPG-bug-id: 3121 Reported-by: ka7 (klemens) Signed-off-by: NIIBE Yutaka <[email protected]>
2017-02-28w32: Make pipes really pollable.Werner Koch1-0/+5
* common/exectool.c (gnupg_exec_tool_stream) [W32]: Use _get_osfhandle to print the fd for the command line. * common/exechelp-w32.c (create_pipe_and_estream): Use es_sysopen so that the streams are actually pollable. -- This addresses two bugs: - Using the "-&@INEXTRA@" kludges requires that we pass the value of the handle on the command line and not the libc fd. - gpgrt_poll requires the use of the ReadFile/WriteFile backend which is currently only used when the stream has been created with gpgrt_sysopen. Signed-off-by: Werner Koch <[email protected]>
2017-01-19common: Fix buffer copy code again.Werner Koch1-20/+14
* common/exectool.c (my_error_from_errno): Remove. (copy_buffer_do_copy): Do without var RC. (copy_buffer_flush): Ditto. Use ERRNO instead of es_write return code. (gnupg_exec_tool): Correctly return errors from es_read. -- Fixes-commit: 55c9212a2338bf0b07c8cf3a69bcedaa28d48d43 Signed-off-by: Werner Koch <[email protected]>
2017-01-19common: Clarify use of vars in buffer copy code.Werner Koch1-16/+26
* common/exectool.c (my_error_from_errno): New. (copy_buffer_do_copy): Use separate vars for errno values and gpg-error values for clarity. s/assert/log_assert/. (copy_buffer_flush): Ditto. (gnupg_exec_tool_stream): Use gpg_err_code when testing. -- NB: It is surprising that es_write seems not to set ERRNO but only returns the ERRNO value. Need to check whether this is really the case. Signed-off-by: Werner Koch <[email protected]>
2017-01-18common: Fix flushing copy buffers.Justus Winter1-7/+19
* common/exectool.c (copy_buffer_flush): Write and flush the data, but do not hide EAGAIN from the caller. (gnupg_exec_tool_stream): Retry on EAGAIN. GnuPG-bug-id: 2425 Signed-off-by: Justus Winter <[email protected]>
2016-11-05Change all http://www.gnu.org in license notices to https://Werner Koch1-1/+1
--
2016-10-18common: Fix copying data to estreams.Justus Winter1-5/+7
* common/exectool.c (copy_buffer_do_copy): Correctly account for partially written data in the event of errors. Signed-off-by: Justus Winter <[email protected]>
2016-07-26common: Avoid excessive stack use.Justus Winter1-14/+39
* common/exectool.c (copy_buffer_shred): Make passing NULL a nop. (gnupg_exec_tool_stream): Allocate copy buffers from the heap. Signed-off-by: Justus Winter <[email protected]>
2016-07-26common: Rework resource cleanup when handling errors.Justus Winter1-9/+10
* common/exectool.c (gnupg_exec_tool_stream): Rework error handling. Signed-off-by: Justus Winter <[email protected]>
2016-06-28common: Fix copying data from the spawned child.Justus Winter1-10/+15
Fixes intermittent gpgtar failures. * common/exectool.c (copy_buffer_do_copy): Initialize 'nwritten'. (gnupg_exec_tool_stream): Loop until all data is copied. Signed-off-by: Justus Winter <[email protected]>
2016-05-27common: Add a status callback to gnupg_exec_tool_stream.Werner Koch1-13/+80
* common/exectool.h (exec_tool_status_cb_t): New. * common/exectool.c: Include missing exectool.h. (read_and_log_buffer_t): Replace array by pointer. (gnupg_exec_tool_stream): Add args 'status_cb' and 'status_cb_value'. Change all callers to pass NULL for them. Malloc buffer for FDERRSTATE. (read_and_log_stderr): Implement status_fd feature. Signed-off-by: Werner Koch <[email protected]>
2016-05-27common: Allow a second input stream for gnupg_exec_tool_stream.Werner Koch1-19/+99
* common/exechelp-posix.c (do_exec): Add arg 'except' and pass to close_all_fds. (gnupg_spawn_process): Add arg 'except'. Change callers to pass NULL for it. * common/exechelp-w32.c (gnupg_spawn_process): Add dummy arg 'except'. * common/exechelp-w32ce.c (gnupg_spawn_process): Ditto. * common/exectool.c (copy_buffer_do_copy): Allow NULL for SINK. (gnupg_exec_tool_stream): Add arg 'inextra'. Change callers to pass NULL for it. Allow NULL for OUTPUT. -- This hack is a first step to allow calling gpg for verification of signatures. Signed-off-by: Werner Koch <[email protected]>
2016-05-27common: Make use of default_errsource in exechelp.Werner Koch1-1/+1
* common/exechelp-posix.c (my_error_from_syserror, my_error): New. Use them instead of gpg_error and gpg_error_from_syserror. (create_pipe_and_estream): Remove arg ERRSOURCE and fix use of OUTBOUND which has a wrong name. Adjust callers. (gnupg_spawn_process): Remove arg ERRSOURCE and replace by use of DEFAULT_ERRSOURCE. * common/exechelp-w32.c (gnupg_spawn_process): Ditto. * common/exechelp-w32ce.c (gnupg_spawn_process): Ditto. * common/exectool.c (gnupg_exec_tool_stream): Do not pass GPG_ERROR_FROM_SYSERROR. * tools/gpgconf-comp.c (gc_component_check_options): Ditto. (retrieve_options_from_program): Ditto. Signed-off-by: Werner Koch <[email protected]>
2016-02-13common: Make gnupg_exec_tool conform to spec.Werner Koch1-9/+18
* common/exectool.c (gnupg_exec_tool): Allocate extra byte. Allow zero length read. Append hidden byte. Release memory on error. -- Signed-off-by: Werner Koch <[email protected]>
2015-12-15common: Use default_errsource for call-gpg and exectool.Werner Koch1-8/+15
* common/call-gpg.c (my_error_from_syserror, my_error_from_errno): New. Use these wrappers. * common/exectool.c (my_error_from_syserror): New. Use these wrappers. -- Function in common should use the error source of the component which links them. The global variable DEFAULT_ERRSOURCE is set early by each component to make this possible. Signed-off-by: Werner Koch <[email protected]>
2015-12-14common: Change license for exectool to LGPLv3+/GPLv2+.Werner Koch1-5/+15
* common/exectool.c, common/exectool.h: Change license. -- We always try to use this license for shared code. Signed-off-by: Werner Koch <[email protected]>
2015-12-14common: Rename sh-exectool to exectool.Werner Koch1-9/+9
* common/sh-exectool.c: Rename to exectool.c. * common/sh-exectool.h: Rename to exectool.h. * common/Makefile.am (common_sources): Adjust for rename. * common/exectool.c (sh_exec_tool_stream): Rename to gnupg_exec-tool-stream. (sh_exec_tool): Rename to gnupg_exec_tool. * tools/gpgtar-create.c (gpgtar_create): Adjust for changes. * tools/gpgtar-extract.c: Adjust for changes. * tools/gpgtar-list.c: Adjust for changes. -- The "sh-" presifx is used by g13 for system helpers which are used by processes created via userv. A generic function in common/ should also have a generic name. Signed-off-by: Werner Koch <[email protected]>
2015-12-04common: Add a stream interface to 'sh-exectool'.Justus Winter1-86/+206
* common/sh-exectool.c (struct copy_buffer): Add infrastructure for copying between streams. (copy_buffer_{init,shred,do_copy,flush}): New functions. (sh_exec_tool_stream): Rework 'sh_exec_tool' to operate on streams. (nop_free): New function. (sh_exec_tool): Express this in terms of 'sh_exec_tool_stream'. * common/sh-exectool.h (sh_exec_tool_stream): New prototype. Signed-off-by: Justus Winter <[email protected]>
2015-12-04common: Add header file and build the new code.Justus Winter1-1/+1
* common/Makefile.am (common_sources): Add new files. * common/sh-exectool.h: New file. Signed-off-by: Justus Winter <[email protected]>
2015-12-04common: Add code to execute a helper.Werner Koch1-0/+303
* common/sh-exectool.c: New file. Signed-off-by: Justus Winter <[email protected]>