Allow interpreted daemons to detect interperter options.
This commit is contained in:
@ -866,19 +866,27 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
fgets(line, sizeof(line), fp);
|
fgets(line, sizeof(line), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (line[0] == '#' && line[1] == '!') {
|
if (line[0] == '#' && line[1] == '!') {
|
||||||
|
p = line + 2;
|
||||||
|
/* Strip leading spaces */
|
||||||
|
while (*p == ' ')
|
||||||
|
p++;
|
||||||
/* Remove the trailing newline */
|
/* Remove the trailing newline */
|
||||||
len = strlen(line) - 1;
|
len = strlen(p) - 1;
|
||||||
if (line[len] == '\n')
|
if (p[len] == '\n')
|
||||||
line[len] = '\0';
|
p[len] = '\0';
|
||||||
strncpy(exec_file, line + 2, sizeof(exec_file));
|
token = strsep(&p, " ");
|
||||||
|
strncpy(exec_file, token, sizeof(exec_file));
|
||||||
|
token = strsep(&p, " ");
|
||||||
opt = 0;
|
opt = 0;
|
||||||
for (nav = argv; *nav; nav++)
|
for (nav = argv; *nav; nav++)
|
||||||
opt++;
|
opt++;
|
||||||
nav = xmalloc(sizeof(char *) * (opt + 2));
|
nav = xmalloc(sizeof(char *) * (opt + token ? 3 : 2));
|
||||||
nav[0] = exec_file;
|
nav[0] = exec_file;
|
||||||
|
if (token)
|
||||||
|
nav[1] = token;
|
||||||
for (i = 0; i < opt; i++)
|
for (i = 0; i < opt; i++)
|
||||||
nav[i + 1] = argv[i];
|
nav[i + token ? 2 : 1] = argv[i];
|
||||||
nav[i + 1] = '\0';
|
nav[i + token ? 2 : 1] = '\0';
|
||||||
argv = nav;
|
argv = nav;
|
||||||
exec = exec_file;
|
exec = exec_file;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user