summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-05-30 08:37:35 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-05-30 08:37:35 +0200
commit7c12000d865b0885c2d5125f14742a54e41a270c (patch)
treee4983ca443c21fa54c20987ca39f523f32bf7554
parenta9223031a6effeaf3673beb752c12a29f5e8f83d (diff)
downloadrsyslog-7c12000d865b0885c2d5125f14742a54e41a270c.tar.gz
rsyslog-7c12000d865b0885c2d5125f14742a54e41a270c.tar.xz
rsyslog-7c12000d865b0885c2d5125f14742a54e41a270c.zip
regression fix: config validation code affected by recent changes
did not return with proper return value
-rw-r--r--runtime/rsconf.c15
-rwxr-xr-xtests/validation-run.sh3
-rw-r--r--tools/syslogd.c4
3 files changed, 17 insertions, 5 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 0f944539..ed6e9ee7 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -1003,7 +1003,7 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
localRet = conf.processConfFile(loadConf, confFile);
CHKiRet(conf.GetNbrActActions(loadConf, &iNbrActions));
- if(localRet != RS_RET_OK) {
+ if(localRet != RS_RET_OK && localRet != RS_RET_NONFATAL_CONFIG_ERR) {
errmsg.LogError(0, localRet, "CONFIG ERROR: could not interpret master config file '%s'.", confFile);
bHadConfigErr = 1;
} else if(iNbrActions == 0) {
@@ -1042,12 +1042,20 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
CHKiRet(validateConf());
+
+ /* return warning state if we had some acceptable problems */
+ if(bHadConfigErr) {
+ iRet = RS_RET_NONFATAL_CONFIG_ERR;
+ }
+
/* we are done checking the config - now validate if we should actually run or not.
* If not, terminate. -- rgerhards, 2008-07-25
* TODO: iConfigVerify -- should it be pulled from the config, or leave as is (option)?
*/
if(iConfigVerify) {
- ABORT_FINALIZE(RS_RET_VALIDATION_RUN);
+ if(iRet == RS_RET_OK)
+ iRet = RS_RET_VALIDATION_RUN;
+ FINALIZE;
}
/* all OK, pass loaded conf to caller */
@@ -1057,9 +1065,6 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
dbgprintf("rsyslog finished loading initial config %p\n", loadConf);
rsconfDebugPrint(loadConf);
- /* return warning state if we had some acceptable problems */
- if(bHadConfigErr)
- iRet = RS_RET_NONFATAL_CONFIG_ERR;
finalize_it:
RETiRet;
}
diff --git a/tests/validation-run.sh b/tests/validation-run.sh
index cc29482a..a68ee8ae 100755
--- a/tests/validation-run.sh
+++ b/tests/validation-run.sh
@@ -25,16 +25,19 @@ echo \[validation-run.sh\]: testing configuraton validation
echo "testing a failed configuration verification run"
../tools/rsyslogd -dn -u2 -c4 -N1 -f$srcdir/testsuites/invalid.conf -M../runtime/.libs:../.libs
if [ $? -ne 1 ]; then
+ echo "after test 1: return code ne 1"
exit 1
fi
echo testing a valid config verification run
../tools/rsyslogd -u2 -c4 -N1 -f$srcdir/testsuites/valid.conf -M../runtime/.libs:../.libs
if [ $? -ne 0 ]; then
+ echo "after test 2: return code ne 0"
exit 1
fi
echo testing empty config file
../tools/rsyslogd -u2 -c4 -N1 -f/dev/null -M../runtime/.libs:../.libs
if [ $? -ne 1 ]; then
+ echo "after test 3: return code ne 1"
exit 1
fi
echo SUCCESS: validation run tests
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 4fe6fa26..4c512ac2 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -2165,6 +2165,10 @@ int realMain(int argc, char **argv)
"startup with a dirty config.\n");
exit(2);
}
+ if(iConfigVerify) {
+ /* a bit dirty, but useful... */
+ exit(1);
+ }
localRet = RS_RET_OK;
}
CHKiRet(localRet);