556 Commits

Author SHA1 Message Date
Rainer Gerhards
b07b45bc17
regression fix: script string comparison did not work correctly
In rscript, comparison operations on strings did not work correctly
and returned false results. This is cause by a regression in commit
5cec5dd634e0. While it fixed number comparisons, it introduced new
problems in string comparisons, which were not present before. Note
that most items in rsyslog are strings, so this can actually cause
some problems.
2022-02-18 15:08:26 +01:00
Michael Biebl
6569133c75
Typo fixes (#4801)
* typo fix: ambigious -> ambiguous

* typo fix: aquire -> acquire

* typo fix: assgined -> assigned

* typo fix: cancelation -> cancellation

* typo fix: childs -> children

* typo fix: configuraton -> configuration

* typo fix: delemiter -> delimiter

* typo fix: forwardig -> forwarding

* typo fix: initializiation -> initialization

* typo fix: intializing -> initializing

* typo fix: lengh -> length

* typo fix: mesage -> message

* typo fix: occured -> occurred

* typo fix: occurence -> occurrence

* typo fix: paramter -> parameter

* typo fix: remaing -> remaining

* typo fix: resetted -> reset

* typo fix: suppored -> supported

* typo fix: Sytem -> System

* typo fix: uncommited -> uncommitted

* typo fix: depricated -> deprecated

* typo fix: stoping -> stopping

* type fix: allow to -> allow one to
2022-02-17 10:54:12 +01:00
Rainer Gerhards
5cec5dd634
rscript: literal numbers were not compared correctly
This problem occurred when numbers were used in rsyslog.conf in
the set statement, e.g.

set $nbr = 1234;

In this case, during comparisons, the number was actually interpreted
as a string with digits. Thus numerical comparisons lead to unexpected
results. Even more so, as in other places of the code they were
treated as native numbers.

This is now fixed. We cannot outrule that this causes, in border cases,
change of behavior to existing configs. But it is unlikely and the
previous behaviour was a clear bug and very unintuitive. This in our
opinion it is justified to risk a breaking change for an expected
very minor subset of installations, if any such exists at all.

The fix was combined with code refactoring. We did this, because
the fix itself would have been quite hard to read, and the need
for refactoring became obvious.

closes https://github.com/rsyslog/rsyslog/issues/4770
2022-02-02 19:04:45 +01:00
alakatos
66bcd91196 Clarify meaning of loadConf and RunConf 2021-12-15 10:26:52 +01:00
6b3bba9e02 PrivDropToUser: fix abortOnIDResolutionFail handling #2
For new configuration style, security.abortonidresolutionfail was
not checked in rainerscript.

see also: https://github.com/rsyslog/rsyslog/pull/4710
closes: https://github.com/rsyslog/rsyslog/issues/4642
2021-10-13 10:57:22 +02:00
Rainer Gerhards
6080121ab7
config: implement script-equavalent for $PrivDrop* statements
closes https://github.com/rsyslog/rsyslog/issues/891
2021-08-23 14:10:16 +02:00
Nelson Yen
91a2049877
percentile module to track percentile metrics via impstats
Brief overview:
TO configure tracking percentile metrics in rainerscript:
User would need to define:
  - which percentile to track, such as [p50, p99, etc.]
  - window size - note, this correlates directly with memory usage to
  track the percentiles.

To track a value, user would call built-in function `percentile_observe()` in their configurations to
record an integer value, and percentile metrics would be emitted every
impstats interval.
2021-06-23 00:14:39 -07:00
Rainer Gerhards
39896ca622
config script: add re_match_i() and re_extract_i() functions
This provides case-insensitive regex functionality.

closes https://github.com/rsyslog/rsyslog/issues/4429
2021-04-21 12:23:46 +02:00
Nelson Yen
af8085fc83
Add built-in function get_property() to access property vars
Provides ability to evaluate a rsyslog variable using dynamically
evaluated parameters.
  1st param is the rsyslog param, 2nd param is a key, can be an array
  index or key string.

Useful for accessing json sub-objects, where a key
needs to be evaluated at runtime. Can be used to access arrays as well.

see tests for examples

remove unnecessary escape char
2021-04-15 11:52:15 -07:00
Rainer Gerhards
14aabc691e
testbench: add check for proper config include file order
This commit adds a check that include files are processed in the
proper order.

It also slightly changes some text that seemed to cause the wrong
impression that include files were processed in the wrong order.
Right the contrary is the case, as config files are being put on
a stack before they are processed.

closes https://github.com/rsyslog/rsyslog/issues/4271
2021-03-29 10:24:53 +02:00
Janmejay Singh
ff3a3f8e22 Fix race between key-lookup and lookup-table-reload 2021-01-29 15:15:32 +05:30
Rainer Gerhards
389484010f
lookup table bugfix: data race on lookup table reload
A data race could happen when a lookup table was reloaded. We found
this while moving to newer version of TSAN, but have no matching
report from practice. However, there is a potential for this to cause
a segfault under "bad circumstances".
2021-01-29 09:25:09 +01:00
Rainer Gerhards
d247c31888
add 'exists()' script function to check if variable exists
This implements a way to check if rsyslog variables (e.g. '$!path!var') is
currently set of not.

Sample: if exists($!somevar) then ...

closes https://github.com/rsyslog/rsyslog/issues/4385
2020-10-05 12:38:58 +02:00
Rainer Gerhards
24816cd9dd
config bugfix: intended warning emitted as error
When there are actions configured after a STOP, a warning should be
emitted. In fact, an error message is generated. This prevents the
construct, which may have some legit uses in exotic settings. It
may also break older configs, but as the message is an error
for so long now, this should be no longer of concern.
2020-08-26 13:17:16 +02:00
Jiri Vymazal
1c6f1a9c1b fixed ChkDisabled method to make config.enabled work
There was wrong negation in the method so it returned 0/1 in reverse
and also it did not mark the node to not be reported as unknown at all
times which is needed after all.
2020-07-02 10:42:14 +02:00
Rainer Gerhards
16085cbfed
config system bugfix: backticks cat segfault if file cannot be opened
when an `cat <filename>` consruct is used in rsyslog.conf ang <filename>
can not be accessed (does not exist, no permissions, ...), rsyslog
segfaults.

Thanks to Michael Skeffington for notifying us and providing analysis
of root cause.

closes https://github.com/rsyslog/rsyslog/issues/4290
2020-05-22 09:40:08 +02:00
Emil Bartczak
052d6f9d6b rainerscript: call getgrnam_r repeatedly to get all group members 2020-04-14 12:27:24 +02:00
Tetiana Ohnieva
04240ebb69 fix -o which produces missing space between call and rulename
closes #3761
2020-02-28 14:03:20 +02:00
Jiri Vymazal
ba5b68be84 Fixed processing of 'cofig.enabled' directive
Previously the directive was processed way too late which caused
false errors whenever it was set to 'off' and possibly other
problems.
2020-02-12 10:14:51 +01:00
Rainer Gerhards
4d69817808
config system: emit proper error message on $ in double-quoted string
closes https://github.com/rsyslog/rsyslog/issues/2869
2019-12-30 17:39:04 +01:00
Rainer Gerhards
deb98fecc1
bugfixes: small issues detected by clang static analyzer 10 2019-12-18 11:37:00 +01:00
Rainer Gerhards
fec4535f1c
core/config bugfix: false error msg when config.enabled="on" is used
When the 'config.enabled="on"' config parameter an invalid error message
was emitted that this parameter is not supported. However, it was still
applied properly. This commit removes the invalid error message.

closes https://github.com/rsyslog/rsyslog/issues/4011
2019-12-09 17:43:53 +01:00
Rainer Gerhards
e8320b77e4
function bugfix: "ipv42num" misspelled as "ip42mum" (without "v")
To fix the issue but keep compatible with existing deployments
both function names are now supported.

closes https://github.com/rsyslog/rsyslog/issues/3676
2019-07-02 16:19:17 +02:00
Rainer Gerhards
15ae6dfd24
bugfix: error messages if config.enabled="off" is used
Using config.enabled="off" could lead to error messages on
"parameter xxx not known", which were invalid. They occured
because the config handler expected them to be used, which
was not the case due to being disabled.

This commit fixes that issue.

closes https://github.com/rsyslog/rsyslog/issues/2520
2019-05-09 18:29:15 +02:00
Rainer Gerhards
68a00b0bd5
add capability to write full config file (-o cmdline option)
Introduces the capability to create an output config file that explodes
all "includes" into a single file. This provides a much better overview
of how exactly the configuration is crafted. That could often be a great
troubleshooting aid.

This commit also contains some slight not-really-related cleanup.

closes https://github.com/rsyslog/rsyslog/issues/3634
2019-04-28 11:52:51 +02:00
Rainer Gerhards
4fec04b90f
lexer.l: change to PRAGMA macros 2019-02-21 10:16:11 +01:00
Rainer Gerhards
00f09d8723
cleanup: use less verbose C11 method to use pragmas 2019-02-20 17:13:28 +01:00
Rainer Gerhards
e66bbf8bd1
clarify that commented-out code is intentional (as an example) 2019-01-18 14:10:49 +01:00
Harshvardhan Shrivastava
b4d3627613 adding abs in rainscript random impl to be in [0-max] range 2018-11-22 15:49:30 +05:30
Julien Thomas
a21f5f02b1 config: fix segfault in backticks "echo" expansion of undefined variables
The bug was introduced in commit abe0434 (config: enhance backticks "echo"
capability). The getenv() result passed to strlen() and es_addBuf() may be
NULL if the environment variable does not exist, resulting in a segfault.

This commit fixes Github issue #3006.
2018-11-02 03:29:59 +01:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
Rainer Gerhards
531e356a64
cleanup: remove commented-out code, simplify a bit
commented-out code detected by lgtm.com
2018-10-29 09:14:13 +01:00
Jan Gerhards
26f9ae3cc4 core bugfix: regex compile error messages could be incorrect 2018-10-17 18:16:55 +02:00
Rainer Gerhards
6efae3c2fd fix compile warnings under AIX
see also https://github.com/rsyslog/rsyslog/issues/2971
2018-08-31 05:14:01 -05:00
PascalWithopf
c83e3ed216 correct codestyle in rsyslog part 2 2018-08-01 16:11:33 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
c72de64804
work around clang 7 static analyzer report that we can't fix 2018-07-26 13:04:32 +02:00
Rainer Gerhards
7d52d7676b
"fix" gcc 8 false warnings
These warnings are definitely overdone, but the clutter the build log
so we change it. It's kind of sad, as code cleanness is actually
reduced, but it doesn't help. The core issue is that we can suppress
the warning itself, but but the extra information lines to go with it.
2018-07-19 12:53:19 +02:00
Rainer Gerhards
4408012ab0 config optimizer: bugfix in constant folding
did not work properly if a string and a number were to be folded.

Detected by gcc 8.
2018-07-16 14:39:10 +02:00
Rainer Gerhards
abe04344bf
config: enhance backticks "echo" capability
This is now more along the lines of what bash does. We now support
multiple environment variable expansions as well as constant text
between them.

example:
env SOMEPATH is set to "/var/log/custompath"
config is: param=`echo $SOMEPATH/myfile`
param than is expaned to "/var/log/custompath/myfile"

among others, this is also needed inside the testbench to properly
support "make distcheck".

Note: testbench tests follows via separate commit. There will be
no special test, as the testbench itself requires the functionality
at several places, so the coverage will be very good even without
a dedicated test.
2018-07-05 09:49:21 +02:00
Rainer Gerhards
dd62a34c66 config: permit 4-digit file creation modes
permit 4-digit file creation modes (actually 5 with the leading zero) so
that the setgid bit can also be set (and anything else on that position.

closes https://github.com/rsyslog/rsyslog/issues/1092
2018-05-14 15:34:03 +02:00
Rainer Gerhards
dc95ef09bd remove no longer needed --enable-libcurl configure switch
The --enable-libcurl switch was added to be able to disable libcurl
functionality inside the rsyslog core, see 46f4f43. As libcurl is no
longer used inside the core (due to introducing function modules),
--enable-libcurl needs to be removed.

closes https://github.com/rsyslog/rsyslog/issues/2628
2018-05-07 14:21:05 +02:00
Rainer Gerhards
d09323324f cosmetic bugfix: valgrind complain in some error conditions
When a "call" script statement was used with a non-existing ruleset AND
debug logginf was active for rainerscript.c, valgrind complained and
one debug message could potentially be incorrect (stating a queue
where non was).

This was caused by not initializing a variable which was probed in
debug mode before it was set. Non-debug mode was not affected.

see also https://github.com/rsyslog/rsyslog/issues/2399#issuecomment-384890873
2018-04-27 13:04:51 +02:00
Rainer Gerhards
0ca21d9190 core: config optimizer did not handle call_indirect
closes https://github.com/rsyslog/rsyslog/issues/2665
2018-04-26 13:17:26 +02:00
Rainer Gerhards
26d3fd0ef9
Merge pull request #2465 from CodeHarsh/master
adding hash64 and hash64mod functions support in rainerscript
2018-04-17 15:29:09 +02:00
Rainer Gerhards
1dead064dc
Merge pull request #2622 from rgerhards/all-warnings
QA: re-enable some compiler warnigs AX_COMPILER_FLAGS disables
2018-04-13 17:44:53 +02:00
Rainer Gerhards
48c397374d fix some __attribute__((unused)) and add missing ones
as it looks, some compiler versions (e.g. gcc 7) seem to be rather
picky on the position where this attribute is applied. So this
commit moves them to the position where they are properly detected.

We also add missing attributes. Some are missing due to conditional
compilation what we did not detect in our regular development
environments. This now comes up as we have enabled the corresponding
warning globally, and so they now also show up on those platforms.
2018-04-10 14:44:58 +02:00
Jan Gerhards
debea3785b remove unnecessary debug output
was used while implementing function modules, but were
not removed due to oversight.
2018-04-10 10:31:24 +02:00
Jan Gerhards
065022e551 rainerscript: mark unused parameters as such 2018-04-05 13:24:34 +02:00
Rainer Gerhards
76dccef817 fix cosmetic Coverity Scan ID 185316 2018-03-29 18:52:21 +02:00