summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-11-16 11:24:36 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-11-16 11:24:36 +0100
commitcd4ba256dd488e6dc4ebffdaa6dfcfe107c35908 (patch)
tree643ccbb05f7860bc852a392bb521a664902ae1a7
parentfbd978247d4f0d8a3f83d07af9fddc2f6a79ef82 (diff)
afm-launch: allows variable in environment
Change-Id: I57e45894ffb4e4e32e4560f8a15adc54335067d0 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afm-launch.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/afm-launch.c b/src/afm-launch.c
index 237a7ed..cdfdc41 100644
--- a/src/afm-launch.c
+++ b/src/afm-launch.c
@@ -669,7 +669,7 @@ static pid_t launch(
)
{
int rc;
- char **args;
+ char **args, **env;
pid_t pid;
int rpipe[2];
struct pollfd pfd;
@@ -684,9 +684,13 @@ static pid_t launch(
/* instanciate the arguments */
params->readyfd = rpipe[1];
args = instantiate_arguments(exec->args, desc, params, 1).vector;
- if (args == NULL) {
+ env = instantiate_arguments((const char * const*)environ,
+ desc, params, 1).vector;
+ if (args == NULL || env == NULL) {
close(rpipe[0]);
close(rpipe[1]);
+ free(args);
+ free(env);
ERROR("out of memory in master");
errno = ENOMEM;
return -1;
@@ -701,6 +705,7 @@ static pid_t launch(
close(rpipe[0]);
close(rpipe[1]);
free(args);
+ free(env);
ERROR("master fork failed: %m");
return -1;
}
@@ -710,6 +715,7 @@ static pid_t launch(
close(rpipe[1]);
free(args);
+ free(env);
pfd.fd = rpipe[0];
pfd.events = POLLIN;
@@ -759,7 +765,7 @@ static pid_t launch(
}
/* executes the process */
- rc = execve(args[0], args, environ);
+ rc = execve(args[0], args, env);
ERROR("failed to exec master %s: %m", args[0]);
_exit(1);
return -1;
@@ -934,8 +940,10 @@ int afm_launch_initialize()
else
groupid = (gid_t)-1;
+ /* reads the configuration file */
rc = read_configuration_file(FWK_LAUNCH_CONF);
/* dump_launchers(stderr); */
+
return rc;
}