1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

spawn: Remove spawn callback, introduce gnupg_spawn_actions.

* common/exechelp-posix.c (call_spawn_cb): Remove.
(gnupg_spawn_actions_new, gnupg_spawn_actions_release)
(gnupg_spawn_actions_set_environ, gnupg_spawn_actions_set_atfork)
(gnupg_spawn_actions_set_redirect)
(gnupg_spawn_actions_set_inherit_fds): New.
(my_exec, spawn_detached): Use spawn actions.
(gnupg_spawn_helper): Remove.
(gnupg_process_spawn): Remove callback, introduce gnupg_spawn_actions.
* common/exechelp-w32.c: Ditto.
* common/exechelp.h: Ditto.
* agent/genkey.c (do_check_passphrase_pattern): Follow the change of
gnupg_process_spawn API.
* common/asshelp.c (start_new_service): Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Likewise.
* common/t-exechelp.c (test_pipe_stream): Likewise.
* dirmngr/ldap-wrapper.c (ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Likewise.
* scd/app.c (report_change): Likewise.
* tests/gpgscm/ffi.c (do_process_spawn_io, do_process_spawn_fd):
Likewise.
* tools/gpg-card.c (cmd_gpg): Likewise.
* tools/gpgconf-comp.c (gpg_agent_runtime_change): Likewise.
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Likewise.
* tools/gpgconf.c (show_versions_via_dirmngr): Likewise.
* tools/gpgtar-create.c (gpgtar_create): Likewise.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (gpgtar_list): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2024-05-31 15:36:39 +09:00
parent 34045ed9e1
commit fc3fde1bde
No known key found for this signature in database
GPG key ID: 640114AF89DE6054
17 changed files with 351 additions and 181 deletions

View file

@ -42,7 +42,7 @@ int get_max_fds (void);
EXCEPT is not NULL, it is expected to be a list of file descriptors
which are not to close. This list shall be sorted in ascending
order with its end marked by -1. */
void close_all_fds (int first, int *except);
void close_all_fds (int first, const int *except);
/* Returns an array with all currently open file descriptors. The end
@ -75,22 +75,21 @@ void gnupg_close_pipe (int fd);
/* The opaque type for a subprocess. */
typedef struct gnupg_process *gnupg_process_t;
typedef struct gnupg_spawn_actions *gnupg_spawn_actions_t;
gpg_err_code_t gnupg_spawn_actions_new (gnupg_spawn_actions_t *r_act);
void gnupg_spawn_actions_release (gnupg_spawn_actions_t act);
#ifdef HAVE_W32_SYSTEM
struct spawn_cb_arg;
#ifdef NEED_STRUCT_SPAWN_CB_ARG
struct spawn_cb_arg {
HANDLE hd[3];
HANDLE *inherit_hds;
BOOL allow_foreground_window;
void *arg;
};
#endif
void gnupg_spawn_actions_set_envvars (gnupg_spawn_actions_t, char *);
void gnupg_spawn_actions_set_redirect (gnupg_spawn_actions_t,
void *, void *, void *);
void gnupg_spawn_actions_set_inherit_handles (gnupg_spawn_actions_t, void **);
#else
struct spawn_cb_arg {
int fds[3];
int *except_fds;
void *arg;
};
void gnupg_spawn_actions_set_environ (gnupg_spawn_actions_t, char **);
void gnupg_spawn_actions_set_redirect (gnupg_spawn_actions_t, int, int, int);
void gnupg_spawn_actions_set_inherit_fds (gnupg_spawn_actions_t,
const int *);
void gnupg_spawn_actions_set_atfork (gnupg_spawn_actions_t,
void (*atfork)(void *), void *arg);
#endif
#define GNUPG_PROCESS_DETACHED (1 << 1)
@ -110,14 +109,10 @@ struct spawn_cb_arg {
#define GNUPG_PROCESS_STREAM_NONBLOCK (1 << 16)
/* Spawn helper. */
void gnupg_spawn_helper (struct spawn_cb_arg *sca);
/* Spawn PGMNAME. */
gpg_err_code_t gnupg_process_spawn (const char *pgmname, const char *argv[],
gpg_err_code_t gnupg_process_spawn (const char *pgmname, const char *argv1[],
unsigned int flags,
void (*spawn_cb) (struct spawn_cb_arg *),
void *spawn_cb_arg,
gnupg_spawn_actions_t act,
gnupg_process_t *r_process);
/* Get FDs for subprocess I/O. It is the caller which should care