Skip to content

Commit

Permalink
Merge pull request #3658 from rgerhards/i2520
Browse files Browse the repository at this point in the history
bugfix: error messages if config.enabled="off" is used
  • Loading branch information
rgerhards committed May 14, 2019
2 parents 912c948 + 15ae6df commit f0e4258
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 6 additions & 2 deletions grammar/rainerscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ done: return r;
* it is the caller's duty to free it when no longer needed.
* NULL is returned on error, otherwise a pointer to the vals array.
*/
struct cnfparamvals*
struct cnfparamvals* ATTR_NONNULL(2)
nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
struct cnfparamvals *vals)
{
Expand Down Expand Up @@ -1213,8 +1213,12 @@ nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
if((valnode = nvlstFindNameCStr(lst, "config.enabled")) != NULL) {
if(es_strbufcmp(valnode->val.d.estr, (unsigned char*) "on", 2)) {
dbgprintf("config object disabled by configuration\n");
valnode->bUsed = 1;
/* flag all params as used to not emit error mssages */
bInError = 1;
struct nvlst *val;
for(val = lst; val != NULL ; val = val->next) {
val->bUsed = 1;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,8 @@ TESTS += \
imfile-logrotate-copytruncate.sh \
imfile-logrotate-nocopytruncate.sh \
imfile-growing-file-id.sh \
glbl-oversizeMsg-truncate-imfile.sh
glbl-oversizeMsg-truncate-imfile.sh \
config_enabled-off.sh

if ENABLE_MMNORMALIZE
TESTS += \
Expand Down Expand Up @@ -1404,6 +1405,7 @@ EXTRA_DIST= \
glbl-internalmsg_severity-debug-shown.sh \
glbl-internalmsg_severity-debug-not_shown.sh \
glbl-oversizeMsg-log-vg.sh \
config_enabled-off.sh \
empty-hostname.sh \
hostname-getaddrinfo-fail.sh \
hostname-with-slash-pmrfc5424.sh \
Expand Down
17 changes: 17 additions & 0 deletions tests/config_enabled-off.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# check disabling a config construct via config.enable. Most
# importantly ensure that it does not emit any error messages
# for object parameters.
# addd 2019-05-09 by RGerhards, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
module(load="../plugins/imfile/.libs/imfile")
input(type="imfile" file="/tmp/notyet.txt" tag="testing-tag" config.enabled="off")
action(type="omfile" file="'$RSYSLOG_OUT_LOG'")
'
startup
shutdown_when_empty
wait_shutdown
check_not_present 'parameter .* not known'
exit_test

0 comments on commit f0e4258

Please sign in to comment.