summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-12-17 14:09:16 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-12-17 14:09:16 +0000
commit7a1d5f307d88d8cf6bbf25bb465693a43809dbdd (patch)
tree772bac241c05c500bdb3b6c573b6ca3e9e5b9575
parent8dc1f57b1a59dfa4b064b00ef065e40f1df063fd (diff)
Filter cmd-line env vars.
-rw-r--r--src/app.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index ec4fb18..e3c6505 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2109,6 +2109,9 @@ execute_cmdline_lwp (App *app, char **argv, gboolean attach_dbg, GError **error)
}
if (found) {
/* override with the user's cmdline var */
+ if (strcmp (env[n], "LD_PRELOAD") == 0)
+ have_preload = TRUE;
+
continue;
}
@@ -2130,8 +2133,20 @@ execute_cmdline_lwp (App *app, char **argv, gboolean attach_dbg, GError **error)
envp[i++] = g_strconcat ("LD_PRELOAD=", lib, NULL);
if (! have_socket)
envp[i++] = g_strconcat ("LWP_PATH=unix:", path, NULL);
- while (n_client_env--)
- envp[i++] = g_strdup (*argv++);
+ while (n_client_env--) {
+ char *equals = strchr (*argv, '=');
+ g_assert (equals != NULL);
+ *equals = '\0';
+ if (strcmp (*argv, "LD_PRELOAD") == 0) {
+ envp[i++] = g_strdup_printf ("LD_PRELOAD=%s:%s", lib, equals+1);
+ } else if (strcmp (*argv, "LWP_PATH") == 0) {
+ /* ignore */
+ } else {
+ *equals = '=';
+ envp[i++] = g_strdup (*argv);
+ }
+ argv++;
+ }
envp[i] = NULL;
g_strfreev (env);