[gnome-builder] subprocess: Correctly clear environment of subprocesses
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] subprocess: Correctly clear environment of subprocesses
- Date: Fri, 10 Feb 2017 00:41:08 +0000 (UTC)
commit e10579feea2b94995371e072d1e83db30a624a5c
Author: Matthew Leeds <mleeds redhat com>
Date: Thu Feb 9 18:25:47 2017 -0600
subprocess: Correctly clear environment of subprocesses
Setting the GSubprocessLauncher's environ member to NULL doesn't end up
clearing the inherited env vars (because glib uses execv rather than
execve if envp is NULL). So instead we set it to a dummy array.
libide/subprocess/ide-subprocess-launcher.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/libide/subprocess/ide-subprocess-launcher.c b/libide/subprocess/ide-subprocess-launcher.c
index 6e4a0e9..cb8c1c0 100644
--- a/libide/subprocess/ide-subprocess-launcher.c
+++ b/libide/subprocess/ide-subprocess-launcher.c
@@ -267,9 +267,14 @@ ide_subprocess_launcher_spawn_worker (GTask *task,
/*
* GSubprocessLauncher starts by inheriting the current environment.
* So if clear-env is set, we need to unset those environment variables.
+ * Simply setting the environ to NULL doesn't work, because glib uses
+ * execv rather than execve in that case.
*/
if (priv->clear_env)
- g_subprocess_launcher_set_environ (launcher, NULL);
+ {
+ gchar *envp[] = { NULL };
+ g_subprocess_launcher_set_environ (launcher, envp);
+ }
/*
* Now override any environment variables that were set using
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]