mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-15 10:30:40 +01:00
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. Also minor bugfix: no error msg on unreadable $IncludeConfig path
This commit is contained in:
parent
b05d4a6db4
commit
dc8f9b531c
@ -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
|
This did not affect users, but could have caused trouble in the future
|
||||||
for developers.
|
for developers.
|
||||||
- bugfix: no error msg on invalid field option in legacy/string template
|
- 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
|
Version 6.6.0 [v6-stable] 2012-10-22
|
||||||
This starts a new stable branch, based on the 6.5.x series, plus:
|
This starts a new stable branch, based on the 6.5.x series, plus:
|
||||||
|
|||||||
@ -680,7 +680,6 @@ nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
|
|||||||
vals = NULL;
|
vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgprintf("DDDD: vals %p\n", vals);
|
|
||||||
return vals;
|
return vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1818,24 +1817,29 @@ int
|
|||||||
cnfDoInclude(char *name)
|
cnfDoInclude(char *name)
|
||||||
{
|
{
|
||||||
char *cfgFile;
|
char *cfgFile;
|
||||||
|
char *finalName;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int result;
|
int result;
|
||||||
glob_t cfgFiles;
|
glob_t cfgFiles;
|
||||||
struct stat fileInfo;
|
struct stat fileInfo;
|
||||||
|
char nameBuf[MAXFNAME+1];
|
||||||
|
|
||||||
/* Use GLOB_MARK to append a trailing slash for directories.
|
finalName = name;
|
||||||
* Required by doIncludeDirectory().
|
if(stat(name, &fileInfo) == 0) {
|
||||||
*/
|
/* stat usually fails if we have a wildcard - so this does NOT indicate error! */
|
||||||
result = glob(name, GLOB_MARK, NULL, &cfgFiles);
|
if(S_ISDIR(fileInfo.st_mode)) {
|
||||||
if(result == GLOB_NOSPACE || result == GLOB_ABORTED) {
|
/* if we have a directory, we need to add "*" to get its files */
|
||||||
#if 0
|
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];
|
char errStr[1024];
|
||||||
rs_strerror_r(errno, errStr, sizeof(errStr));
|
rs_strerror_r(errno, errStr, sizeof(errStr));
|
||||||
errmsg.LogError(0, RS_RET_FILE_NOT_FOUND, "error accessing config file or directory '%s': %s",
|
parser_errmsg("error accessing config file or directory '%s': %s",
|
||||||
pattern, errStr);
|
finalName, errStr);
|
||||||
ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
|
|
||||||
#endif
|
|
||||||
dbgprintf("includeconfig glob error %d\n", errno);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1849,11 +1853,8 @@ cnfDoInclude(char *name)
|
|||||||
dbgprintf("requested to include config file '%s'\n", cfgFile);
|
dbgprintf("requested to include config file '%s'\n", cfgFile);
|
||||||
cnfSetLexFile(cfgFile);
|
cnfSetLexFile(cfgFile);
|
||||||
} else if(S_ISDIR(fileInfo.st_mode)) { /* config directory */
|
} else if(S_ISDIR(fileInfo.st_mode)) { /* config directory */
|
||||||
if(strcmp(name, cfgFile)) {
|
dbgprintf("requested to include directory '%s'\n", cfgFile);
|
||||||
/* do not include ourselves! */
|
cnfDoInclude(cfgFile);
|
||||||
dbgprintf("requested to include directory '%s'\n", cfgFile);
|
|
||||||
cnfDoInclude(cfgFile);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dbgprintf("warning: unable to process IncludeConfig directive '%s'\n", cfgFile);
|
dbgprintf("warning: unable to process IncludeConfig directive '%s'\n", cfgFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,9 @@ TESTS += \
|
|||||||
failover-no-basic.sh \
|
failover-no-basic.sh \
|
||||||
rcvr_fail_restore.sh \
|
rcvr_fail_restore.sh \
|
||||||
rscript_contains.sh \
|
rscript_contains.sh \
|
||||||
|
incltest.sh \
|
||||||
|
incltest_dir.sh \
|
||||||
|
incltest_dir_wildcard.sh \
|
||||||
linkedlistqueue.sh
|
linkedlistqueue.sh
|
||||||
|
|
||||||
if HAVE_VALGRIND
|
if HAVE_VALGRIND
|
||||||
@ -267,6 +270,13 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
|
|||||||
testsuites/arrayqueue.conf \
|
testsuites/arrayqueue.conf \
|
||||||
rscript_contains.sh \
|
rscript_contains.sh \
|
||||||
testsuites/rscript_contains.conf \
|
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 \
|
linkedlistqueue.sh \
|
||||||
testsuites/linkedlistqueue.conf \
|
testsuites/linkedlistqueue.conf \
|
||||||
da-mainmsg-q.sh \
|
da-mainmsg-q.sh \
|
||||||
|
|||||||
@ -10,8 +10,8 @@
|
|||||||
#valgrind="valgrind --tool=helgrind --log-fd=1"
|
#valgrind="valgrind --tool=helgrind --log-fd=1"
|
||||||
#valgrind="valgrind --tool=exp-ptrcheck --log-fd=1"
|
#valgrind="valgrind --tool=exp-ptrcheck --log-fd=1"
|
||||||
#set -o xtrace
|
#set -o xtrace
|
||||||
#export RSYSLOG_DEBUG="debug nologfuncflow noprintmutexaction nostdout"
|
export RSYSLOG_DEBUG="debug nologfuncflow noprintmutexaction nostdout"
|
||||||
#export RSYSLOG_DEBUGLOG="log"
|
export RSYSLOG_DEBUGLOG="log"
|
||||||
case $1 in
|
case $1 in
|
||||||
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
|
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
|
||||||
cp $srcdir/testsuites/diag-common.conf diag-common.conf
|
cp $srcdir/testsuites/diag-common.conf diag-common.conf
|
||||||
|
|||||||
11
tests/incltest.sh
Executable file
11
tests/incltest.sh
Executable file
@ -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
|
||||||
11
tests/incltest_dir.sh
Executable file
11
tests/incltest_dir.sh
Executable file
@ -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
|
||||||
11
tests/incltest_dir_wildcard.sh
Executable file
11
tests/incltest_dir_wildcard.sh
Executable file
@ -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
|
||||||
5
tests/testsuites/incltest.conf
Normal file
5
tests/testsuites/incltest.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# see .sh file for description
|
||||||
|
# rgerhards, 2009-11-30
|
||||||
|
$IncludeConfig diag-common.conf
|
||||||
|
|
||||||
|
$IncludeConfig testsuites/incltest.d/include.conf
|
||||||
2
tests/testsuites/incltest.d/include.conf
Normal file
2
tests/testsuites/incltest.d/include.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$template outfmt,"%msg:F,58:2%\n"
|
||||||
|
:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt
|
||||||
5
tests/testsuites/incltest_dir.conf
Normal file
5
tests/testsuites/incltest_dir.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# see .sh file for description
|
||||||
|
# rgerhards, 2009-11-30
|
||||||
|
$IncludeConfig diag-common.conf
|
||||||
|
|
||||||
|
$IncludeConfig testsuites/incltest.d/
|
||||||
5
tests/testsuites/incltest_dir_wildcard.conf
Normal file
5
tests/testsuites/incltest_dir_wildcard.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# see .sh file for description
|
||||||
|
# rgerhards, 2009-11-30
|
||||||
|
$IncludeConfig diag-common.conf
|
||||||
|
|
||||||
|
$IncludeConfig testsuites/incltest.d/*.conf
|
||||||
Loading…
x
Reference in New Issue
Block a user