summaryrefslogtreecommitdiffstats
path: root/grammar/rainerscript.c
diff options
context:
space:
mode:
authorGeorgi Georgiev <chutzimir@gmail.com>2012-11-13 09:40:32 +0900
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-13 16:55:35 +0100
commit0f6300f1e6a038f37c406b2362218ea043def55b (patch)
treeaf78a9abf90524ab4c925fc94f4726f36d372d9c /grammar/rainerscript.c
parent7b2d8906a4d615bc84cee9e784de0fe884811840 (diff)
downloadrsyslog-0f6300f1e6a038f37c406b2362218ea043def55b.tar.gz
rsyslog-0f6300f1e6a038f37c406b2362218ea043def55b.tar.bz2
rsyslog-0f6300f1e6a038f37c406b2362218ea043def55b.zip
Silently ignore wildcard includes that match nothing
This will avoid an error message when including an empty directory.
Diffstat (limited to 'grammar/rainerscript.c')
-rw-r--r--grammar/rainerscript.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 39ff6df3..e54c9060 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -2778,8 +2778,15 @@ cnfDoInclude(char *name)
}
}
/* Use GLOB_MARK to append a trailing slash for directories. */
- result = glob(finalName, GLOB_MARK, NULL, &cfgFiles);
- if(result == GLOB_NOSPACE || result == GLOB_ABORTED || cfgFiles.gl_pathc == 0) {
+ /* Use GLOB_NOMAGIC to detect wildcards that match nothing. */
+ result = glob(finalName, GLOB_MARK | GLOB_NOMAGIC, NULL, &cfgFiles);
+
+ /* Silently ignore wildcards that match nothing */
+ if(result == GLOB_NOMATCH) {
+ return 1;
+ }
+
+ if(result == GLOB_NOSPACE || result == GLOB_ABORTED) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
parser_errmsg("error accessing config file or directory '%s': %s",
@@ -2790,8 +2797,13 @@ cnfDoInclude(char *name)
for(i = 0; i < cfgFiles.gl_pathc; i++) {
cfgFile = cfgFiles.gl_pathv[i];
- if(stat(cfgFile, &fileInfo) != 0)
- continue; /* continue with the next file if we can't stat() the file */
+ if(stat(cfgFile, &fileInfo) != 0)
+ {
+ char errStr[1024];
+ rs_strerror_r(errno, errStr, sizeof(errStr));
+ parser_errmsg("error accessing config file or directory '%s': %s",
+ cfgFile, errStr);
+ }
if(S_ISREG(fileInfo.st_mode)) { /* config file */
dbgprintf("requested to include config file '%s'\n", cfgFile);