74 Commits

Author SHA1 Message Date
Rainer Gerhards
e0dcad6cdf
pmrfc3164: add headerless message detection and handling
This patch adds a robust, optional mechanism for handling "headerless" input—
log messages that do not conform to traditional syslog formatting.

- **Headerless detection (opt-in)**
  - Controlled by the new `detect.headerless` boolean (default: off)
  - Detects messages with **no PRI** and **no valid timestamp**
  - Excludes structured inputs (e.g. JSON starting with `{` or `[`) as
    before
  - Injects default `hostname` and `tag` values
  - Flags message internally as `HEADERLESS_MSG` for further processing

- **Fallback processing options**
  - `headerless.ruleset`: route headerless messages to a dedicated ruleset
  - `headerless.errorfile`: optionally store raw input to a file
  - `headerless.drop`: discard headerless messages early if desired

- **Thread-safe HUP signal handling**
  - New `doHUPParser` entry point allows safe log rotation for error file
  - Follows standard reopen-on-write pattern post-HUP

- **Testing & Maintenance**
  - Adds two test cases: `pmrfc3164-headerless.sh` and `pmrfc3164-drop.sh`
  - Extends documentation for all new parameters
  - Cleans up code formatting, includes, and bumps copyright

Some environments produce mixed or malformed input streams. This patch enables
early, lightweight detection of non-syslog input, with customizable recovery
and routing strategies. It avoids unnecessary parsing work and gives operators
better tools to isolate or discard garbage input—without breaking legacy behavior.
2025-07-31 10:39:24 +02:00
Rainer Gerhards
a82fcd0d9c
parser: add checkParserInst hook for pre-registration validation
Introduce a new lifecycle callback—`checkParserInst`—to perform
configuration sanity checks on parser instances immediately after they’re
created. This establishes a standardized validation point (similar to
`checkCnf` in other module types) without altering existing parser logic.

By wiring `checkParserInst` into:
- the module template (macros for definition and registration),
- the module loader (`doModInit`) with graceful fallback,
- the runtime configuration flow (`rsconf.c`) just after
  `newParserInst`,

and by providing empty stubs in all current parser modules (contrib and
plugins), we now have a clear, uniform spot to add parser-specific
validation rules in subsequent patches. This improves future
maintainability and robustness of parser configuration handling.
2025-07-31 08:26:50 +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
64f683d92b
tooling: new developer tool to fix trailing spaces
This may be an interim solution, but definitely a useful one
to address style inconsistencies.

Style inconsistencies are problematic as they tend to pollute
git history by causing pseudo-changes.

This commit also contains a set of fixes to existing files, so
that we get to a clean state.
2025-07-11 09:01:03 +02:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Jan Gerhards
22fc00e897 rscript: make function modules loadable
function modules add functions to rainerscript dynamically,
change http_request into such a module (enabled by default).
This module can be used as a sample for future function modules.
2018-03-19 11:49:36 +01:00
PascalWithopf
79de51e4fc codestyle: reduce max line length to 125 2017-12-20 16:16:57 +01:00
Rainer Gerhards
04220bdd3f omhttpfs: "fix" Coverity scan false positive CID 185398 2017-12-02 12:08:34 +01:00
Rainer Gerhards
a4c7f2ac81 module-template framework: avoid compiler warning in some legal cases
the finalize_it: label is required, but not always used, which each
time results in a compiler warning that needs to be worked around.
Now this is fixed once and for all for gcc and clang - the others
will probably not complain in any case. Great solution until something
comes up that makes us need a revision.
2017-11-22 11:08:34 +01:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
Rainer Gerhards
070ed1d1fe Merge pull request #1247 from purnimam1/master
AIX Port
2016-12-02 09:53:24 +01:00
Rainer Gerhards
1441eaa1b2 core: fix bug in module-template macros
If an om,mm module has no parameters, a macro function parameter is
unused and triggers compile warning (and thus error on -Werror).

closes https://github.com/rsyslog/rsyslog/issues/1293
2016-12-02 08:14:09 +01:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
182b42cfee fix missing prototypes 2016-06-01 10:40:19 +02:00
Rainer Gerhards
2e55c77d70 clean up doAction output module interface
We started with char * pointers, but used different types of pointers
over time. This lead to alignment warnings. In practice, I think this
should never cause any problems (at least there have been no reports
in the 7 or so years we do this), but it is not clean. The interface is
now cleaned up. We do this in a way that does not require modifications
to modules that just use string parameters. For those with message
parameters, have a look at e.g. mmutf8fix to see how easy the
required change is.
2016-01-13 04:04:26 -05:30
Rainer Gerhards
ca3f961671 core engine: plugin IF extension to support wrkr-level HUP processing 2015-03-30 15:10:13 +02:00
Rainer Gerhards
27ba29abfc implement parse() config object
including the necessary plumbing to support multiple parser
instances
2014-07-08 20:44:43 +02:00
Rainer Gerhards
0c60fc158d Merge branch 'v7-stable' into v8-stable 2014-05-27 13:10:37 +02:00
Rainer Gerhards
7106ec424d relicens
authors only Rainer Gerhards and Bojan Smojver, who gave
permission to relicense via mail on 2014-05-22.
2014-05-27 12:58:59 +02:00
Rainer Gerhards
01de5afe83 refactor strgen interface once again
as this provides more flexibility and potentially better performance. We
try to squeueze all interface changes into as early an release as
possible.
2013-12-06 09:52:03 +01:00
Rainer Gerhards
b5dcbf9167 refactor: do not require transactional omods to provide doAction() 2013-12-04 12:30:52 +01:00
Rainer Gerhards
69752635d2 refactor strgen interface 2013-12-04 11:55:36 +01:00
Rainer Gerhards
fb6dd02afc refactor milestone: create first PoC of commitTransaction() entry point 2013-12-04 11:38:07 +01:00
Rainer Gerhards
be36ef5009 refactor doAction omod interface
we do no longer support the iMsgOpts parameter
2013-12-04 09:24:11 +01:00
Rainer Gerhards
b44dcabe90 remove pData emulation from v8 omod interface
breaks compilation of not converted modules - but these
won't work anyways. So better change this now.
2013-10-31 18:15:33 +01:00
Rainer Gerhards
2f5aec47db remove pData from tryResume callback 2013-10-30 18:22:03 +01:00
Rainer Gerhards
63edb11d37 omelasticsearch: upgrade to v8 ouptut module interface
Note that this code here has NOT yet been tested.
2013-10-30 18:12:32 +01:00
Rainer Gerhards
64a4358384 add freeWrkrInstance to output module interface 2013-10-29 16:17:46 +01:00
Rainer Gerhards
f4161583cc milestone: omfile supports buffering mechanism 2013-10-28 15:04:58 +01:00
Rainer Gerhards
33784d03f1 milestone: stage work for omfile worker instance handling 2013-10-28 09:00:26 +01:00
Rainer Gerhards
84537ced75 milestone: make default modules compile again (but they do NOT work!) 2013-10-27 11:40:52 +01:00
Rainer Gerhards
d1a9ea216c milestone: change output module interface -- breaks build process! 2013-10-27 11:35:48 +01:00
Rainer Gerhards
d9cde56eb8 add output module interface to facilitate cooperative shutdown
... in more complex cases (where receiving SIGTTIN is not sufficient).
See also:
http://blog.gerhards.net/2013/04/rsyslog-output-plugin-wrangling.html
2013-04-08 17:55:52 +02:00
Rainer Gerhards
d9df6e9775 bugfix: modules not (yet) supporting new conf format were not properly registered
This lead to a "module not found" error message instead of
the to-be-expected "module does not support new style" error message.
That invalid error message could be quite misleading and actually stop
people from addressing the real problem (aka "go nuts" ;))
2012-11-28 10:02:08 +01:00
Rainer Gerhards
05eb0a5052 silence compiler warnings & some cleanup 2012-11-14 12:16:24 +01:00
Rainer Gerhards
7c2183ee32 input stmt: add core engine plumbing 2012-09-26 12:25:10 +02:00
Rainer Gerhards
4b150db338 milestone: module() config statement basically works
some nits to iron out, only omfile actually support module params
2012-06-21 16:19:20 +02:00
Rainer Gerhards
535d6cf0b8 v6.1/2 scoping support removed from plugins 2012-01-19 14:48:40 +01:00
Rainer Gerhards
ad0fa51759 Merge branch 'v6-stable'
Conflicts:
	runtime/conf.c
	runtime/modules.c
	runtime/modules.h
2012-01-19 14:16:57 +01:00
Rainer Gerhards
1049537cd8 removing the newScope/resumeScope macro interfaces
to make using pre-v6-plugins even easier
2012-01-19 14:10:29 +01:00
Rainer Gerhards
6624ad434b Merge branch 'v6-stable-noscoping' into master
Conflicts:
	ChangeLog
	configure.ac
	doc/manual.html
	plugins/imfile/imfile.c
	plugins/imklog/imklog.c
	plugins/immark/immark.c
	plugins/imptcp/imptcp.c
	plugins/imrelp/imrelp.c
	plugins/imtcp/imtcp.c
	plugins/imtemplate/imtemplate.c
	plugins/imudp/imudp.c
	plugins/imuxsock/imuxsock.c
	plugins/mmsnmptrapd/mmsnmptrapd.c
	plugins/omtemplate/omtemplate.c
	runtime/glbl.c
	runtime/parser.c
	tools/omfile.c
	tools/syslogd.c
2012-01-19 13:07:46 +01:00
Rainer Gerhards
9b24152b6a undoing v6.1 config scoping interface, part I
The most common files are now changed, more needs to be done.
2012-01-18 18:21:08 +01:00
Rainer Gerhards
ac9afc4149 Merge branch 'v5-stable' into master
Conflicts:
	ChangeLog
	action.h
	configure.ac
	doc/manual.html
	plugins/immark/immark.c
	plugins/impstats/impstats.c
	plugins/imptcp/imptcp.c
	plugins/imtcp/imtcp.c
	runtime/cfsysline.c
	runtime/cfsysline.h
	runtime/conf.c
	runtime/ctok.c
	runtime/ctok.h
	runtime/ctok_token.c
	runtime/ctok_token.h
	runtime/dnscache.h
	runtime/expr.c
	runtime/expr.h
	runtime/rule.c
	runtime/rule.h
	runtime/ruleset.h
	runtime/sysvar.c
	runtime/vm.h
	runtime/vmop.c
	runtime/vmop.h
	runtime/vmprg.c
	runtime/vmprg.h
	runtime/vmstk.c
	runtime/vmstk.h
	tools/omusrmsg.c
2012-01-18 14:08:24 +01:00
Rainer Gerhards
c9b70abf1a Merge branch 'v5-stable' into v6-stable
Conflicts:
	ChangeLog
	configure.ac
	doc/manual.html
	plugins/imptcp/imptcp.c
2012-01-18 13:55:16 +01:00
Rainer Gerhards
18e60f46a1 Merge branch 'v4-stable' into v5-stable
Conflicts:
	runtime/debug.h
	runtime/obj.c
	runtime/parser.h
	runtime/wti.h
2012-01-16 16:14:30 +01:00
Rainer Gerhards
f6dea36394 runtime license change 2012-01-16 12:39:01 +01:00
Rainer Gerhards
f2528ec101 Merge branch 'v5-devel'
Conflicts:
	ChangeLog
	configure.ac
	doc/manual.html
	runtime/conf.c
	tools/omfile.c
	tools/omusrmsg.c
2011-09-26 12:48:57 +02:00
Rainer Gerhards
d6b6b30c18 added capability to emit config error location info for warnings
otherwise, omusrmsg's warning about new config format was not
accompanied by problem location.
2011-08-09 11:48:52 +02:00