2079 Commits

Author SHA1 Message Date
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
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
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
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
Yonas Habteab
8ef921aa5e Implement bool operator for ObjectLock 2025-07-08 18:24:16 +02:00
Yonas Habteab
4c0628c24d Allow to defer lock on ObjectLock 2025-07-08 18:24:16 +02:00
Yonas Habteab
455d6fcde1 Introduce ValueGenerator class 2025-07-08 18:24:16 +02:00
Julian Brost
0ebcd2662d No longer allow overriding the frozen attribute of containers
The Array, Dictionary, and Namespace types provide a Freeze() method that makes
them read-only. So far, there was the possibility to call some methods with
`overrideFrozen=true` which would then bypass the corresponding check and allow
modification of the data structures nonetheless.

With 24b57f0d3a222835178e88489eabd595755ed883, this possibility was already
removed from the Namespace type. However, for interface compatibility, it kept
the parameter and just ignores it, throwing an exception on any modification on
a frozen instance.

The only place using `overrideFrozen` was processing of the `-D`/`--define`
command line flag that allows setting additional variables in the DSL. At the
time it is evaluated, there are no user-created data structures yet that could
be frozen, so the only frozen objects that could be encountered are Namespaces
(Icinga doesn't freeze other types by itself) and for these, `overrideFrozen`
already has no effect.

Hence, there is no harm in removing `overrideFrozen` altogether. This
simplifies the code and also means that frozen objects are now indeed read-only
without exceptions, allowing further optimizations regarding locking in the
future.
2025-07-08 14:16:20 +02:00
Johannes Schmidt
157e3750e3 Add IsLockable method to WaitGroup 2025-06-13 14:48:07 +02:00
Yonas Habteab
bc5db9834f Drop System#track_parents DSL function
No external user needs to manipulate the actual object dependency
graphs. This was maybe introduced for debugging purposes at that time
but if someone messes with this in prod - good luck with that. Oh, apart
from that it's broken :( and doesn't track parents as its implies but
children.
2025-06-03 17:09:57 +02:00
Julian Brost
c253e7eb6e
Merge pull request #10397 from Icinga/activation-priority-10179
Checkable#ProcessCheckResult(): discard🗑️ CR or delay its producers shutdown
2025-05-28 12:30:40 +02:00
Yonas Habteab
7d2f1c2030 Drop Windows VISTA from the supported platform
Boost `1.88.0` introduced a feature [^1] that makes use of the Windows API, but it
uses API functions that are only available with `PSAPI_VERSION >= 2` and
Windows VISTA only supports `PSAPI_VERSION == 1`. Actually, that new feature
can also be disabled by setting the `BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE`
macro, but since it seems to be a useful feature and isn't even disabled by default,
we can just drop it that ancient Windows version instead of disabling it.

[^1]: https://github.com/boostorg/stacktrace/pull/200
2025-05-28 09:39:03 +02:00
Yonas Habteab
d265329a17
Merge commit from fork
Fix for master
2025-05-27 13:50:26 +02:00
Alexander Aleksandrovič Klimov
56d9f38b35
Merge pull request #10456 from Icinga/SharedObject-delete
SharedObject: delete unused methods
2025-05-26 10:00:52 +02:00
Alexander A. Klimov
4f351f625f SharedObject: delete unused methods
None of the derived classes use them, none shall have to explicitly delete them.
2025-05-23 15:47:02 +02:00
Alexander A. Klimov
18fb93fc11 Introduce WaitGroup and StoppableWaitGroup 2025-05-23 14:53:58 +02:00