diff options
author | NIIBE Yutaka <[email protected]> | 2024-05-29 08:13:00 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2024-05-29 08:19:44 +0000 |
commit | fbe1f5153c3cb8b7c5de40973cceee7f639804e7 (patch) | |
tree | c9bbd781297ed6a0c0e6d78cf52ed15ae6ef989a | |
parent | Cleaner semantics for _gpgrt_process_spawn without a callback. (diff) | |
download | libgpg-error-fbe1f5153c3cb8b7c5de40973cceee7f639804e7.tar.gz libgpg-error-fbe1f5153c3cb8b7c5de40973cceee7f639804e7.zip |
Fix how environment variables are specified for spawn.
* 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]>
-rw-r--r-- | src/gpgrt-int.h | 3 | ||||
-rw-r--r-- | src/spawn-posix.c | 11 | ||||
-rw-r--r-- | src/spawn-w32.c | 8 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h index 2871128..cb25b3f 100644 --- a/src/gpgrt-int.h +++ b/src/gpgrt-int.h @@ -686,12 +686,13 @@ gpg_err_code_t _gpgrt_make_pipe (int filedes[2], estream_t *r_fp, */ gpg_err_code_t _gpgrt_spawn_actions_new (gpgrt_spawn_actions_t *r_act); void _gpgrt_spawn_actions_release (gpgrt_spawn_actions_t act); -void _gpgrt_spawn_actions_set_envvars (gpgrt_spawn_actions_t, char **env); #ifdef HAVE_W32_SYSTEM +void _gpgrt_spawn_actions_set_envvars (gpgrt_spawn_actions_t, char *); void _gpgrt_spawn_actions_set_redirect (gpgrt_spawn_actions_t, void *, void *, void *); void _gpgrt_spawn_actions_set_inherit_handles (gpgrt_spawn_actions_t, void **); #else +void _gpgrt_spawn_actions_set_environ (gpgrt_spawn_actions_t, char **); void _gpgrt_spawn_actions_set_redirect (gpgrt_spawn_actions_t, int, int, int); void _gpgrt_spawn_actions_set_inherit_fds (gpgrt_spawn_actions_t, const int *); diff --git a/src/spawn-posix.c b/src/spawn-posix.c index f31b9c5..b784cc5 100644 --- a/src/spawn-posix.c +++ b/src/spawn-posix.c @@ -290,7 +290,7 @@ posix_open_null (int for_write) struct gpgrt_spawn_actions { int fd[3]; const int *except_fds; - char **env; + char **environ; void (*atfork) (void *); void *atfork_arg; }; @@ -323,8 +323,8 @@ my_exec (const char *pgmname, const char *argv[], /* Close all other files. */ _gpgrt_close_all_fds (3, act->except_fds); - if (act->env) - environ = act->env; + if (act->environ) + environ = act->environ; if (act->atfork) act->atfork (act->atfork_arg); @@ -428,9 +428,10 @@ _gpgrt_spawn_actions_release (gpgrt_spawn_actions_t act) } void -_gpgrt_spawn_actions_set_envvars (gpgrt_spawn_actions_t act, char **env) +_gpgrt_spawn_actions_set_environ (gpgrt_spawn_actions_t act, + char **environ_for_child) { - act->env = env; + act->environ = environ_for_child; } void diff --git a/src/spawn-w32.c b/src/spawn-w32.c index 72d5552..a3de3db 100644 --- a/src/spawn-w32.c +++ b/src/spawn-w32.c @@ -304,7 +304,7 @@ _gpgrt_make_pipe (int filedes[2], estream_t *r_fp, int direction, int nonblock) struct gpgrt_spawn_actions { void *hd[3]; void **inherit_hds; - char **env; + char *env; }; struct gpgrt_process { @@ -450,7 +450,7 @@ spawn_detached (const char *pgmname, char *cmdline, gpgrt_spawn_actions_t act) &sec_attr, /* Thread security attributes. */ ask_inherit, /* Inherit handles. */ cr_flags, /* Creation flags. */ - NULL, /* Environment. */ + act->env, /* Environment. */ NULL, /* Use current drive/directory. */ (STARTUPINFOW *)&si, /* Startup information. */ &pi /* Returns process information. */ @@ -517,7 +517,7 @@ _gpgrt_spawn_actions_release (gpgrt_spawn_actions_t act) } void -_gpgrt_spawn_actions_set_envvars (gpgrt_spawn_actions_t act, char **env) +_gpgrt_spawn_actions_set_envvars (gpgrt_spawn_actions_t act, char *env) { act->env = env; } @@ -786,7 +786,7 @@ _gpgrt_process_spawn (const char *pgmname, const char *argv[], &sec_attr, /* Thread security attributes. */ ask_inherit, /* Inherit handles. */ cr_flags, /* Creation flags. */ - NULL, /* Environment. */ + act->env, /* Environment. */ NULL, /* Use current drive/directory. */ (STARTUPINFOW *)&si, /* Startup information. */ &pi /* Returns process information. */ |