]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: abort when include directive fails
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 20 Jun 2017 15:43:26 +0000 (17:43 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Jun 2017 13:29:01 +0000 (15:29 +0200)
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

diff --git a/conf.c b/conf.c
index 2b9d37658851323ba2f5b9af2f6c2ca5fb96d5c1..f5583fa8575d43a0bb4fca3df2f4c679ec11ae11 100644 (file)
--- 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;
   }