mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
Add quote support to pre/post/ready/cleanup scripts
- Allow scripts to take space separated arguments with quoting - Simplify script-exists check, which already checks for leading / - Unset current script on parse error - Allow setting no timeout Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 file changed
+20
-10
+20
-10
@@ -1386,26 +1386,36 @@ static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *b
|
|||||||
if (errstr) {
|
if (errstr) {
|
||||||
errx(1, "%s: tmo %s is %s (0-3600)", svc_ident(svc, NULL, 0),
|
errx(1, "%s: tmo %s is %s (0-3600)", svc_ident(svc, NULL, 0),
|
||||||
script, errstr);
|
script, errstr);
|
||||||
return;
|
goto err;
|
||||||
}
|
}
|
||||||
*tmo = (int)(sec * 1000);
|
*tmo = (int)(sec * 1000);
|
||||||
} else {
|
} else {
|
||||||
path = script;
|
path = script;
|
||||||
*tmo = svc->killdelay;
|
if (tmo)
|
||||||
|
*tmo = svc->killdelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unquote(&path, NULL)) {
|
||||||
|
errx(1, "Syntax error, unterminated quote in %s:%s", type, path);
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = which(path);
|
found = which(path);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
/* Not in $PATH, check if path exists and is executable */
|
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.", type, path);
|
||||||
if (access(path, X_OK)) {
|
goto err;
|
||||||
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.",
|
}
|
||||||
type, path);
|
free(found);
|
||||||
return;
|
|
||||||
}
|
if (strlen(path) >= len) {
|
||||||
} else
|
errx(1, "Command too long in %s:%s", type, path);
|
||||||
free(found);
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
strlcpy(buf, path, len);
|
strlcpy(buf, path, len);
|
||||||
|
return;
|
||||||
|
err:
|
||||||
|
memset(buf, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in new issue
Block a user