mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-15 10:30:40 +01:00
The spec for the omprog interaction with the program it calls specifies that the program receives one message via one line. In other words: it must be a string terminated by LF. However, omprog does currently rely on a proper template to fulfill this requirement, If the template does not provide for the LF, it is never written. For the called program, this looks like it does not receive any input at all. Even if it finally reads data (e.g. due to full buffer), it will not properly be able to discern the messages. This handling is improved with this commit. We cannot just check the template, because at the end of the template may by a non-constant value. As such, we do not know at config load time if there is this problem or not. So the correct approach is to, during runtime, check if each message is properly terminated. For those that are not: * we append a LF, because anything else makes matters worse * log a warning message, at least for a sample of the messages The warning is useful in the (expected most often) case that the template is simply missing the LF. While appending works, it slows down processing. As such the user should be given a chance to correct the config bug. To avoid clutter, the warning is emitted at most once every 30 seconds. This value is hardcoded as we do not envison a need to adjust it. Usually users should quickly fix the template. closes https://github.com/rsyslog/rsyslog/issues/3975
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# This file is part of the rsyslog project, released under ASL 2.0
|
|
# This test tests omprog if omprog detects errors in the calling
|
|
# interface, namely a missing LF on input messages
|
|
. ${srcdir:=.}/diag.sh init
|
|
generate_conf
|
|
add_conf '
|
|
module(load="../plugins/omprog/.libs/omprog")
|
|
|
|
template(name="outfmt" type="string" string="%msg%")
|
|
|
|
if (prifilt("local4.*") and $msg contains "msgnum:") then {
|
|
action(type="omprog" binary="'$srcdir'/testsuites/omprog-defaults-bin.sh p1 p2 p3"
|
|
template="outfmt" name="omprog_action")
|
|
} else {
|
|
action(type="omfile" file="'$RSYSLOG_DYNNAME'.othermsg")
|
|
}
|
|
'
|
|
startup
|
|
injectmsg 0 10
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
cat $RSYSLOG_DYNNAME.othermsg
|
|
|
|
content_check 'must be terminated with \n' $RSYSLOG_DYNNAME.othermsg
|
|
|
|
export EXPECTED="Starting with parameters: p1 p2 p3
|
|
Received msgnum:00000000:
|
|
Received msgnum:00000001:
|
|
Received msgnum:00000002:
|
|
Received msgnum:00000003:
|
|
Received msgnum:00000004:
|
|
Received msgnum:00000005:
|
|
Received msgnum:00000006:
|
|
Received msgnum:00000007:
|
|
Received msgnum:00000008:
|
|
Received msgnum:00000009:
|
|
Terminating normally"
|
|
|
|
cmp_exact $RSYSLOG_OUT_LOG
|
|
exit_test
|