From cc507bffae8ce8215fb3c14fc63b070be7418bbd Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 20 Jun 2017 17:43:26 +0200 Subject: [PATCH] conf: abort when include directive fails When parsing the include directive, call glob() with the GLOB_ERR and GLOB_NOMAGIC flags, and abort with an error message when matching of the pattern failed with other error than GLOB_NOMATCH. This restores the original behavior of the directive when it didn't allow patterns, but it will still not fail with patterns not matching any files in an existing directory. --- conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 2b9d376..f5583fa 100644 --- a/conf.c +++ b/conf.c @@ -1324,10 +1324,14 @@ parse_include(char *line) { glob_t gl; size_t i; + int r; check_number_of_args(line, 1); - if (glob(line, 0, NULL, &gl)) { + if ((r = glob(line, GLOB_ERR | GLOB_NOMAGIC, NULL, &gl)) != 0) { + if (r != GLOB_NOMATCH) + LOG_FATAL("Could not search for files matching %s", line); + DEBUG_LOG("glob of %s failed", line); return; }