diff options
author | Ray Strode <rstrode@redhat.com> | 2008-07-10 13:12:01 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2008-07-12 00:32:24 -0400 |
commit | 8ec160419231d68c1f6a1e03def8353e02b442a9 (patch) | |
tree | b9ae6c657346ca65236258e654427f3a2e317a68 /dbus/dbus-spawn.c | |
parent | 0e3ec9cec0f6740acd39d6e6983f419e20461282 (diff) |
When spawning processes, don't ignore the passed in environment
Previously, we'd always call execv() and unconditionally use
the environment of the parent. Now we call execve() with the
passed in environment. For compatibility, we detect if
the passed in environment is NULL and for that case, use the
environment from the parent instead.
Diffstat (limited to 'dbus/dbus-spawn.c')
-rw-r--r-- | dbus/dbus-spawn.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index d74b3265..35ccba6c 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -880,6 +880,7 @@ write_status_and_exit (int fd, int status) static void do_exec (int child_err_report_fd, char **argv, + char **envp, DBusSpawnChildSetupFunc child_setup, void *user_data) { @@ -910,8 +911,17 @@ do_exec (int child_err_report_fd, _dbus_warn ("Fd %d did not have the close-on-exec flag set!\n", i); } #endif + + if (envp == NULL) + { + extern char **environ; + + _dbus_assert (environ != NULL); + + envp = environ; + } - execv (argv[0], argv); + execve (argv[0], argv, envp); /* Exec failed */ write_err_and_exit (child_err_report_fd, @@ -1190,6 +1200,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, { do_exec (child_err_report_pipe[WRITE_END], argv, + env, child_setup, user_data); _dbus_assert_not_reached ("Got to code after exec() - should have exited on error"); } @@ -1218,6 +1229,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, else _dbus_babysitter_unref (sitter); + dbus_free_string_array (env); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); return TRUE; |