63 Commits

Author SHA1 Message Date
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
0e5444706d
testbench: make waiting for HUP processing more reliable
The previous approach was more or less delay based. We have now
changed the code to enable imdiag to detect if HUP is underway
and wait until it is completed. The new method still employs some
kind of timeout, but is now quite reliable. Most importantly,
it works great with long-running HUP processing, which can happen
e.g. when querying the system name takes long or some actions need
longer time to persist their HUP processing.

The new approach will most likely reduce CI flakes and also speed
up testbench runs. The speedup happens from not having to wait a
full delay in cases where we detect HUP is completed (plus reduced
timeout when we cannot clearly detect this - see code comments why
the new method is still considered more reliable than the old one).

Code note: we needed to slightly re-structure the way actual HUP
processing and the "HUP mutex" is handled. After best analysis,
this does not affect the reliability or speed in production
settings.

closes https://github.com/rsyslog/rsyslog/issues/5192
2023-07-26 17:17:01 +02:00
alakatos
452b62b4a4 Make the main message queue part of the config 2022-03-01 09:56:39 +01:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
90308823df core: consistent handling of oversize input messages
In the community we frequently discuss handling of oversize messages.
David Lang rightfully suggested to create a central capability inside
rsyslog core to handle them.

We need to make a distinction between input and output messages. Also,
input messages frequently need to have some size restrictions done at
a lower layer (e.g. protocol layer) for security reasons. Nevertheless,
we should have a central capability

* for cases where it need not be handled at a lower level
* as a safeguard when a module invalidly emits it (imfile is an example,
  see https://github.com/rsyslog/rsyslog/pull/2632 for a try to fix it
  on the module level - we will replace that with the new capability
  described here).

The central capability works on message submission, and so cannot be
circumvented. It has these capabilities:

* overisze message handling modes:
  - truncate message
  - split message
    this is of questionable use, but also often requested. In that mode,
    the oversize message content is split into multiple messages. Usually,
    this ends up with message segments where all but the first is lost
    anyhow as the regular filter rules do not match the other fragments.
    As it is requested, we still implemented it.
  - accept message as is, even if oversize
    This may be required for some cases. Most importantly, it makes
    quite some sense when writing messages to file, where oversize
    does not matter (accept from a DoS PoV).
* report message to a special "oversize message log file" (not via the
  regular engine, as that would obviously cause another oversize message)

This commit, as the title says, handles oversize INPUT messages.

see also https://github.com/rsyslog/rsyslog/issues/2190
closes https://github.com/rsyslog/rsyslog/issues/2681
closes https://github.com/rsyslog/rsyslog/issues/498

Note: this commit adds global parameters:
 * "oversizemsg.errorfile",
   is used to specify the location of the oversize message log file.
 * "oversizemsg.report",
   is used to control if an error shall be reported when an oversize
   message is seen. The default it "on".
 * add global parameter "oversizemsg.input.mode"
   is used to specify the mode with which oversized messages will
   be handled.
2018-05-14 11:24:20 +02:00
Rainer Gerhards
9b06493dab add some more temp files to .gitignore 2017-10-27 13:19:51 +02:00
Rainer Gerhards
bf81d5a9b0 applying some "const" attributes
in trying to get more robust code (we do this as a side-activity
from time to time)
2017-10-27 13:19:51 +02:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
2963dbe56c add parameter -N3 to enable config check of partial config file
Use for config include files. Disables checking if any action exists at all.
2014-11-21 14:54:29 +01:00
Rainer Gerhards
d1514a3b1a relicense
the code that now remained in this file was all written by me
myself, so I can finally change the license

see also https://github.com/rsyslog/rsyslog/issues/82
2014-11-12 12:56:03 +01:00
Rainer Gerhards
a407348963 refactor PRI-handling code 2014-10-08 12:50:10 +02:00
Rainer Gerhards
a45ea8a144 testbench: make more reliable shutdown
so far, we checked only the main queue size to become zero, ignoring
the sizes of action queues. For some tests, this caused racieness and
unreliability. Now, we check all queues. This should make matters
much more stable.
2014-07-11 17:23:21 +02:00
Rainer Gerhards
7644e5928a Merge branch 'v7-devel' 2013-12-19 10:12:08 +01:00
Rainer Gerhards
5cdf4c6239 Merge branch 'v7-stable' into v7-devel
Conflicts:
	dirty.h
	tools/syslogd.c
2013-12-19 10:11:55 +01:00
Rainer Gerhards
7b42e11dce regression fix: last patch wrote to constant memory pool
This could lead to abort on some platforms/compiler/system settings.
2013-12-19 09:37:54 +01:00
Rainer Gerhards
c4501ebb52 Merge branch 'v7-devel' into tmp
Conflicts:
	action.c
2013-11-29 16:59:19 +01:00
Rainer Gerhards
a42da69a72 nit: update copyright dates 2013-11-29 09:49:42 +01:00
Rainer Gerhards
1ea869ec54 use const keyword at (some) appropriate places 2013-11-29 09:16:03 +01:00
Rainer Gerhards
2387c9281d fix: ruleset queues were activated too early
This does not cause issues in v7, but here we have the problem
that the total number of actions, which now is required for wti sizing,
is not available at that early stage. So we needed to delay queue
startup until everything is processed (just as it should have been
already!). Note the previously we could have a segfault on first message
when ruleset queues were used.
2013-11-14 15:51:52 +01:00
Rainer Gerhards
415b26d5a1 enable shuffling of crypto parameters down through queue definition 2013-05-10 15:39:42 +02:00
Rainer Gerhards
42d1d27a01 Merge branch 'v7-stable-newmsglock' into master-newmsglock
Conflicts:
	runtime/msg.c
	runtime/queue.c
	tools/syslogd.c
2012-12-06 17:27:37 +01:00
Rainer Gerhards
62f6a7d7b4 fix missing functionality: ruleset(){} could not specify ruleset queue
The "queue.xxx" parameter set was not supported, and legacy ruleset
config statements did not work (by intention). The fix introduces the
"queue.xxx" parameter set. It has some regression potential, but only
for the new functionality. Note that using that interface it is possible
to specify duplicate queue file names, which will cause trouble. This
will be solved in v7.3, because there is a too-large regression
potential for the v7.2 stable branch.
2012-11-30 17:09:28 +01:00
Rainer Gerhards
3d41da36b8 remove "last message repeated n times" from rsyslog output part 2012-10-23 11:22:56 +02:00
Rainer Gerhards
3806643baa ratelimiter: enable thread-safe mode & (related) API changes 2012-10-15 11:19:22 +02:00
Rainer Gerhards
2a6ff7d53d interface cleanup (probably not final) 2012-10-15 08:55:12 +02:00
Rainer Gerhards
49fb431e0c milestone: ratelimiter used in imptcp 2012-10-15 08:41:04 +02:00
Rainer Gerhards
4269e45781 new ratelimit: interface plumbing added
no actual implementation yet done
2012-10-09 18:54:25 +02:00
Rainer Gerhards
c55997638f added $InputRELPServerBindRuleset directive to specify rulesets for RELP 2011-09-08 15:05:04 +02:00
Rainer Gerhards
6093f31103 step: moved main message queue activation to after priv drop 2011-04-27 17:57:47 +02:00
Rainer Gerhards
706121052d step: shuffled module-related code from syslogd.c to rsconf.c
... plus some minor cleanup/code shuffle
2011-04-27 13:33:06 +02:00
Rainer Gerhards
13ecf8a6ef step: config handler setting from syslogd.c moved to rsconf.c 2011-04-21 14:27:41 +02:00
Rainer Gerhards
c97b1d3c72 added support to save/restore rsyslog core action settings...
... but not those of plugins (which are at least as important as
the core ones). So this is an interim commit.
2010-07-23 17:33:08 +02:00
Rainer Gerhards
2dafb35077 some module cleanup 2009-11-12 12:03:27 +01:00
Rainer Gerhards
b41e0d51f5 some more cleanup along the way
... getting the module structure a bit cleaner ;)
2009-11-03 18:48:40 +01:00
Rainer Gerhards
6f511cecfa more cleanup and working towards a parser module calling interface
I cleaned up a lot of config variable access along the way. This
version compiles and runs, but does not yet offer any enhanced
functionality. pmrfc5424 is just a dummy that is not yet being used.
2009-11-03 12:39:48 +01:00
Rainer Gerhards
7d78b3bdfd restructured parser part of rsyslog
now cleaner and hopefully usuable as a basis for loadable parser
modules. I also cleaned up/consolidated some of the internal
message generation functionality in rsyslogd.
2009-11-03 10:41:47 +01:00
Rainer Gerhards
1ada506e2d added the capability to have ruleset-specific main message queues
This offers considerable additional flexibility AND superior performance
(in cases where multiple inputs now can avoid lock contention)
2009-10-27 17:31:27 +01:00
Rainer Gerhards
e397c34d2a finished transition to using inputName property
... plus some celanup and adding minor missing functionality
(the rule debug info again tell the property name, not just number).
2009-06-30 15:21:15 +02:00
Rainer Gerhards
56e462610d further optimized message object
pri, facility and severity string generation simplified
2009-06-17 12:56:58 +02:00
Rainer Gerhards
ca0ddc30a3 completed multi-ruleset core support
... as well as added multi-ruleset support for imtcp
2009-06-12 15:31:08 +02:00
Rainer Gerhards
e3d9843c85 re-enabled pipe, tty and console in omfile
... by moving code to stream.c. Thanks to the new design, new cases are
not really needed, resulting in cleaner code.

I also did a cleanup of header file usage as a side-activity.
2009-06-12 11:47:00 +02:00
Rainer Gerhards
6f4e3c4e4c restructered code in perparation for multiple rule set support
... this was long overdue, and I finlly tackeld it. It turned out to
be more complex than I initially thought. The next step now probably is
to actually implement multiple rule sets and the beauty that comes
with them.
2009-06-10 16:49:14 +02:00
Rainer Gerhards
eb1615068c added new testing module imdiag
which enables to talk to the rsyslog core at runtime. The current
implementation is only a beginning, but can be expanded over time
2009-05-25 10:47:22 +02:00
Rainer Gerhards
3e1220f434 fixed some compiler warnings 2008-12-05 01:10:06 +01:00
Rainer Gerhards
6c6e9a0f3f moved bParseHostname and bIsParsed to msgFlags
This enables us to use more efficient calling conventions and
also helps us keep the on-disk structure of a msg object more
consistent in future releases.
2008-10-09 13:45:56 +02:00
Rainer Gerhards
ace4f2f752 reordered imudp processing.
Message parsing is now done as part of main message queue worker
processing (was part of the input thread) This should also improve
performance, as potentially more work is done in parallel.
2008-10-08 18:55:11 +02:00
Rainer Gerhards
8528344ef5 "output" timestamp now taken from mesg's time generated
This enhances performance and, as some have pointed out, is
probably also more consistent with what users expect how
the various output-timestamp related function should work. This
commit needs some more testing.
2008-10-07 14:26:41 +02:00
Rainer Gerhards
65f74a712b added $UDPServerTimeRequery option
...which enables to work with
less acurate timestamps in favor of performance. This enables querying
of the time only every n-th time if imudp is running in the tight
receive loop (aka receiving messsages at a high rate)
2008-10-06 14:25:23 +02:00
Rainer Gerhards
760e5f0d39 performance optimization: unnecessary time() calls during message parsing removed
thanks to David Lang for his excellent performance analysis
2008-09-16 11:56:07 +02:00