Rainer Gerhards 4a63f8e962
rscript fix: ruleset called async when ruleset had queue.type="direct"
The call rscript statement is able to call a rule set either synchronously or
asynchronously. We did this, because practice showed that both modes
are needed. For various reasons we decided to make async
calls if the ruleset has a queue assigned and sync if not.

To know if a "queue is assigned" we just checked if queue parameters were
given. It was overlookeded the case of someone explicitly specifying a
"direct  queue", aka "no queue". As such, queue="direct" triggered async
calls. That in turn meant that when a write operation to a variable was
made inside that rule set, other rulesets could or could not see the
write. While if was often not seen, this was a data race where the
change could also be seen by the outside.

This is now fixed. No matter if queue.type="direct" is specified or
left out, the call will always by synchronous. Any values written to
variables will also be seen by the "outside world" in later processing
stages.

Note that this has some potential to BREAK EXISTING CONFIGURATIONS.
We deem this acceptable because:

1. this was racy at all, so unexpected behaviour could alwas occur
2. it is actually unlikely that someone used the triggering conditions
   in practice. But we can not outrule this, especially when the
   configuration was auto-generated.

Potential compatibility issues can be solved by defining a small
array-memory queue on the ruleset in question instead of specifying
direct type.

Again, we expect that almost all users will never experience any
problems. If you do, however, please let us know: we may add an
option to re-enable the bug.
2021-10-11 15:07:16 +02:00
..
2009-10-21 15:17:19 +02:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-11 16:30:26 +01:00
2018-11-14 11:56:57 -05:00
2018-11-14 11:56:57 -05:00
2018-11-14 11:56:57 -05:00
2018-11-14 11:56:57 -05:00
2019-12-27 13:57:25 +01:00
2019-12-27 14:14:54 +01:00
2018-11-14 11:56:57 -05:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2018-10-20 10:58:04 +02:00
2009-03-16 18:54:42 +01:00
2019-12-27 13:57:25 +01:00
2019-08-20 09:11:16 +02:00
2020-01-19 16:09:44 +01:00
2019-07-30 09:00:01 +02:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-08 10:22:29 +01:00
2019-12-27 13:57:25 +01:00
2021-01-18 08:58:07 +01:00
2020-01-19 16:09:44 +01:00
2019-12-27 13:57:25 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2019-12-27 13:57:25 +01:00
2018-11-14 11:56:57 -05:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2018-07-31 09:44:27 +02:00
2019-12-26 17:37:14 +01:00
2018-07-31 09:44:27 +02:00
2020-01-19 16:09:44 +01:00
2018-07-31 09:44:27 +02:00
2018-06-13 13:20:23 +02:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00

This directory contains the rsyslog testbench. It is slowly
evolving. New tests are always welcome. So far, most tests check
out the functionality of a single module. More complex tests are
welcome.

For a simple sample, see rtinit.c, which does a simple
init/deinit check of the runtime system.

Test Naming
===========

Test that use valgrind shall end in "-vg.sh".
Test that use valgrind's helgrind thread debugger shall end in "-vgthread.sh".

Setting up Test Environments
============================

Setting up MariaDB/MySQL
------------------------
to create the necessary user:

echo "create user 'rsyslog'@'localhost' identified by 'testbench';" | mysql -u root
mysql -u root < ../plugins/ommysql/createDB.sql
echo "grant all on Syslog.* to 'rsyslog'@'localhost';" | mysql -u root

openSUSE
--------
To configure system properties like hostname and firewall, use the
graphical "yast2" administration tool. Note the ssh-access by default
is disable in the firewall!

Before running tests
====================
make check - this will compile all of the C code used in the tests, as well as
do any other preparations, and will start running all of the tests.  Ctrl-C to
stop running all of the tests.

Running all tests
=================
make check

Running named tests
===================
make testname.sh.log

For example, to run the imfile-basic.sh test, use

make imfile-basic.sh.log

Test output is in imfile-basic.sh.log

To re-run the test, first remove imfile-basic.sh.log then make again

* Using gdb to debug rsyslog during a test run

Edit your test like this:

    . $srcdir/diag.sh startup
    if [ -n "${USE_GDB:-}" ] ; then
        echo attach gdb here
        sleep 54321 || :
    fi

Run your test in the background:

    USE_GDB=1 make mytest.sh.log &

Tail mytest.sh.log until you see 'attach gdb here'.  The log should also
tell you what is the rsyslogd pid.

   gdb ../tools/rsyslogd $rsyslogd_pid

Set breakpoints, whatever, then 'continue'

In another window, do ps -ef|grep 54321, then kill that pid

Core Dump Analysis
==================
The testbench contains some limited (yet useful) support for automatically
analyzing core dumps. In order for this to work, obviously core files need
to be generated. This often doesn't work as intended. If you hit this problem,
check

1. ulimit -c unlimited (or a reasonable limit)
   Note that root may need to increase a system-wide limit, which is
   usually recorded in /etc/security/limits.conf
   You need:
   *     soft    core      unlimited

2. cat  /proc/sys/kernel/core_pattern"
   On systemd systems (and some others), the pattern is changed to save
   core files so that systemd can import them -- with the result that the
   testbench doesn't see them any longer. We require classic format, which
   can be set via
   $ sudo bash -c "echo \"core\" > /proc/sys/kernel/core_pattern"

Note that you probably want to do neither of these changes to a production
system.