summaryrefslogtreecommitdiff
path: root/src/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-08 04:09:59 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-08 04:09:59 +0200
commitfab56fc541cebdbbc4cc273c3f0807eb7807b9fd (patch)
treeb0c6a377c3e087000ac66ce57515571ef94f779c /src/execute.c
parent1e3ad081efda42dd1cc737ce7e98be8889c78340 (diff)
execute: support minimal environment variable replacement when executing processes
Diffstat (limited to 'src/execute.c')
-rw-r--r--src/execute.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/execute.c b/src/execute.c
index 138d38817f..955a3e2378 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -943,7 +943,7 @@ int exec_spawn(ExecCommand *command,
const char *username = NULL, *home = NULL;
uid_t uid = (uid_t) -1;
gid_t gid = (gid_t) -1;
- char **our_env = NULL, **pam_env = NULL, **final_env = NULL;
+ char **our_env = NULL, **pam_env = NULL, **final_env = NULL, **final_argv = NULL;
unsigned n_env = 0;
int saved_stdout = -1, saved_stdin = -1;
bool keep_stdout = false, keep_stdin = false;
@@ -1260,13 +1260,19 @@ int exec_spawn(ExecCommand *command,
goto fail;
}
- execve(command->path, argv, final_env);
+ if (!(final_argv = replace_env_argv(argv, final_env))) {
+ r = EXIT_MEMORY;
+ goto fail;
+ }
+
+ execve(command->path, final_argv, final_env);
r = EXIT_EXEC;
fail:
strv_free(our_env);
strv_free(final_env);
strv_free(pam_env);
+ strv_free(final_argv);
if (saved_stdin >= 0)
close_nointr_nofail(saved_stdin);