diff --git a/NEWS b/NEWS index da3ba78..cc957f4 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ * Version (not released, yet) - m-kress: -- add missing brackets to harmonize code + -- check (stat) the program path given as command and ignore the command, if not existing - auouymous: -- fix behavior of (program_)?regex and (program_)?neg_regex conditions - LonEox78: diff --git a/man/metalog.conf.5.in b/man/metalog.conf.5.in index 5b1b43d..0b003bf 100644 --- a/man/metalog.conf.5.in +++ b/man/metalog.conf.5.in @@ -146,6 +146,9 @@ Set to \fI0\fR to filter out repeat log messages. Run the specified program as soon as something is logged in a given section. The program is passed the date, the matching program name, and the log message. + +In case the program doesn't exist at metalog startup, metalog will not exit and +just ignore that config line. .TP \fBstamp_fmt\fR = \fI"%b %e %T"\fR Format of the human readable timestamp prepended to all log messages. diff --git a/src/metalog.c b/src/metalog.c index 34e55c7..7f19165 100644 --- a/src/metalog.c +++ b/src/metalog.c @@ -267,6 +267,25 @@ static int parseLine(char * const line, ConfigBlock **cur_block, (void) 0; } else if (strcasecmp(keyword, "command") == 0) { + char *command = NULL; + struct stat st; + char *p = NULL; + + if ((command = wstrdup(value)) == NULL) { + return -3; + } + + p = strchr(command, (int) ' '); + if (p != NULL) { + *p = '\0'; + } + if (stat(command, &st) < 0) { + warnp("Ignoring command \"%s\"", command); + free(command); + return 0; + } + free(command); + if (((*cur_block)->command = wstrdup(value)) == NULL) { return -3; }