mirror of
https://github.com/troglobit/finit.git
synced 2026-10-24 11:54:36 +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) {
|
||||
errx(1, "%s: tmo %s is %s (0-3600)", svc_ident(svc, NULL, 0),
|
||||
script, errstr);
|
||||
return;
|
||||
goto err;
|
||||
}
|
||||
*tmo = (int)(sec * 1000);
|
||||
} else {
|
||||
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);
|
||||
if (!found) {
|
||||
/* Not in $PATH, check if path exists and is executable */
|
||||
if (access(path, X_OK)) {
|
||||
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.",
|
||||
type, path);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
free(found);
|
||||
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.", type, path);
|
||||
goto err;
|
||||
}
|
||||
free(found);
|
||||
|
||||
if (strlen(path) >= len) {
|
||||
errx(1, "Command too long in %s:%s", type, path);
|
||||
goto err;
|
||||
}
|
||||
|
||||
strlcpy(buf, path, len);
|
||||
return;
|
||||
err:
|
||||
memset(buf, 0, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user