1868 Commits

Author SHA1 Message Date
Julian Brost
3504fc7ed6 Security: fix TLS certificate validation bypass
The previous validation in set_verify_callback() could be bypassed, tricking
Icinga 2 into treating invalid certificates as valid. To fix this, the
validation checks were moved into the IsVerifyOK() function.

This is tracked as CVE-2024-49369, more details will be published at a later time.
2024-10-22 10:42:15 +02:00
Alexander Aleksandrovič Klimov
600e631a4d
Merge pull request #9945 from Icinga/2139backport
Disable TLS renegotiation, bump Windows deps and fix Icinga DB crashes
2023-12-20 12:14:30 +01:00
Alexander A. Klimov
89c54ca5e5 Disable TLS renegotiation
The API doesn't need it and a customer's security scanner
is afraid of a potential DoS attack vector.
2023-12-20 10:05:35 +01:00
Alexander A. Klimov
5bf8db41ef CertificateToString(): allow raw pointer input 2023-12-18 17:07:44 +01:00
Alexander A. Klimov
d1098dc959 CreateCertIcingaCA(EVP_PKEY*, X509_NAME*): enable optional CA creation 2023-12-18 17:07:44 +01:00
Alexander A. Klimov
35317f14e7 Introduce IsCaUptodate() by splitting IsCertUptodate() 2023-12-18 17:07:44 +01:00
Alexander Aleksandrovič Klimov
eacf5f27cf
Merge pull request #9816 from Icinga/2.13.8/vendor
Update vendored libs
2023-07-07 16:29:20 +02:00
Alexander A. Klimov
b3d90f5418 Update third-party/nlohmann_json to v3.9.1
the latest version w/o Apache 2.0 licensed code which conflicts with GPL 2.
2023-07-03 17:40:53 +02:00
Alexander A. Klimov
243b8aa7a8 Connect(): don't try next DNS record if operation is canceled
Instead return immediately to meet the caller's expectations.
2023-07-03 17:16:26 +02:00
Alexander Aleksandrovič Klimov
c0bd0936f9
Merge pull request #9682 from Icinga/9631-213
Setup all signal handlers with SA_RESTART flag
2023-02-16 16:24:26 +01:00
Alexander Aleksandrovič Klimov
fe2fed4817
Merge pull request #9680 from Icinga/9488-213
Fix compile error on Solaris 11.4
2023-02-16 16:24:05 +01:00
Alexander Aleksandrovič Klimov
6dfc21f9bd
Merge pull request #9678 from Icinga/181b213
Bump Boost to v1.81
2023-02-16 16:23:50 +01:00
Alexander A. Klimov
d2e3a094c1 Introduce AtomicFile#GetTempFilename() 2023-02-15 17:20:35 +01:00
Alexander A. Klimov
69b3c81ea1 Remove unused Utility::CreateTempFile() 2023-02-15 17:20:02 +01:00
Alexander A. Klimov
34844c146d Deduplicate and stabilize fragile filesystem transactions
by using AtomicFile so they ensure all or nothing of a file gets replaced.
2023-02-15 17:19:57 +01:00
Alexander A. Klimov
f0c1764adc Introduce AtomicFile::Write() 2023-02-15 16:25:39 +01:00
Alexander A. Klimov
a497645127 Setup all signal handlers with SA_RESTART flag
so interrupted syscalls get auto-restarted and callers
don't get or have to handle the EINTR error.
2023-02-15 11:08:29 +01:00
Alexander A. Klimov
a1bda3300e Fix compile error on Solaris 11.4
by not using LOG_FTP which is not defined there.
2023-02-15 10:48:05 +01:00
Alexander A. Klimov
68198f2ef9 Handle boost::beast::http::basic_fields#set() signature change (v1.81)
Make String convertible to boost::beast::string_view (always working),
not boost::string_view (broken).
2023-02-15 10:41:31 +01:00
Alexander A. Klimov
3d2a6bbfb1 Allow hashmaps of String 2022-11-04 12:47:41 +01:00
Alexander A. Klimov
de60eb445b Logger: don't render log messages which will be disposed anyway
by caching the total minimum log severity of all loggers in a
"global variable" and whether a message's severity is large enough for any of
the loggers in a per-message no-op flag.
2022-10-26 11:55:10 +02:00
Alexander A. Klimov
865c5b8365 Utility::ValidateUTF8(): move a string instead of copying a vector
less malloc() = more speed

Especially as JsonEncode() validates every single input string.
2022-10-26 11:55:10 +02:00
Julian Brost
1a2ee1241a
Merge pull request #9467 from Icinga/flush-state-file-213
Dump state file atomically not to corrupt it
2022-08-02 09:21:07 +02:00
Alexander A. Klimov
92a01a748d Dump state file atomically not to corrupt it
by using fsync(2) before close(2) and rename(2).
2022-08-01 17:56:37 +02:00
Alexander A. Klimov
53af4f2dd4 Introduce AtomicFile 2022-08-01 17:56:37 +02:00
Julian Brost
cc1e9c05ec Windows: output useful error message for syscall errors 2022-08-01 17:56:37 +02:00
Julian Brost
67fb24cc11 Windows: only include critical messages in early log messages
The point of logging to the Windows Event Log was to catch errors that happen
before the full logging configuration has been loaded and enabled. Messages
like the number of loaded objects per type just cause noise in the log and
provide little benefit. Therefore raise the required log level at this stage.

Note that this commit removes the (never documented) ability to use the -x flag
to change the level. But doing so would require patching the command line of
the service in the registry anyways.
2022-07-26 18:33:22 +02:00
Julian Brost
184548f4fe Replace EventuallyAtomic with AtomicOrLocked which falls back to a mutex
Apparently there was a reason for making the members of generated classes
atomic. However, this was only done for some types, others were still accessed
using non-atomic operations. For members of type T::Ptr (i.e.  intrusive_ptr<T>),
this can result in a double free when multiple threads access the same variable
and at least one of them writes to the variable.

This commit makes use of std::atomic<T> for more T (it removes the additional
constraint sizeof(T) <= sizeof(void*)) and uses a type including a mutex for
load and store operations as a fallback.
2022-06-14 13:46:40 +02:00
Julian Brost
e289ec689e
Merge pull request #9337 from Icinga/Al2Klimov-patch-3-213
Let new cluster certificates expire after 397 days, not 15 years
2022-04-11 21:20:39 +02:00
Alexander A. Klimov
f63b364d91 Renew certificates also periodically 2022-04-11 12:43:54 +02:00
Alexander A. Klimov
83911d0e05 Introduce IsCertUptodate() 2022-04-11 12:43:54 +02:00
Alexander A. Klimov
85f8496017 Let new cluster certificates expire after 397 days, not 15 years
https://cabforum.org/wp-content/uploads/CA-Browser-Forum-BR-1.7.3.pdf, section 6.3.2:

"Subscriber Certificates issued on or after 1 September 2020 SHOULD NOT have a Validity Period greater than 397 days and MUST NOT have a Validity Period greater than 398 days."
2022-04-11 12:43:53 +02:00
Julian Brost
9d566e0138
Merge pull request #9328 from Icinga/bugfix/parallel-api-package-calls-do-not-finish-while-reload-213
Worker process doesn't let parallel API package stage updates to complete when terminated
2022-04-07 17:09:52 +02:00
Yonas Habteab
236a888c1b Defer: Allow to cancel the callback before going out of scope 2022-04-07 11:58:04 +02:00
Yonas Habteab
36c75218e4 ConfigObject: Initialize local static var at declaration to ensure thread safety 2022-03-29 16:38:09 +02:00
Alexander A. Klimov
1d1e2b2888 Introduce IoEngine::YieldCurrentCoroutine() 2022-03-03 09:57:03 +01:00
Alexander A. Klimov
3cc82069cd Icinga DB: log amount of history kept in memory every 10s 2022-03-03 09:57:03 +01:00
Alexander A. Klimov
0137713d15 Icinga DB: keep history in memory until written to Redis
by putting the messages into a Bulker and retrying each chunk.
2022-03-03 09:57:03 +01:00
Alexander A. Klimov
8538ba97aa Introduce Bulker 2022-03-03 09:57:03 +01:00
Noah Hilverling
6ddac83d81 Dictionary: Make sure underlaying map is ordered 2021-11-12 17:55:47 +01:00
Julian Brost
1dcba7d127 tlsutility: move hex encoding into a separate function BinaryToHex 2021-11-11 16:58:16 +01:00
Julian Brost
6080538223 Enable hostname verification in UnbufferedAsioTlsStream 2021-08-19 11:06:19 +02:00
Julian Brost
ec73b417f2 ApiListener: Choose bind host default based on OS IPv6 support 2021-08-06 12:19:08 +02:00
Julian Brost
9d5ae0f6fa
Merge pull request #8899 from Icinga/feature/icingadb-connect_timeout
Introduce IcingaDB#connect_timeout
2021-07-28 13:52:00 +02:00
Julian Brost
cc8d3fbedd
Merge pull request #8937 from Icinga/bugfix/timeout-always-unknown
Override exit code on process timeout
2021-07-28 11:56:42 +02:00
Alexander A. Klimov
504fdda76c Introduce DEFAULT_CONNECT_TIMEOUT 2021-07-27 21:57:02 +02:00
Noah Hilverling
07cb6cd1cb
Merge pull request #8930 from Icinga/bugfix/wq-balance
WorkQueue#ParallelFor(): optionally don't pre-glue items together to chunks of different size
2021-07-27 19:05:26 +02:00
Julian Brost
a55939e462 Override exit code on process timeout
As Icinga first sends a SIGTERM to a check plugin on timeout to allow it to
terminate gracefully, this is not really part of the plugin API specification
and we cannot assume that plugins will handle this correctly and still exit
with an exit code that maps to UNKNOWN. Therefore, once Icinga decides to kill
a process, force its exit code to 128 to be sure the state will be UNKNOWN
after a timeout.
2021-07-27 17:57:19 +02:00
Alexander A. Klimov
8731d84299 WorkQueue#ParallelFor(): optionally don't pre-glue items together to chunks of different size
... to equally distribute the load across the workers.
2021-07-26 11:40:43 +02:00
Alexander A. Klimov
37e53eaa68 Icinga DB: support TLS 2021-07-22 14:34:07 +02:00