44 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
c886c28fa4
cleanup: fix some TODOs and remove outdated ones 2025-06-15 08:05:12 +02:00
taavi.valjaots
f2395745d9 ksi bugfix: sending of too many signing requests fixed.
As there is a bug in libksi where too many signing requests may have bene sent
out the amount of signing requests will be limited by KSI module until the fix
is implemented.
2022-11-14 12:03:27 +02:00
taavi.valjaots
b206bb5795 ksi bugfix: Segmentation fault in async mode fixed.
Libksi internal uses KSI_DataHash cache (in KSI_CTX) to reduce the amount of
memory allocations by recycling old objects. In async mode the root data hash is
produced in thread A by its own KSI_CTX. Async signing is run by thread B with
its own KSI_CTX. Root hash value was processed by thread B during async signing
and cache owned by thread A was affected resulting system to crash.

To fix the issue root hash value is cloned under thread B so it is not possible
to affect cache operated by another thread.
2022-10-31 10:39:55 +02:00
taavi.valjaots
24a3f2dbd9 ksi bugfix: request cache size and send timeout issue fixed.
Async service send timeout is not configurable and request cache size is too
small to handle large amount of signing requests with small amount of permitted
requests per aggregation round. For example user with max_requests = 4 results
cache size 5 * max_requests or at least 256. When signing 300 log files cache
will be too small resulting several unsigned blocks. When signing 200 log file
cache will be adequate, but with rate of 4 signatures per second, it is only
possible to sign 4 * 10 blocks before all requests that are not sent out will
timeout.

Fix for the issue is to make send timeout configurable and make the size of the
cache depend on the value of send timeout. New configuration value
sig.block.signtimeout="time, s" introduced that defines the time window wherein
the block has to be signed. The size of the request cache is increased to
3 * max_requests * sign_timeout or at least 256.
2022-08-05 17:21:41 +03:00
taavi.valjaots
9166e22f29 ksi bugfix: optimize processing of signer queue to fix delays.
There is a worker queue where rsyslog KSI module collects events and signing
requests. When queue is processed thread is periodically put to sleep. Previous
implementation handles signature requests well but sleeps every time after
handling new file open / close event. When several log files are opened or
closed simultaneously process is significantly slowed down. Another issue is
that thread always sleeps 1000ms that may be 2x longer than aggregation round.
This slows down overall signing process.

Fix for the issue is to simply not sleep after file open / close event if there
are next items to be processed. To speed up the signing process, rsyslog uses
KSI aggregator conf. to obtain the aggregation period that is used for the sleep
time configuration.
2022-08-04 16:26:23 +03:00
taavi.valjaots
d21d9cfa57 ksi bugfix: possible crash fixed when several log files are opened.
KSI module in async mode used to request aggregator conf. every time a log
file was opened. When several log files were opened simultaneously
corresponding amount of pointless concurrent conf. requests were posted.
Concurrent conf. requests lead to a bug in libksi, where internal count of
pending requests was not decremented correctly causing system to crash.

Fix for the issue is to optimize the frequency of conf. requests so that only
one conf. requests is handled at once. Instead of checking conf. every time
log file is opened, conf is requested periodically after conf timeout. This will
affect both sync and async mode.

New option for KSI module introduced - sig.confinterval="time, s".
2022-07-27 11:58:16 +03:00
MIZUTA Takeshi
988c3c2a67 Fix message typo when pthread_create fails in KSI-LS12 support library 2022-03-22 16:59:24 +09:00
MIZUTA Takeshi
0b830970c2 Don't refer to errno when the pthread library fails
When the pthread library fails, errno is referenced even though errno is not set.
Fix to refer to the return code of the pthread library instead of errno.
2022-03-03 10:34:54 +09:00
taavi.valjaots
858a5292c1 ksi bugfix: locking bug fixed in rsksiCtxOpenFile 2021-09-20 11:11:47 +03:00
taavi.valjaots
5906968120 ksi bugfix: Optimized code in KSI module initialization fixed.
KSI module initialization will not stuck in infinite loop when code is
built with optimization -O2.
2020-06-03 15:21:50 +03:00
Rainer Gerhards
6b56e0418e Merge branch 'sudden-ksi-module-closure-fix' 2020-04-28 13:11:22 +02:00
Rainer Gerhards
80c6be0c47
Merge pull request #4211 from taavi-valjaots/default-hash-algo-fix
Hardcoded default hash algorithm KSI_HASHALG_SHA2_256 replaced with
2020-04-28 12:28:52 +02:00
taavi.valjaots
7211b6aac4 ksi bugfix: Signer thread initialization is verified before usage.
When signer thread is created in rsksiInitModule thread successful
initialization is verified before returning the function. This will
prevent adding records to not initialized module and in case of an
error signature files opened will contain only magic bytes.

Thread flags replaced with thread state.

When init module fails, module is disabled.
2020-03-12 15:21:02 +02:00
taavi.valjaots
f219fa3003 ksi bugfix: Hardcoded default hash algorithm replaced with 'default'.
Instead of hardcoded SHA-256 KSI_getHashAlgorithmByName("default")
is used to get default hash function.
Function rsksiSetHashFunction and SetCnfParam updated.
2020-03-10 13:07:35 +02:00
taavi.valjaots
8b3c24a768 ksi bugfix: When KSI module is suddenly closed, files are finalized.
In async. mode all pending signature requests are closed immediately and
unsigned block marker is attached with message about sudden closure.
Similar approach is used for blocks that already contain some records.
Empty blocks are just closed without any metadata.
2020-03-10 12:59:17 +02:00
taavi.valjaots
5174c8ae6e Bugfix: KSI module + dynafile in asynchronous mode fixed. 2020-01-09 18:08:10 +02:00
Rainer Gerhards
6936ff6cf8
Merge pull request #3339 from allanpark/Issue_3338_lmsig_ksils12_add_high_avalability_mode
Issue 3338: lmsig_ksils12: Add high avalability mode supported by libksi 3.18
2019-03-02 14:01:24 +01:00
Allan Park
9204b78ab3 lmsig_ksils12: added high availability mode of operation (supported by the latest libksi) 2019-02-28 11:51:08 +00:00
Henri Lakk
ece47ab50c ksi component: update deprecated definitions 2019-02-22 16:25:40 +01:00
Rainer Gerhards
7008f50e96
Merge pull request #3195 from allanpark/Issue_3190_disable_sha1
Issue 3190 lmsig_ksils12: disable unsafe hash algorithm SHA1
2018-10-28 08:38:38 +01:00
Allan Park
5296c83d5f Issue 3191, lmsig_ksils12: improve module debug logging, added conf parameter for specifing file name for libksi debug output and improved error reporting 2018-10-27 13:29:31 +03:00
Allan Park
fff4c96528 Issue 3190 lmsig_ksils12: disable unsafe hash algorithm SHA1 2018-10-26 16:30:46 +03:00
Rainer Gerhards
c1e129b284
Merge pull request #3124 from allanpark/issue_3105_lmsig_ksils12_fix_signing_issue
Bugfix: issue 3105, lmsig-ksils12
2018-10-15 10:14:32 +02:00
Rainer Gerhards
041f0f15c7
CodeCov: adjust config
hopefully this avoids false positive CI fail reports
2018-10-12 19:00:06 +02:00
Allan Park
52e58be929 Bugfix: issue 3105, lmsig-ksils12 module skips signing the last block in the file in some conditions 2018-10-03 10:55:22 +00:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
5c0f9ef989 fix build issues on armhf systems
Look like general 32 bit issues, though.
2018-07-26 07:59:46 +00:00
Allan Park
10d463d742 Fixed (hopefully last) bugs reported by clang 2018-04-13 14:32:37 +03:00
Allan Park
6dc460120f Fixing warnings in lmsig_ksils12 reported by clang static analyzer 2018-04-12 11:23:51 +03:00
Allan Park
b56fd2bd2d lmsig_ksils12: fixing issues 2517 and 2621 2018-04-10 10:11:37 +03:00
Rainer Gerhards
e22e70840e lmsig_ksils12: emit error message if chown() to sig file fails
see also https://github.com/rsyslog/rsyslog/pull/2450
2018-02-11 18:22:59 +01:00
Allan Park
9620e3ffcc BUGFIX, Issue 2446. Fix directory creation code in lmsig_ksils12 plugin 2018-01-30 13:02:43 +02:00
Rainer Gerhards
8cb0a95a38 code style: fix too-long lines 2017-12-23 18:25:37 +01:00
PascalWithopf
79de51e4fc codestyle: reduce max line length to 125 2017-12-20 16:16:57 +01:00
Allan Park
5b720b3c8e lmsig_ksils12: fixing coverity issue 185331 2017-12-14 11:30:14 +02:00
Allan Park
c802e29593 BUGFIX: fixing regression bugs introduxed by PR 2117 (reported by coverity) 2017-11-28 09:43:35 +02:00
Allan Park
bd42f471c6 BUGFIX: fixing bugs pointed out by coverity 2017-11-27 10:41:19 +02:00
Allan Park
2cb7071a2f Added static keyword to a file local function 2017-11-23 19:56:21 +02:00
Allan Park
a8a754ee40 Add possibility to use the asyncronous mode of the libksi (>=3.16) (Issue 2090) 2017-11-23 13:11:41 +02:00
Allan Park
d5bafd1917 BUGFIX: fix issues in ksi ls12 pluginreported by coverity scan 2017-11-09 17:28:13 +02:00
Allan Park
c4f7d23b63 Fixing issue #1621: fixing ksi ls12 tree height calculation 2017-06-20 14:11:13 +03:00
Rainer Gerhards
8457050168 lmsig_ksi_ls12: fix build problems 2017-05-31 11:34:20 +02:00
Allan Park
263c18fc0c Added new module: KSI log signing ver. 1.2 (lmsig_ksi_ls12) 2017-05-11 16:50:41 +00:00