summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--grammar/rainerscript.c37
-rw-r--r--tests/Makefile.am10
-rwxr-xr-xtests/diag.sh4
-rwxr-xr-xtests/incltest.sh11
-rwxr-xr-xtests/incltest_dir.sh11
-rwxr-xr-xtests/incltest_dir_wildcard.sh11
-rw-r--r--tests/testsuites/incltest.conf5
-rw-r--r--tests/testsuites/incltest.d/include.conf2
-rw-r--r--tests/testsuites/incltest_dir.conf5
-rw-r--r--tests/testsuites/incltest_dir_wildcard.conf5
11 files changed, 86 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index bccb6395..2b057c30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,11 @@ Version 6.6.1 [v6-stable] 2012-10-??
This did not affect users, but could have caused trouble in the future
for developers.
- bugfix: no error msg on invalid field option in legacy/string template
+- bugfix: no error msg on unreadable $IncludeConfig path
+- bugfix: $IncludeConfig did not correctly process directories
+ closes: http://bugzilla.adiscon.com/show_bug.cgi?id=376
+ The testbench was also enhanced to check for these cases.
+ Thanks to Georgi Georgiev for the bug report.
---------------------------------------------------------------------------
Version 6.6.0 [v6-stable] 2012-10-22
This starts a new stable branch, based on the 6.5.x series, plus:
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 9e0d04c7..072bdd5d 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -680,7 +680,6 @@ nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
vals = NULL;
}
-dbgprintf("DDDD: vals %p\n", vals);
return vals;
}
@@ -1818,24 +1817,29 @@ int
cnfDoInclude(char *name)
{
char *cfgFile;
+ char *finalName;
unsigned i;
int result;
glob_t cfgFiles;
struct stat fileInfo;
-
- /* Use GLOB_MARK to append a trailing slash for directories.
- * Required by doIncludeDirectory().
- */
- result = glob(name, GLOB_MARK, NULL, &cfgFiles);
- if(result == GLOB_NOSPACE || result == GLOB_ABORTED) {
-#if 0
+ char nameBuf[MAXFNAME+1];
+
+ finalName = name;
+ if(stat(name, &fileInfo) == 0) {
+ /* stat usually fails if we have a wildcard - so this does NOT indicate error! */
+ if(S_ISDIR(fileInfo.st_mode)) {
+ /* if we have a directory, we need to add "*" to get its files */
+ snprintf(nameBuf, sizeof(nameBuf), "%s*", name);
+ finalName = nameBuf;
+ }
+ }
+ /* 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) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
- errmsg.LogError(0, RS_RET_FILE_NOT_FOUND, "error accessing config file or directory '%s': %s",
- pattern, errStr);
- ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
-#endif
- dbgprintf("includeconfig glob error %d\n", errno);
+ parser_errmsg("error accessing config file or directory '%s': %s",
+ finalName, errStr);
return 1;
}
@@ -1849,11 +1853,8 @@ cnfDoInclude(char *name)
dbgprintf("requested to include config file '%s'\n", cfgFile);
cnfSetLexFile(cfgFile);
} else if(S_ISDIR(fileInfo.st_mode)) { /* config directory */
- if(strcmp(name, cfgFile)) {
- /* do not include ourselves! */
- dbgprintf("requested to include directory '%s'\n", cfgFile);
- cnfDoInclude(cfgFile);
- }
+ dbgprintf("requested to include directory '%s'\n", cfgFile);
+ cnfDoInclude(cfgFile);
} else {
dbgprintf("warning: unable to process IncludeConfig directive '%s'\n", cfgFile);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a9369929..e7122653 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,6 +65,9 @@ TESTS += \
failover-no-basic.sh \
rcvr_fail_restore.sh \
rscript_contains.sh \
+ incltest.sh \
+ incltest_dir.sh \
+ incltest_dir_wildcard.sh \
linkedlistqueue.sh
if HAVE_VALGRIND
@@ -267,6 +270,13 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/arrayqueue.conf \
rscript_contains.sh \
testsuites/rscript_contains.conf \
+ incltest.sh \
+ testsuites/incltest.conf \
+ incltest_dir.sh \
+ testsuites/incltest_dir.conf \
+ incltest_dir_wildcard.sh \
+ testsuites/incltest_dir_wildcard.conf \
+ testsuites/incltest.d/include.conf \
linkedlistqueue.sh \
testsuites/linkedlistqueue.conf \
da-mainmsg-q.sh \
diff --git a/tests/diag.sh b/tests/diag.sh
index bd38b29d..02b24c5b 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -10,8 +10,8 @@
#valgrind="valgrind --tool=helgrind --log-fd=1"
#valgrind="valgrind --tool=exp-ptrcheck --log-fd=1"
#set -o xtrace
-#export RSYSLOG_DEBUG="debug nologfuncflow noprintmutexaction nostdout"
-#export RSYSLOG_DEBUGLOG="log"
+export RSYSLOG_DEBUG="debug nologfuncflow noprintmutexaction nostdout"
+export RSYSLOG_DEBUGLOG="log"
case $1 in
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
cp $srcdir/testsuites/diag-common.conf diag-common.conf
diff --git a/tests/incltest.sh b/tests/incltest.sh
new file mode 100755
index 00000000..8e3fe454
--- /dev/null
+++ b/tests/incltest.sh
@@ -0,0 +1,11 @@
+echo ===============================================================================
+echo \[incltest.sh\]: test $IncludeConfig for specific file
+
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup incltest.conf
+# 100 messages are enough - the question is if the include is read ;)
+source $srcdir/diag.sh injectmsg 0 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 99
+source $srcdir/diag.sh exit
diff --git a/tests/incltest_dir.sh b/tests/incltest_dir.sh
new file mode 100755
index 00000000..3716a695
--- /dev/null
+++ b/tests/incltest_dir.sh
@@ -0,0 +1,11 @@
+echo ===============================================================================
+echo \[incltest_dir.sh\]: test $IncludeConfig for directories
+
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup incltest_dir.conf
+# 100 messages are enough - the question is if the include is read ;)
+source $srcdir/diag.sh injectmsg 0 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 99
+source $srcdir/diag.sh exit
diff --git a/tests/incltest_dir_wildcard.sh b/tests/incltest_dir_wildcard.sh
new file mode 100755
index 00000000..0dcad34d
--- /dev/null
+++ b/tests/incltest_dir_wildcard.sh
@@ -0,0 +1,11 @@
+echo ===============================================================================
+echo \[incltest_dir_wildcard.sh\]: test $IncludeConfig for directories with wildcards
+
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup incltest_dir_wildcard.conf
+# 100 messages are enough - the question is if the include is read ;)
+source $srcdir/diag.sh injectmsg 0 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 99
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/incltest.conf b/tests/testsuites/incltest.conf
new file mode 100644
index 00000000..737018cd
--- /dev/null
+++ b/tests/testsuites/incltest.conf
@@ -0,0 +1,5 @@
+# see .sh file for description
+# rgerhards, 2009-11-30
+$IncludeConfig diag-common.conf
+
+$IncludeConfig testsuites/incltest.d/include.conf
diff --git a/tests/testsuites/incltest.d/include.conf b/tests/testsuites/incltest.d/include.conf
new file mode 100644
index 00000000..39a2ea70
--- /dev/null
+++ b/tests/testsuites/incltest.d/include.conf
@@ -0,0 +1,2 @@
+$template outfmt,"%msg:F,58:2%\n"
+:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/incltest_dir.conf b/tests/testsuites/incltest_dir.conf
new file mode 100644
index 00000000..421349d2
--- /dev/null
+++ b/tests/testsuites/incltest_dir.conf
@@ -0,0 +1,5 @@
+# see .sh file for description
+# rgerhards, 2009-11-30
+$IncludeConfig diag-common.conf
+
+$IncludeConfig testsuites/incltest.d/
diff --git a/tests/testsuites/incltest_dir_wildcard.conf b/tests/testsuites/incltest_dir_wildcard.conf
new file mode 100644
index 00000000..0d7e6782
--- /dev/null
+++ b/tests/testsuites/incltest_dir_wildcard.conf
@@ -0,0 +1,5 @@
+# see .sh file for description
+# rgerhards, 2009-11-30
+$IncludeConfig diag-common.conf
+
+$IncludeConfig testsuites/incltest.d/*.conf