mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-08 20:48:02 +02:00
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.
This commit is contained in:
parent
0e3ec9cec0
commit
8ec1604192
1 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue