/*
- Copyright 2015 IoT.bzh
+ Copyright 2015, 2016, 2017 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
*/
static const int ready_timeout = 1500;
+#if defined(DUMP_LAUNCHERS)
/*
* dump all the known launchers to the 'file'
*/
fprintf(file, "\n");
}
}
+#endif
/*
* update 'cread' to point the the next token
)
{
int rc;
- char **args;
+ char **args, **env;
pid_t pid;
int rpipe[2];
struct pollfd pfd;
/* 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;
close(rpipe[0]);
close(rpipe[1]);
free(args);
+ free(env);
ERROR("master fork failed: %m");
return -1;
}
close(rpipe[1]);
free(args);
+ free(env);
pfd.fd = rpipe[0];
pfd.events = POLLIN;
close(rpipe[0]);
+ /* set name by appid */
+ verbose_set_name(desc->appid, 0);
+
/* avoid set-gid effect */
setresgid(groupid, groupid, groupid);
}
/* executes the process */
- rc = execve(args[0], args, environ);
+ rc = execve(args[0], args, env);
+ access(args[0], X_OK);
ERROR("failed to exec master %s: %m", args[0]);
_exit(1);
return -1;
for (dl = launchers ; dl ; dl = dl->next)
if (dl->mode == mode)
for (tl = dl->types ; tl != NULL ; tl = tl->next)
- if (!strcmp(tl->type, type))
+ if (!strcasecmp(tl->type, type))
return dl;
return NULL;
}
else
groupid = (gid_t)-1;
+ /* reads the configuration file */
rc = read_configuration_file(FWK_LAUNCH_CONF);
- /* dump_launchers(stderr); */
+#if defined(DUMP_LAUNCHERS)
+ if (!rc)
+ dump_launchers(stderr);
+#endif
+
return rc;
}