Check for pre:- and post:scripts in $PATH

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2025-02-11 10:17:34 +01:00
1 parent bbc83eaa64
commit 9d8a9b7fba
1 file changed
+15 -6
+15 -6
View File
@@ -1305,7 +1305,7 @@ static void parse_killdelay(svc_t *svc, char *delay)
*/ */
static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *buf, size_t len) static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *buf, size_t len)
{ {
char *path; char *found, *path;
path = strchr(script, ','); path = strchr(script, ',');
if (path) { if (path) {
@@ -1316,7 +1316,8 @@ static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *b
sec = strtonum(script, 0, 3600, &errstr); sec = strtonum(script, 0, 3600, &errstr);
if (errstr) { if (errstr) {
errx(1, "%s: tmo %s is %s (0-3600)", svc_ident(svc, NULL, 0), script, errstr); errx(1, "%s: tmo %s is %s (0-3600)", svc_ident(svc, NULL, 0),
script, errstr);
return; return;
} }
*tmo = (int)(sec * 1000); *tmo = (int)(sec * 1000);
@@ -1325,10 +1326,18 @@ static void parse_script(svc_t *svc, char *type, char *script, int *tmo, char *b
*tmo = svc->killdelay; *tmo = svc->killdelay;
} }
if (access(path, X_OK)) found = which(path);
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.", type, path); if (!found) {
else /* Not in $PATH, check if path exists and is executable */
strlcpy(buf, path, len); if (access(path, X_OK)) {
logit(LOG_WARNING, "%s:%s is missing or not executable, skipping.",
type, path);
return;
}
} else
free(found);
strlcpy(buf, path, len);
} }
/* /*