Commit graph

2091 commits

Author SHA1 Message Date
Yonas Habteab
afd22622fb Process: Remove dead code 2026-01-26 16:39:10 +01:00
Yonas Habteab
014ff59a63 Reserve vector capacity where applicable & declare variables only when they're to be used 2026-01-26 16:03:03 +01:00
Alexander A. Klimov
4ba46f9eb2 Silence compiler warnings about unused parameters
Every of these parameters exists for a reason.
The best we can do is to convince the compiler.
2026-01-23 13:31:01 +01:00
Johannes Schmidt
1505f09ed6 Refactor HttpMessage into generalized templated types
This adds generalized IncomingHttpMessage and OutgoingHttpMessage templates
that support different types of streams (via a std::variant) and can both
be used for either requests or responses.

The tacked on metadata from the old HttpRequest and server connection from
the old HttpServerConnection have been moved to HttpApi(Request|Response)
classes that derive from the above generalized message types.
2026-01-22 17:20:32 +01:00
Yonas Habteab
0b2f22ce40 tlsutility: make cert ts configurable & use ASN1_TIME_compare for comparison 2025-12-04 13:01:48 +01:00
Brad Smith
bbc1859aa1 Have thread name length clamping also apply for the other OSes
This covers macOS, *BSDs, Linux, Cygwin.

NetBSD PTHREAD_MAX_NAMELEN_NP 32
macOS 64
OpenBSD 24
Linux/FreeBSD/DragonFly/Cygwin 16
2025-11-27 09:19:16 -05:00
Brad Smith
7aa777c40f Fix usage of pthread_setname_np() on NetBSD
NetBSD's pthread_setname_np() takes a slightly different set of parameters.
2025-11-27 07:16:34 -05:00
Alvar
8c230df3da
Merge pull request #10640 from brad0/openbsd_dlopen
Fix dlopen()'ing libraries on OpenBSD
2025-11-27 12:13:18 +00:00
Brad Smith
d243da72e5 Fix dlopen()'ing libraries on OpenBSD 2025-11-27 04:52:28 -05:00
Brad Smith
cf8fc3d64f
Add tests for pthread_set_name_np() and pthread_setname_np()
Looks like the conversion from autoconf to CMake dropped
these tests along the way.
2025-11-27 10:48:54 +01:00
Brad Smith
77881a7e18 Enable the pthread_np.h header on OpenBSD and DragonFly
Necessary for pthread_set_name_np().
2025-11-25 15:46:02 -05:00
Johannes Schmidt
a2e0ce426f Fix -Wunused-variable warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
7b4697a237 Fix -Wredundant-move warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
93e69ed0e8 Fix -Wsign-compare warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
758d1b6873 Fix -Wsuggest-override warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
4f0a24f8ab Add ABORT() macro for unconditionally failing ASSERTS
This is necessary to stop MSVC complaining that "not all paths return a value", because
it is not able to infer that the expression `false ? 0 : non_returning_function()`
never returns.

In the process of debugging this I've also slightly simplified the other assert macros and
abort function, so they don't need compiler specific preprocessor-paths anymore.
2025-11-19 11:55:49 +01:00
Johannes Schmidt
f42510f981
Merge pull request #9411 from Icinga/compiler-warnings
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Fix compiler warnings
2025-10-21 15:23:31 +02:00
Alexander A. Klimov
9612de881a Fix compiler warnings by not std::move()ing where redundant 2025-10-17 17:08:31 +02:00
Alexander A. Klimov
78631fa319 Fix compiler warnings by ensuring variable initialization 2025-10-17 17:08:31 +02:00
Alexander A. Klimov
315c9a3692 Fix compiler warnings by replacing x&&y||z with (x&&y)||z 2025-10-17 17:08:30 +02:00
Alexander Aleksandrovič Klimov
5d46ca4f77
Merge pull request #9730 from Icinga/don-t-define-use-openssl-callback-for-in-openssl-v1-1
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Don't define/use OpenSSL*Callback() for/in OpenSSL > v1.1
2025-10-17 16:41:07 +02:00
Alexander A. Klimov
37b5c39e20 Fix compiler warnings by re-ordering member init in constructors 2025-10-17 15:33:57 +02:00
Alexander Aleksandrovič Klimov
c25297e26a
Merge pull request #9729 from Icinga/fix-compiler-warnings-by-removing-unused-variables
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Windows / Windows (push) Waiting to run
Fix compiler warnings by removing unused variables
2025-10-17 15:12:05 +02:00
Alexander A. Klimov
728d6fff3e Don't define/use OpenSSL*Callback() for/in OpenSSL > v1.1
Since OpenSSL v1.1 the macros they're passed to expand to nothing creating
the illusion those functions aren't used. That triggers compiler warnings.
2025-10-17 14:28:00 +02:00
Alexander A. Klimov
3d69a31043 Fix compiler warnings by removing unused variables 2025-10-17 09:56:46 +02:00
Julian Brost
d372ecc20b AtomicOrLocked: use std::conditional_t and std::is_trivially_copyable_v
std::conditional_t was added in C++14, is_trivially_copyable_v in C++17, both
do the same as the previous implementation and are a bit more compact.
2025-10-16 16:50:03 +02:00
Julian Brost
a2dc35031c Remove obsolete workaround for GCC 4.x
The fallback implementation was added for GCC 4.x as that didn't yet implement
std::is_trivially_copyable. However, by now we're using C++17 as our language
standard and that wasn't even implemented in GCC 4.x yet[^1]:

    Some C++17 features are available since GCC 5, but support was experimental
    and the ABI of C++17 features was not stable until GCC 9.

Hence, this became more or less dead code and can be removed.

[^1]: https://gcc.gnu.org/projects/cxx-status.html#cxx17
2025-10-16 16:50:03 +02:00
Julian Brost
56255ac7a6
Merge commit from fork
Check for permissions when evaluating object filters
2025-10-16 14:13:36 +02:00
Johannes Schmidt
9fed14d6fa Filter global variables when Sandboxed 2025-10-02 15:51:42 +02:00
Johannes Schmidt
218e41aed6 Declare functions as unsafe that aren't useful in filter expressions
+ get_objects(): Has no use because in sandboxed contexts the result
                 can't be filtered or iterated over.
+ get_template(): Currently this is not dangerous because the returned
                  dictionary object does not hold any interesting
                  information. However, someone could add more details
                  in the future and forget to add a permission check.
+ get_templates(): Combines the reasons for get_objects() and
                   get_template()
+ get_env(): There is no point of ever using this in a filter expression.
2025-10-02 15:51:42 +02:00
Johannes Schmidt
07216bdf77 Check for permission in get_object() 2025-10-02 15:51:42 +02:00
Johannes Schmidt
61670d5f23 Add permission checking to script frames and filter utilities 2025-10-02 15:51:38 +02:00
Julian Brost
bc7debed4f
Merge pull request #10558 from Icinga/fix-posix-error-double-free
Fix double-free error in posix_error::what()
2025-09-23 16:14:45 +02:00
Alexander A. Klimov
4b2b45c8a1 Introduce AtomicDuration 2025-09-23 11:04:58 +02:00
Johannes Schmidt
db4e984989 Fix double-free error in posix_error::what() 2025-09-17 10:11:37 +02:00
Johannes Schmidt
3ebe95ba8c Allow UID/GID in ICINGA2_(USER|GROUP) environment variables 2025-08-25 14:31:19 +02:00
Yonas Habteab
1f92ec656b
Merge pull request #10523 from Icinga/dependency-eval-complexity
Prevent worst-case exponential complexity in dependency evaluation
2025-08-05 11:57:47 +02:00
Julian Brost
a49ec1015d Allow intrusive_ptr<const T> for objects
This allows using ref-counted pointers to const objects. Adds a second typedef
so that T::ConstPtr can be used similar to how T::Ptr currently is.
2025-07-30 16:42:27 +02:00
Julian Brost
ebd4fd1933 Log: don't construct std::ostringstream for no-op messages
This commit removes the existing m_IsNoOp bool and instead wraps the m_Buffer
std::ostringstream into std::optional. Functionally, this is pretty much the
same, with the exception that std::ostringstream is no longer constructed for
messages that will be discarded later.
2025-07-29 10:27:38 +02:00
Julian Brost
6487497665 Log: use std::forward in operator<< and remove overload for const char*
There already is a template operator<< implemented, so far only for const
references though. Changing this to perfectly forward the argument to the
corresponding operator in the underlying std::ostringstring allows handling all
the cases there, removing the need for a separate overload for const char*.
2025-07-29 10:27:38 +02:00
Julian Brost
1f15f0ff07 JsonEncoder: wrap writer for flushing
This commit intruduces a small helper class that wraps any writer and
provides a flush operation that performs the corresponding action if the
writer is an AsyncJsonWriter and does nothing otherwise.
2025-07-11 16:10:22 +02:00
Yonas Habteab
82b80e24c1 fix comment 2025-07-11 14:05:54 +02:00
Yonas Habteab
cd1ab7548c Rename AsyncJsonWriter::Flush() -> MayFlush() to reflect its usage 2025-07-11 13:55:33 +02:00
Yonas Habteab
89418f38ee JsonEncoder: let the serializer replace invalid UTF-8 characters
Replacing invalid UTF-8 characters beforehand by our selves doesn't make
any sense, the serializer can literally perform the same replacement ops
with the exact same Unicode replacement character (U+FFFD) on its own.
So, why not just use it directly? Instead of wasting memory on a temporary
`String` object to always UTF-8 validate every and each value, we just
use the serializer to directly to dump the replaced char (if any) into
the output writer. No memory waste, no fuss!
2025-07-10 18:09:21 +02:00
Yonas Habteab
dad4c0889f JsonEncoder: lock olock conditionally & flush output regularly 2025-07-10 18:09:21 +02:00
Yonas Habteab
398b5e3193 Implement LockIfRequired() method for Namespace, Dictionary & Array 2025-07-10 18:09:21 +02:00
Yonas Habteab
57726fbb66 Do not require olock on frozen Namespace, Dictionary & Array 2025-07-10 18:09:21 +02:00
Yonas Habteab
2461e0415d Introduce JsonEncode helper function
It's just a wrapper around the `JsonEncoder` class to simplify its usage.
2025-07-10 18:09:21 +02:00
Yonas Habteab
9dd2e2a3ec Introduce JsonEncoder class 2025-07-10 18:09:21 +02:00
Yonas Habteab
1c61bced03 Introduce AsyncJsonWriter output adapter interface 2025-07-09 13:41:15 +02:00