1740 Commits

Author SHA1 Message Date
Julian Brost
5c35ab551b Enable hostname verification in UnbufferedAsioTlsStream 2021-08-17 18:49:35 +02:00
Julian Brost
a261a96a99 Add comments to stack trace formatter and test case 2021-07-08 13:59:39 +02:00
Julian Brost
3d650e865d Use backtrace_symbols() when printing stack traces on FreeBSD
Unfortunately, the symbol resolution of boost::stacktrace is broken on
FreeBSD, therefore fall back to using backtrace_symbols() to print the
stack trace saved by Boost.

Additionally, -D_GNU_SOURCE is required on FreeBSD for the
_Unwind_Backtrace function used by boost::stacktrace.
2021-07-08 13:59:39 +02:00
Julian Brost
0246765a5c Crash handlers: use more compact string representation 2021-07-08 13:59:39 +02:00
Julian Brost
0dda2de696 Begin crash log for SIGABRT with error message and timestamp
This makes the format more similar to what the uncaught C++ and SEH
exception handlers write. Previously there was no indication in the
crash log that a SIGABRT happened.
2021-07-08 13:59:39 +02:00
Julian Brost
a342d75cc3 Add some comments to __cxa_throw
Maybe this will save the next person who has to look at this code some
time. Please don't blame me for the implementation, I'm just trying to
reconstruct what it does.
2021-07-08 13:59:39 +02:00
Julian Brost
9aeb962863 Restructure stack and context trace selection in DiagnosticInformation and document behavior
The logic for selecting the traces to print stays the same, but there
are fewer nested ifs now. This changes the format of the returned string
a bit by adding a heading for both traces.
2021-07-08 13:59:39 +02:00
Julian Brost
6104df37dc Add documentation for cast_exception function 2021-07-08 13:59:39 +02:00
Julian Brost
27767b1aa3 Pass fallback stacktrace to DiagnosticInformation in terminate handler
By default, DiagnosticInformation uses the stack trace saved when the
exception was thrown, but this mechanism is not in use on Windows.
Gathering a stacktrace in the terminate handler serves as a fallback.
2021-07-08 13:59:39 +02:00
Julian Brost
58d553a971 Replace icinga::StackTrace with boost::stacktrace::stacktrace
Provides roughly the same functionality but works better on certain
platforms (especially Windows) and is less code to maintain.
2021-07-08 13:59:39 +02:00
Julian Brost
fb303f5205 Print details in uncaught SEH exception handler 2021-07-08 13:59:39 +02:00
Julian Brost
a77c37da8e Move error message and time to the beginning of the SEH crash log
This is more similar to the normal exception crashlog which also states
the problem and time at the beginning of the file.
2021-07-08 13:59:39 +02:00
Julian Brost
2c9b1d8415 Use boost::stacktrace instead of custom implementation in Windows SEH filter 2021-07-08 13:59:39 +02:00
Julian Brost
0b9ef5ab6d Run termination handler for uncaught C++ exceptions on Windows
On Windows, the termination handler is executed for uncaught C++
exceptions unless a SEH unhandled exception filter is also set. In this
case, this filter has to explicitly chain the default filter to keep
this behavior.
2021-07-08 13:59:39 +02:00
Julian Brost
fc0019b271 Utility: add a function to truncate strings while avoiding collisions 2021-07-05 16:18:40 +02:00
Julian Brost
c0c7d52921 Retry file rename operations on Windows for some errors 2021-05-26 08:51:22 +02:00
Alexander Aleksandrovič Klimov
04d8eee3e5
Merge pull request #8793 from Icinga/bugfix/211boost174
Support Boost 1.74
2021-05-25 15:26:19 +02:00
Julian Brost
50820f1a73 Provide a conversion function from icinga::String to boost::string_view
Boost.Beast changed the signature of
boost::beast::http::basic_fields::set in version 1.74 so that no longer
allows passing an icinga::String instance as value. This adds a
conversion function so that it works again.
2021-05-20 16:28:30 +02:00
Louis Sautier
514a4e326f Fix ‘fs::copy_option’ has not been declared with boost 1.74.0
It was deprecated in
f199152b7d
2021-05-20 16:28:30 +02:00
Julian Brost
398a5baf70 Remove unused function declarations in tlsutility.hpp
These were introduced in c510fe4dfed0f65824bb259433faa0988caa2447, probably
when resolving a merge conflict. However, these functions do not exist in 2.11,
but refer to the Array type which is not included in the header, leading to
non-unity build failing.

This commit simply removes these declarations and thus restores non-unity
builds in 2.11.
2021-05-20 14:25:59 +02:00
Noah Hilverling
9c433044cc Build fix: Use correct shared pointer implementation 2020-12-15 13:00:23 +01:00
Julian Brost
c510fe4dfe Verify certificates against CRL before renewing them
When a CRL is specified in the ApiListener configuration, Icinga 2 only
used it when connections were established so far, but not when a
certificate is requested. This allows a node to automatically renew a
revoked certificate if it meets the other conditions for auto-renewal
(issued before 2017 or expires in less than 30 days).
2020-12-15 10:38:37 +01:00
Julian Brost
905cf5aa65 Use ERR_error_string_n() instead of ERR_error_string()
Explicitly pass the actual length of the buffer to avoid overflows.
2020-12-09 12:23:07 +01:00
Julian Brost
3b37867d2e Increase size of buffer for OpenSSL error messages
According to man 3 ERR_error_string, "buf must be at least 256 bytes
long", therefore increase the buffer size to 256 everywhere.
2020-12-09 12:23:07 +01:00
Julian Brost
64a49ee3a1 Remove std::string to_string(const errinfo_openssl_error& e)
The function was never used and it's implementation contains a bug where
a buffer of too small size is used as a paramter to ERR_error_string.
According to the `man 3 ERR_error_info`, the buffer has to be at least
256 bytes in size.

Also the function seems of limited use as it allows to output the tag
object used with additional error information for exceptions in Boost.
However, you boost::get_error_info<>() just returns the value type but
not the full tag object from the exception.
2020-12-09 12:22:52 +01:00
Julian Brost
072434f3f3 Remove SpinLock
No longer needed as its only user now uses std::mutex.
2020-11-27 11:24:17 +01:00
Julian Brost
fde51ed9f7 Add Process::WaitForResult to allow waiting for the process to finish 2020-11-27 11:24:17 +01:00
Alexander A. Klimov
8fff42c73d Buildfix 2020-10-13 16:36:10 +02:00
Alexander Aleksandrovič Klimov
dd8b786b3b
Merge pull request #8292 from Icinga/bugfix/icinga2-doesn-t-close-connections-7203-211
Add timeout for boost::asio::ssl::stream#async_shutdown()
2020-10-13 13:58:39 +02:00
Julian Brost
21b30322c9
Merge pull request #8308 from Icinga/bugfix/configsyncstagelock-unlock-owner
Make ApiListener::m_ConfigSyncStageLock a SpinLock
2020-10-13 13:37:08 +02:00
Alexander A. Klimov
0abcf7ea6f Introduce SpinLock 2020-10-02 17:54:36 +02:00
Alexander A. Klimov
186a9e95f7 Generalize I/O timeout emulation 2020-09-28 15:39:29 +02:00
Henrik Triem
3468191450 WorkQueue: Allow choosing stats log level 2020-09-22 14:35:51 +02:00
Noah Hilverling
5911879ffa
Merge pull request #8120 from Icinga/feature/shared-t
Introduce Shared<T>
2020-07-21 09:10:13 +02:00
Alexander A. Klimov
2138480704 Introduce Shared<T> 2020-07-17 16:50:18 +02:00
Noah Hilverling
d6a007cd27
Merge pull request #8094 from Icinga/bugfix/jsonrpcconnection-m_seen
Consider a JsonRpcConnection being seen on a single byte of TLS payload, not only a whole message
2020-07-08 09:59:22 +02:00
Noah Hilverling
e59c2e896f
Merge pull request #8054 from Icinga/bugfix/segfault-map-reduce-filter-null-8047
Ensure the custom function is not null in Array#{sort,map,reduce,filter,any,all}()
2020-06-15 16:16:30 +02:00
Noah Hilverling
949da2bc6b
Merge pull request #8043 from Icinga/bugfix/unify-application-start-times-v2114
Fix timing point for Application::GetStartTime() (related to command endpoint grace period)
2020-06-09 14:04:07 +02:00
Alexander A. Klimov
9c85401914 Ensure the custom function is not null in Array#{sort,map,reduce,filter,any,all}()
refs #8047
2020-06-09 12:35:04 +02:00
Michael Friedrich
18fdc1457a Unify Application::GetStartTime() and drop GetMainTime()
This essentially moves the start time into the scope when main
starts to "do something", after the reload and configuration handling
is done.
2020-06-03 16:25:53 +02:00
Michael Friedrich
4878daff44 Introduce Application::GetUptime() 2020-06-03 16:21:01 +02:00
Alexander A. Klimov
0f84ce0470 Consider a JsonRpcConnection being seen on a single byte of TLS payload, not only a whole message 2020-02-19 11:11:53 +01:00
Alexander A. Klimov
99387dd536 IoEngine#SpawnCoroutine(): always terminate coroutines cleanly 2020-02-13 18:27:18 +01:00
Michael Friedrich
2c0e0da2d9 Introduce IoEngine::SpawnCoroutine wrapping asio::spawn and Boost exceptions
This is required to

- catch all exceptions and wrap them into Boost exceptions. They
are the only ones allowed with Boost.Coroutine.
- set a dedicated coroutine stack size for Windows.

refs #7431
2019-09-09 16:40:35 +02:00
Michael Friedrich
5fa7331cc9 Quality: Replace deprecated Boost IO service code
https://github.com/boostorg/asio/issues/110
https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/example/cpp03/services/logger_service.hpp
2019-09-09 15:27:57 +02:00
Michael Friedrich
1f50a705f9 Adjust code comment for Logger->Flush() on Windows 2019-09-06 09:24:34 +02:00
Michael Friedrich
c2e1d023e2
Merge pull request #7421 from Icinga/feature/threadpool-metric
Expose metric current_pending_callbacks
2019-08-15 10:51:31 +02:00
Alexander A. Klimov
a58a5feee3 Introduce ThreadPool#GetPending() 2019-08-14 17:12:59 +02:00
Michael Friedrich
43ea6fb636
Merge pull request #7419 from Icinga/bugfix/downtime-loop-activate-origin
Fix object create/delete config object cluster loop (missing message origin)
2019-08-14 16:29:08 +02:00
Michael Friedrich
96f62d2d34 Add Utility::ParseVersion() and unit tests
This now uses a regex to extract the short version
similar to how Icinga Web 2 does it.

Additional unit tests prove the rule.
2019-08-14 11:22:55 +02:00