193 Commits

Author SHA1 Message Date
zhuyan
59235f8396
core: add setting to permit compact json format
Adds the ability to remove unnecessary spaces from genrated json
to conserve space, e.g. on disk.

Maintainer edit: this replaces orginal PR which was too hard to
  rebase. This was caused by too-slow reaction of the rsyslog team.

see also: https://github.com/rsyslog/rsyslog/pull/2925
  (this is the original PR)

closes: https://github.com/rsyslog/rsyslog/issues/2913
2025-09-10 14:42:48 +02:00
Cursor Agent
582d9d98e9 runtime: fix NetstreamDriverCAExtraFiles parsing
Multiple intermediate CAs were not honored because strtok() modified
the original config value at the first comma. This led to only the
first file being considered. This change preserves the original value
and validates files using a duplicate buffer.

Impact: Users can reliably specify multiple CA intermediates via
NetstreamDriverCAExtraFiles; TLS chains that require intermediates
now validate as expected. Tests added.

Before: parsing mutated the stored string, effectively truncating at
the first comma and ignoring subsequent CA files.

After: we strdup() for validation, leave the original string intact,
and set it only if all files are accessible. Error handling follows
existing RS_RET patterns; temporary buffer is freed on all paths.

Additionally, add a test (OpenSSL backend) that generates a root,
two intermediates, and leaf certs on both client and server. The test
verifies chains with openssl, aligns CN/PermittedPeer, and exercises
a full send/receive path to guard against regressions. Makefile is
updated to include the new test in TESTS and EXTRA_DIST.

Fixes: https://github.com/rsyslog/rsyslog/issues/5207
2025-08-25 11:38:21 +02:00
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
7225999b77 refactor: modernize macro definitions to support formatting and clarity
This commit performs a broad modernization of widely used rsyslog
macros to align with modern C practices and support automated
formatting tools like clang-format. The changes focus on improving
syntactic regularity, readability, and tooling compatibility — without
altering behavior.

Macros refactored in this commit now follow a consistent,
statement-like form with explicit trailing semicolons. Where
applicable, macro blocks that define module interfaces (`queryEtryPt`)
have been updated to use simple `if` statements instead of `else if`
chains. While this slightly increases evaluation time, the affected
functions are only called once per module during load time to register
supported interfaces — making the performance cost irrelevant in
practice.

These improvements serve multiple purposes:
- Enable reliable clang-format usage without mangling macro logic
- Simplify reasoning about macro-expanded code for human readers
- Reduce style drift and merge conflicts
- Facilitate development for contributors using assistive tools
- Support future formatting pipelines using:
  1. `clang-format`
  2. a post-fixup normalization script

Refactored macros:
- MODULE_TYPE_NOKEEP
- MODULE_TYPE_KEEP
- MODULE_TYPE_INPUT
- MODULE_TYPE_OUTPUT
- MODULE_TYPE_FUNCTION
- MODULE_TYPE_PARSER
- MODULE_TYPE_LIB
- DEF_IMOD_STATIC_DATA
- DEF_OMOD_STATIC_DATA
- DEF_PMOD_STATIC_DATA
- DEF_FMOD_STATIC_DATA
- DEFobjStaticHelpers
- SIMP_PROP(...)

And all `queryEtryPt()` dispatch macros:
- CODEqueryEtryPt_STD_MOD_QUERIES
- CODEqueryEtryPt_STD_OMOD_QUERIES
- CODEqueryEtryPt_STD_OMODTX_QUERIES
- CODEqueryEtryPt_STD_OMOD8_QUERIES
- CODEqueryEtryPt_TXIF_OMOD_QUERIES
- CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
- CODEqueryEtryPt_STD_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_QUERIES
- CODEqueryEtryPt_STD_CONF2_setModCnf_QUERIES
- CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_PREPRIVDROP_QUERIES
- CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES
- CODEqueryEtryPt_STD_PMOD_QUERIES
- CODEqueryEtryPt_STD_PMOD2_QUERIES
- CODEqueryEtryPt_STD_FMOD_QUERIES
- CODEqueryEtryPt_STD_SMOD_QUERIES
- CODEqueryEtryPt_doHUPWrkr
- CODEqueryEtryPt_doHUP

This general modernization reduces macro misuse, improves DX, and
lays the foundation for a robust, automated style normalization
system.

See also: https://github.com/rsyslog/rsyslog/issues/5747
2025-07-15 08:25:58 +02:00
Rainer Gerhards
c886c28fa4
cleanup: fix some TODOs and remove outdated ones 2025-06-15 08:05:12 +02:00
Rainer Gerhards
1c0f9bba50
omfwd: implement native load balancing - phase 1
This patch implements a simple round-robin load balancer
for omfwd. It provides equal distribution of load to a pool
of target servers.

The code currently has no different modes and no special tuning
for the load balancer. However, it works very well in the most
common use cases. Furthermore, it provides a solid base on which
more elaborate functionality can be build if there is need to.

The new functionality is fully backwards compatible with previous
configuration settings.

New action() config params:
* pool.resumeinterval

New/"changed" rstats counters
Each target receives its own set of pstats counters. Most
importantly this is the case for byte counts. That counter retains
the same naming, but there may now be multiple of these counters,
one for each target ip, port tuple.

New pstats message count to target
Among others, this can be used for checking that the load balancer
works as intended. The so-far byte count emitted does not provide
a clear indication of how many messages the targets had actually
processed.

For obvious reasons, this message count makes most sense in
advanced load balancing scenarios, but also provides additional
insight into round-robin. Non-matches indicate that targets
went offline, and we can now evaluate the impact this had
on processing.

- re-design rebind functionality

This now works at the transaction level. It causes a rebind of all
pool members. Previous code did not work 100% correct since for a
couple of years now (after output batching integration).

As cleanup, rebindInterval support has been removed from tcpClt,
because omfwd is the only user. This permits a cleaner code path.

We also noticed a bug with rebindInterval:  it caused some mild
message duplication for quite some time. This went unnoticed.
To address that efficiently, rebindInterval in the future will
be considered once per batch. That means up to (maxBatchSize - 1)
messages may be transmitted more than the rebindinterval is.
That's the cleanest mode of operation and should not make any
difference for real deployments.

Some additional work done in this commit:

netstream: harden component against upper-layer logic errors

network subsystem: better handle API errors and provide more info

omfwd: add new parameter "iobuffer.maxsize"

add new global parameter debug.abortoninternalerror and use it

This parameter permits to make test runs fail when an internal error
is detected and gracefully handled by rsyslog. While it is great to
have it gracefully handled in practice, we should not accept this
during testing. The new parameter permits to abort in this case and
emits the related error message beforehand. It is turned on by
default in our regular tests.

add dedicated error code for "hard" program errors

omfwd: some cleanup + error message fix + new debug level messages

imptcp: improve error messages

add omfwd option to NOT do extended connection check

also output wrkr id in some omfwd messages (primarily debugging aid)

better debug info via LogMsg() interface

improve messages regarding imptcp and omfwd suspension / thread IDs

refactor and enchance minitcpsrvr for mimicing died servers

new global (debugging) option, correction of an informational msg

add global option allmessagestostderr

add new tests
2024-08-19 08:54:31 +02:00
6c3795ea75 openssl: evp support and custom openssl engine support
- output all loaded ciphers and engines.
- Add new global option "defaultopensslengine" to customize the
  default openssl engine. If not defined, openssl will handle the
  default engine automatically.
- Add simple openssl performance test with defaultopensslengine
  set to rdrand (Intel).
- removed unneeded testcase files in runtime folder.
- corrected whitelist settings for debug.files in TLS testcases
2024-05-02 12:07:14 +02:00
Rainer Gerhards
f886d1f1b2
core bugfix: rsyslog messages may not always have FQDN
Even if hostname FQDN is configured, rsyslog internal messages generated
after rsyslog startup and before the first HUP will not necessarily have
FQDN but instead only the shortname of the local host. This commit
fixes the situation.

Special thanks to github user eciii for doing a great bug analysis
and helping us considerably to fix the issue.

closes https://github.com/rsyslog/rsyslog/issues/5218
2023-12-06 17:11:20 +01:00
alakatos
7e30408f08 Netstreamdriver: deallocate certificate related resources
Free resources when a certificate path has been typed in
incorrectly. It will also trigger more information on the
configuration problem.
2023-10-30 09:46:03 +01:00
alakatos
8d33dce93d Add new global config option "libcapng.enable"
Defines whether rsyslog should drop capabilities at startup or not.
    By default, it is set to "on". Until this point, if the project was
    compiled with --enable-libcap-ng option, capabilities were
    automatically dropped. This is configurable now.
2023-10-04 13:39:18 +02:00
Darren J Moffat
844d1795a2 TLS CRL Support Issue 5081 2023-07-06 10:36:39 +02:00
alakatos
ea821b7b9d Add new global config option "libcapng.default"
Defines how rsyslog should behave in case something went wrong
when capabilities were to be dropped. Default value is "on",
in which case rsyslog exits on a libcapng related error.
Closes #5096
2023-06-08 12:40:50 +02:00
Rainer Gerhards
e2beca5311
core bugfix: local hostname invalid if no global() config object given
The local hostname is invalidly set to "[localhost]" on rsyslog startup
if no global() config object is present in rsyslog.conf. Sending a HUP
corrects the hostname.

This is a regression from ba00a9f25293f

closes https://github.com/rsyslog/rsyslog/issues/4975,
closes https://github.com/rsyslog/rsyslog/issues/4825
2022-10-20 18:21:00 +02:00
Rainer Gerhards
3b554ef7e4
Merge pull request #4904 from rgerhards/i4902
config: add "abortOnFailedQueueStartup" global config parameter
2022-09-14 09:53:12 +02:00
Rainer Gerhards
ba00a9f252
core bugfix: correct local host name after config processing
rsyslog.conf may affect the host's local name. These changes were
so far only activated after the first HUP. This patch now ensures
that the configured local host name is applied correctly throughout
all processing, including early startup.

This patch causes a slight change of behaviour. However, the behaviour
was inconsitent before. Now it is consistent and according to the config.

Please note: this patch also exposes a global entry point via "regular"
dynamic loading as this makes things much easier to do. This is in-line
with ongoing simplification effort.

Finally, we also remove a CI test that we do no longer need because
the problem covered is now addressed differently and the original issue
can no longer occur.

closes https://github.com/rsyslog/rsyslog/issues/4975
2022-09-06 13:01:37 +02:00
Rainer Gerhards
edd25fac04
config: add "abortOnFailedQueueStartup" global config parameter
similiar to "abortONUncleanConfig", this parameter aborts rsyslog
when a queue has problems during startup. Some users perfer rsyslog
to terminate in this case. By default, nothing changes.

closes https://github.com/rsyslog/rsyslog/issues/4902
2022-08-16 15:09:17 +02:00
Sergio Arroutbi
318449ad3a Add mechanism to include extra CA files parameter
This change allows to include extra CA files
so that no "unable to get issuer certificates" issue
is obtained when using chained cert files.
Proposed new parameter name is "NetstreamDriverCAExtraFiles"

fixes #4851

Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
2022-07-13 11:12:29 +02:00
alakatos
5caa989ce2 glblGetMaxLine() fix when config not yet exists, fixes #4810 2022-03-01 14:36:16 +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
alakatos
3edbe334e7 Move timezone specific variables to rsconf 2022-01-14 15:46:40 +01:00
alakatos
321fc76f0f Move rsyslog global parameters to rsconf_t struct 2022-01-13 12:43:21 +01:00
Rainer Gerhards
7b7a538da3
Merge pull request #4710 from alorbach/pr-issue-4642
PrivDropToUser: fix abortOnIDResolutionFail handling
2021-10-13 09:22:01 +02:00
03fdbfda74 PrivDropToUser: fix abortOnIDResolutionFail handling
security.abortonidresolutionfail needs to be loaded glblProcessCnf,
otherwise the setting is ignored in doGetUID / doGetGID.

see also: https://github.com/rsyslog/rsyslog/issues/4642
see also: cbcaf2c7e5
2021-10-12 12:15:15 +02:00
jkschulz
eadb23560b
Fix typo in error message. 2021-10-06 23:49:20 -04: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
Rainer Gerhards
50da918ae0
new global option "parser.supportCompressionExtension"
This permits to turn off rsyslog's single-message compression extension
when it interferes with non-syslog message processing (the parser
subsystem expects syslog messages, not generic text)

closes https://github.com/rsyslog/rsyslog/issues/4598
2021-06-09 14:05:44 +02:00
Aaron Levy
2e3b767d03 Replaced eCmdHdlrPositiveInt with eCmdHdlrNonNegInt where default is 0 2020-09-13 15:56:07 -07:00
Rainer Gerhards
a9dd12b967
queue: permit ability to double size at shutdown
This prevents message loss due to "queue full" when re-enqueueing data
under quite exotic settings.

see also https://github.com/rsyslog/rsyslog/issues/3941#issuecomment-549765813
closes https://github.com/rsyslog/rsyslog/issues/4020
2020-03-03 16:14:31 +01:00
Rainer Gerhards
cbcaf2c7e5
core: add global parameter "security.abortOnIDResolutionFail"
This parameter controls whether or not rsyslog aborts when a name ID
lookup fails (for user and group names). This is necessary as a security
measure, as otherwise the wrong permissions can be assigned or privileges
are not dropped.

CHANGE OF BEHAVIOR
The default for this parameter is "on". In previous versions, the default
was "off" (by virtue) of this parameter not existing. As such, existing
configurations may now error out.

We have decided to accept this change of behavior because of the potential
security implications.

closes https://github.com/rsyslog/rsyslog/issues/4164
2020-02-11 12:54:19 +01:00
Dagobert Michelsen
585d7b1a99 Use cast to long for pid_t to avoid type error 2020-01-06 14:34:04 +01:00
Rainer Gerhards
f9706e6d7c
core: do not unnecessarily set hostname on each HUP 2019-08-20 11:10:12 +02:00
Rainer Gerhards
55d4c7dbf2
imrelp: fix cosmetic race in recently-added code
It is extremely unlikly that the race could have caused harm, except
during test runs with thread sanitizer (TSAN) enabled.
2019-08-05 09:31:18 +02:00
Rainer Gerhards
0b2477a9f5
imrelp bugfix: hang after HUP
termination condition was not properly checked; this lead to
premature termination after patch 1c8712415b9 was applied.

It is open to debate if patch 1c8712415b9 changed the module
interface. Actually it looks like this was previously not
well thought out.

closes https://github.com/rsyslog/rsyslog/issues/3760
2019-07-31 10:35:58 +02:00
Rainer Gerhards
359288d788
global config: new parameters for ruleset queue defaults
specifically:

* default.ruleset.queue.timeoutshutdown
* default.ruleset.queue.timeoutactioncompletion
* default.ruleset.queue.timeoutenqueue
* default.ruleset.queue.timeoutworkerthreadshutdown

closes https://github.com/rsyslog/rsyslog/issues/3656
2019-05-09 15:18:55 +02:00
Rainer Gerhards
d9d12071f3
change default of internalmsg.severity global parameter, add tests
also fix a problem in handling this parameter when rsyslog processed
internal messages itself (it did not work). As the parameter was
introduced today, we do not flag this follow-up commit as "bugfix".
The issue was noticed when we added the additional tests.

see also https://github.com/rsyslog/rsyslog/issues/3650
see also https://github.com/rsyslog/rsyslog/issues/3639
2019-05-09 12:13:45 +02:00
Rainer Gerhards
160f2d7a52
new global config parameter "internalmsg.severity"
permits to specify a severity filter for internal message. Only
messages with this severity level or more severe are logged.

Orignally this was done in rsyslog.conf as usual: you can filter
rsyslog messages on severity, just like any other. But with systemd,
we now emit primarily to the journal, and this is outside of rsyslog's
rule engine and so regular filters do not apply (at least in regard
to the journal). Logging to journal is good, because finally
folks begin to see the messages (traditional distro configs discard
them, for whatever is the reason).

This commit implements a global setting for a severity-based filter
for internal messages, before submitted to journal. So it's not 100%
of what rsyslog can do, but at least some way to customize.

see also https://github.com/rsyslog/rsyslog/issues/3639
2019-05-07 11:27:08 +02:00
Rainer Gerhards
37187427bf
dnscache: fix looking issue detected by Coverity Scan
This leads to a refactoring of the looking code; issue was caused
by new TTL cache expiration code which placed not semantics on the
cache. These were not properly handled under all circumstances.
2019-04-16 15:41:32 +02:00
Rainer Gerhards
6f3f6c47ae
dnscache: add global parameter dnscache.default.ttl
This permits to control default TTL for cache entries. If set
to 0, the DNS cache is effectively disabled.

closes https://github.com/rsyslog/rsyslog/issues/49
closes https://github.com/rsyslog/rsyslog/issues/1487
2019-04-12 17:26:29 +02:00
9c60ae361e testbench: reorganized testcases for server/client certless comm
- Corrected ANON Cipher handling in ossl / gtls driver.
- removed error when no CA is configured for ANON Mode in gtls dirver.
- Set GNUTLS Debug level to 2, so we see more informations about gnutls errors
  in rsyslog debug mode.
- fixed tcpdump parameters not using TLS in manytcp-too-few-tls-vg.sh
- fixed minor memory leak in shutdown destructor of ossl tls driver.
2019-02-21 17:43:35 +01:00
Joan Sala
9315787c6d report child process exit status according to config parameter
Add new global setting 'reportChildProcessExits' with possible values
'none|errors|all' (default 'errors'), and new global function
'glblReportChildProcessExit' to report the exit status of a child
process according to the setting.

Invoke the report function whenever rsyslog reaps a child, namely in:
- rsyslogd.c (SIGCHLD signal handler)
- omprog
- mmexternal
- srutils.c (execProg function, invoked from stream.c and omshell)

Remove redundant "reaped by main loop" info log in omprog.

Promote debug message in mmexternal indicating that the child has
terminated prematurely to a warning log, like in omprog.

Closes #3281
2018-12-21 20:29:01 +01:00
Rainer Gerhards
e2b87769f1
global object: add ability to set action queue timeout defaults
while this is useful for users as well, we have done it so
that we can handle slow CI systems during CI runs. It is also
required for massively parallel testing, which makes each
individual test rather slow.

With the new settings, the testbench framework can now set
longer timeouts by defaults. Also updated framework accordingly.
2018-12-20 13:56:30 +01:00
Rainer Gerhards
d09416c95f
core: add operating state file capability (new feature)
adds global(operatingStateFile="fn") and related handling (see doc
for details).

closes https://github.com/rsyslog/rsyslog/issues/1721
2018-10-29 15:59:47 +01:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
e200b2192f add new global config parameter "inputs.timeout.shutdown" 2018-07-27 09:09:38 +02:00
Rainer Gerhards
2656afd4f5
build system: do not disable testbench tests via --disable-liblogging-stdlog 2018-07-02 11:13:05 +02:00
Rainer Gerhards
8f8ed81e5e
add global directive "abortOnUncleanConfig"
This provides a new-style alternative to $AbortOnUncleanConfig.
Note that a testbench test was changed to the new syntax. Adding
an additional test did not look useful, as the testbench still
sufficiently tests old and new method.

closes https://github.com/rsyslog/rsyslog/issues/2744
2018-06-27 11:17:48 +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
bd6f016db0 add global option internal.developeronly.options
This permits the ability to set some developer-specific behaviour
changes, e.g. for testbench testing or things like this. NEVER to
be used by users.
2018-04-28 12:46:32 +02:00
Rainer Gerhards
6d850a1aa9 fix behaviour not totally defined by C standard
see also: https://stackoverflow.com/questions/32916575/how-to-use-zd-specifier-with-printf

detected by lgtm static analyzer
2018-03-17 10:26:27 +01:00
Rainer Gerhards
c9fa875c44 fix global parameter name shutdown.enable.ctl-c
the config system actually does not permit "-" inside parameter
names. This has now been changed to "shutdown.enable.ctlc".

Note: this was never released and only present in 8.33 pre-release
versions.

closes https://github.com/rsyslog/rsyslog/issues/2482
2018-02-15 18:44:32 +01:00