From de01fb8131fd8d11de50e21b7351af99a3515a94 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 20 Oct 2022 14:03:13 +0900 Subject: [PATCH] agent,common,dirmngr,tests,tools: Remove spawn PREEXEC argument. * common/exechelp-posix.c (do_exec): Remove PREEXEC argument. (gnupg_spawn_process): Likewise. (gnupg_spawn_process_fd): Follow the change of do_exec. (gnupg_spawn_process_detached): Likewise. * common/exechelp-w32.c (gnupg_spawn_process): Remove PREEXEC. * common/exechelp.h (gnupg_spawn_process): Remove PREEXEC. * agent/genkey.c (do_check_passphrase_pattern): Follow the change. * common/exectool.c (gnupg_exec_tool_stream): Likewise. * dirmngr/ldap-wrapper.c (ldap_wrapper): Likewise. * tests/gpgscm/ffi.c (do_spawn_process): Likewise. * tools/gpgconf-comp.c (gc_component_check_options): Likewise. (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. -- PREEXEC is not portable feature and it's not used. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka --- agent/genkey.c | 2 +- common/exechelp-posix.c | 12 +++++------- common/exechelp-w32.c | 6 +----- common/exechelp.h | 2 +- common/exectool.c | 2 +- dirmngr/ldap-wrapper.c | 2 +- tests/gpgscm/ffi.c | 1 - tools/gpgconf-comp.c | 6 +++--- tools/gpgconf.c | 2 +- tools/gpgtar-create.c | 2 +- tools/gpgtar-extract.c | 2 +- tools/gpgtar-list.c | 2 +- 12 files changed, 17 insertions(+), 24 deletions(-) diff --git a/agent/genkey.c b/agent/genkey.c index fc6ce0a26..eb6791dca 100644 --- a/agent/genkey.c +++ b/agent/genkey.c @@ -142,7 +142,7 @@ do_check_passphrase_pattern (ctrl_t ctrl, const char *pw, unsigned int flags) argv[i] = NULL; log_assert (i < sizeof argv); - if (gnupg_spawn_process (pgmname, argv, NULL, NULL, 0, + if (gnupg_spawn_process (pgmname, argv, NULL, 0, &stream_to_check_pattern, NULL, NULL, &pid)) result = 1; /* Execute error - assume password should no be used. */ else diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c index b4d10bf65..54fe7dbac 100644 --- a/common/exechelp-posix.c +++ b/common/exechelp-posix.c @@ -277,7 +277,7 @@ get_all_open_fds (void) static void do_exec (const char *pgmname, const char *argv[], int fd_in, int fd_out, int fd_err, - int *except, void (*preexec)(void), unsigned int flags) + int *except, unsigned int flags) { char **arg_list; int i, j; @@ -334,8 +334,6 @@ do_exec (const char *pgmname, const char *argv[], /* Close all other files. */ close_all_fds (3, except); - if (preexec) - preexec (); execv (pgmname, arg_list); /* No way to print anything, as we have closed all streams. */ _exit (127); @@ -437,7 +435,7 @@ gnupg_close_pipe (int fd) /* Fork and exec the PGMNAME, see exechelp.h for details. */ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[], - int *except, void (*preexec)(void), unsigned int flags, + int *except, unsigned int flags, estream_t *r_infp, estream_t *r_outfp, estream_t *r_errfp, @@ -544,7 +542,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], es_fclose (outfp); es_fclose (errfp); do_exec (pgmname, argv, inpipe[0], outpipe[1], errpipe[1], - except, preexec, flags); + except, flags); /*NOTREACHED*/ } @@ -594,7 +592,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], { gcry_control (GCRYCTL_TERM_SECMEM); /* Run child. */ - do_exec (pgmname, argv, infd, outfd, errfd, NULL, NULL, 0); + do_exec (pgmname, argv, infd, outfd, errfd, NULL, 0); /*NOTREACHED*/ } @@ -893,7 +891,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], for (i=0; envp[i]; i++) putenv (xstrdup (envp[i])); - do_exec (pgmname, argv, -1, -1, -1, NULL, NULL, 0); + do_exec (pgmname, argv, -1, -1, -1, NULL, 0); /*NOTREACHED*/ } diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index 19cf85c85..aeedbbf2d 100644 --- a/common/exechelp-w32.c +++ b/common/exechelp-w32.c @@ -410,7 +410,7 @@ gnupg_close_pipe (int fd) /* Fork and exec the PGMNAME, see exechelp.h for details. */ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[], - int *except, void (*preexec)(void), unsigned int flags, + int *except, unsigned int flags, estream_t *r_infp, estream_t *r_outfp, estream_t *r_errfp, @@ -564,10 +564,6 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], nullhd[2] = ((flags & GNUPG_SPAWN_KEEP_STDOUT)? GetStdHandle (STD_ERROR_HANDLE) : w32_open_null (1)); - /* Start the process. Note that we can't run the PREEXEC function - because this might change our own environment. */ - (void)preexec; - memset (&si, 0, sizeof si); si.cb = sizeof (si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; diff --git a/common/exechelp.h b/common/exechelp.h index 735ea4728..3343fe598 100644 --- a/common/exechelp.h +++ b/common/exechelp.h @@ -133,7 +133,7 @@ void gnupg_close_pipe (int fd); */ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[], - int *execpt, void (*preexec)(void), unsigned int flags, + int *execpt, unsigned int flags, estream_t *r_infp, estream_t *r_outfp, estream_t *r_errfp, diff --git a/common/exectool.c b/common/exectool.c index 8013ba1cc..aaf5898d0 100644 --- a/common/exectool.c +++ b/common/exectool.c @@ -412,7 +412,7 @@ gnupg_exec_tool_stream (const char *pgmname, const char *argv[], exceptclose[0] = -1; err = gnupg_spawn_process (pgmname, argv, - exceptclose, NULL, GNUPG_SPAWN_NONBLOCK, + exceptclose, GNUPG_SPAWN_NONBLOCK, input? &infp : NULL, &outfp, &errfp, &pid); if (extrapipe[0] != -1) diff --git a/dirmngr/ldap-wrapper.c b/dirmngr/ldap-wrapper.c index ac29de973..23d514cf9 100644 --- a/dirmngr/ldap-wrapper.c +++ b/dirmngr/ldap-wrapper.c @@ -855,7 +855,7 @@ ldap_wrapper (ctrl_t ctrl, ksba_reader_t *reader, const char *argv[]) } err = gnupg_spawn_process (pgmname, arg_list, - NULL, NULL, GNUPG_SPAWN_NONBLOCK, + NULL, GNUPG_SPAWN_NONBLOCK, NULL, &outfp, &errfp, &pid); if (err) { diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c index b9210c706..aefd7c385 100644 --- a/tests/gpgscm/ffi.c +++ b/tests/gpgscm/ffi.c @@ -787,7 +787,6 @@ do_spawn_process (scheme *sc, pointer args) } err = gnupg_spawn_process (argv[0], (const char **) &argv[1], - NULL, NULL, flags, &infp, &outfp, &errfp, &pid); diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c index 7cd45c7e9..90f2f53d3 100644 --- a/tools/gpgconf-comp.c +++ b/tools/gpgconf-comp.c @@ -1370,7 +1370,7 @@ gc_component_check_options (int component, estream_t out, const char *conf_file) result = 0; errlines = NULL; - err = gnupg_spawn_process (pgmname, argv, NULL, NULL, 0, + err = gnupg_spawn_process (pgmname, argv, NULL, 0, NULL, NULL, &errfp, &pid); if (err) result |= 1; /* Program could not be run. */ @@ -1759,7 +1759,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed) /* First we need to read the option table from the program. */ argv[0] = "--dump-option-table"; argv[1] = NULL; - err = gnupg_spawn_process (pgmname, argv, NULL, NULL, 0, + err = gnupg_spawn_process (pgmname, argv, NULL, 0, NULL, &outfp, NULL, &pid); if (err) { @@ -1940,7 +1940,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed) /* Now read the default options. */ argv[0] = "--gpgconf-list"; argv[1] = NULL; - err = gnupg_spawn_process (pgmname, argv, NULL, NULL, 0, + err = gnupg_spawn_process (pgmname, argv, NULL, 0, NULL, &outfp, NULL, &pid); if (err) { diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 83ad947bb..4afc4e9fd 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -1182,7 +1182,7 @@ show_versions_via_dirmngr (estream_t fp) pgmname = gnupg_module_name (GNUPG_MODULE_NAME_DIRMNGR); argv[0] = "--gpgconf-versions"; argv[1] = NULL; - err = gnupg_spawn_process (pgmname, argv, NULL, NULL, 0, + err = gnupg_spawn_process (pgmname, argv, NULL, 0, NULL, &outfp, NULL, &pid); if (err) { diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c index 63d0e831b..3a7687d9f 100644 --- a/tools/gpgtar-create.c +++ b/tools/gpgtar-create.c @@ -1195,7 +1195,7 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names, goto leave; } - err = gnupg_spawn_process (opt.gpg_program, argv, NULL, NULL, + err = gnupg_spawn_process (opt.gpg_program, argv, NULL, (GNUPG_SPAWN_KEEP_STDOUT | GNUPG_SPAWN_KEEP_STDERR), &outstream, NULL, NULL, &pid); diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c index 832039b2c..f96887f40 100644 --- a/tools/gpgtar-extract.c +++ b/tools/gpgtar-extract.c @@ -408,7 +408,7 @@ gpgtar_extract (const char *filename, int decrypt) goto leave; } - err = gnupg_spawn_process (opt.gpg_program, argv, NULL, NULL, + err = gnupg_spawn_process (opt.gpg_program, argv, NULL, ((filename? 0 : GNUPG_SPAWN_KEEP_STDIN) | GNUPG_SPAWN_KEEP_STDERR), NULL, &stream, NULL, &pid); diff --git a/tools/gpgtar-list.c b/tools/gpgtar-list.c index 08ab9672e..a536b05f2 100644 --- a/tools/gpgtar-list.c +++ b/tools/gpgtar-list.c @@ -501,7 +501,7 @@ gpgtar_list (const char *filename, int decrypt) goto leave; } - err = gnupg_spawn_process (opt.gpg_program, argv, NULL, NULL, + err = gnupg_spawn_process (opt.gpg_program, argv, NULL, ((filename? 0 : GNUPG_SPAWN_KEEP_STDIN) | GNUPG_SPAWN_KEEP_STDERR), NULL, &stream, NULL, &pid);