18496 Commits

Author SHA1 Message Date
Tobias Brunner
da0d0ecc45 vici: Add Python 3.10 and 3.11 2022-12-12 16:57:01 +01:00
Tobias Brunner
03541c73a0 github: Fix Python build with custom OpenSSL version 2022-12-12 16:57:01 +01:00
Tobias Brunner
3dd5dc5011 Merge branch 'vici-python-timeout'
Closes strongswan/strongswan#1416
2022-12-12 14:38:46 +01:00
Martin Willi
484c0f8dd0 vici: Gracefully consume/ignore incoming events in Python event deregistration
When issuing a deregistration message, some last events may still be sent
by the daemon before deregistration completes. Ignore such event messages
silently during deregistration, avoiding exceptions like:

  vici.exception.SessionException:
    Unexpected response type 7, expected '5' (EVENT_CONFIRM)
2022-12-12 14:38:09 +01:00
Martin Willi
254d4075fe vici: Add some initial session level unit-tests 2022-12-12 14:38:09 +01:00
Martin Willi
aa0da01fde vici: Add simple Python transport layer tests, including timeout 2022-12-12 14:38:09 +01:00
Martin Willi
248a188d21 vici: Allow the Python event listen() operation to optionally time out
The architecture of the Python client is completely blocking, which is fine
for many simple scripts. For more complex applications that do other I/O
and listen for vici events, the most feasible way to integrate the client is
to use a dedicated thread.

Unfortunately, Python has no simple support for thread cancellation. And
having that thread in a blocking recv() does not allow to terminate the
thread gracefully with an Event or the like.

As a way out, add a timeout to the listen() call, so the thread can
periodically do other things, like checking for termination Event and
react on it. Returning from listen() on timeout can be suboptimal, though,
as it involves registration/deregistration for events, including the risk
for missing events while not registered. So return a (None, None) tuple
instead on timeout, allowing the caller to periodically do other things
while staying registered for the events and continue in listen().

The timeout applies to the socket recv() for the start of the header, only,
so a message is either read in full or times out, avoiding the risk
of breaking message framing on the stream with partial reads.
2022-12-12 14:38:09 +01:00
Martin Willi
11b18f65b1 vici: Remove support for Python 2
Python 2 is dead and unmaintained for a while now. Time to stop carrying
on its support.
2022-12-12 14:38:09 +01:00
Tobias Brunner
a2b1e06f07 vici: Base default soft lifetime on hard lifetime if configured
Depending on the configured hard lifetime the default soft lifetime
might not make sense and could even cause rekeying to get disabled.
To avoid that, derive the soft lifetime from the hard lifetime so it's
10% higher than the soft lifetime.

References strongswan/strongswan#1414
2022-12-12 14:24:50 +01:00
Dmitriy Alexandrov
b450865615 child-cfg: Fix apply_jitter() in case jitter is bigger than rekey value
Also avoid returning 0 and disabling rekeying in the rare case of
`jitter = rekey` and the `1/jitter` chance of that happening (returning
1 at least doesn't disable rekeying).

Co-authored-by: Tobias Brunner <tobias@strongswan.org>

Closes strongswan/strongswan#1414
2022-12-12 14:24:32 +01:00
Tobias Brunner
44378d2521 github: CodeQL currently doesn't support ccache
Just disable it but keep everything in place for now.
2022-12-06 09:41:42 +01:00
Andreas Steffen
8329455628 testing: Check canonical OCSP/CRL serial numbers 2022-12-05 20:18:24 +01:00
Andreas Steffen
0d88c76abc unit-tests: Check encoding/retrieval of serial numbers 2022-12-05 20:18:24 +01:00
Andreas Steffen
18082ce2b0 certificates: Retrieve serial numbers in canonical form
The x509 plugin retrieves serial numbers with two's complement
encoding whereas the openssl plugin partially returns them without
leading zeroes.

Serial numbers in X.509 certificates, X.509 CRL, X.509 attribute
certificates, OCSP Requests and OCSP responses are now returned in
canonical form without prepended zero octets.
2022-12-05 20:18:24 +01:00
Tobias Brunner
cb5ae75ac1 github: Remove obsolete LGTM workflow
lgtm.com will be shutdown soon.
2022-12-05 16:49:07 +01:00
Tobias Brunner
0d3fcd100d github: Add CodeQL workflow 2022-12-05 16:49:07 +01:00
Tobias Brunner
b1482f5204 github: Fix path to Android lint report
Has a -debug suffix now.
2022-12-02 16:09:41 +01:00
Tobias Brunner
ef525ff980 github: Update GitHub-provided actions so they don't use deprecated Node.js 12 2022-12-02 16:09:41 +01:00
Tobias Brunner
0fea6a7f8e github: Adapt to switch to Ubuntu 22.04 for ubuntu-latest
Ubuntu 22.04 ships OpenSSL 3, which requires debug symbols so we can
whitelist leaks because we don't deinitialize the library.  And because
the shipped library is not built with `-fno-omit-frame-pointer`, the
build with AddressSanitizer can't use its fast stack unwind method.
However, the previous workaround for DTLS handling with glibc apparently
isn't necessary anymore.

In the custom OpenSSL build we drop no-stdio as that lets the configure
check for libldns fail because ERR_print_errors_fp@OPENSSL_3.0.0 is not
found.

For ccache, the default path to the cache directory has changed.

Also simplified the NM tests as there is only one build since
085daf474330 ("nm: Remove old libnm-glib compat stuff").
2022-12-02 16:09:04 +01:00
Tobias Brunner
7991871bd6 github: Set timeout for tests on macOS
They sometimes hang (without our internal timeout catching them).
So instead of waiting for hours, let them get aborted earlier.
2022-12-02 14:58:23 +01:00
Tobias Brunner
74e319c3f5 fuzz: Force make check to fail if fuzz target fails 2022-12-02 14:58:23 +01:00
Tobias Brunner
30cda14426 leak-detective: Whitelist additional OpenSSL 3 functions
These are necessary when building against the OpenSSL 3 version shipped
with Ubuntu (the first is only seen when built with --enable-bfd-backtraces).
2022-12-02 14:58:23 +01:00
Tobias Brunner
9628c771ad backtrace: Suppress internal errors by libbfd
At least since Ubuntu 22.04 there are lots of (apparently non-fatal)
"DWARF error: could not find variable specification" errors generated
by bfd_find_nearest_line().  This also happens with addr2line, which
internally uses libbfd.  No idea what the actual issue is (it still
happens with binutils 2.39 in Ubuntu 22.10), but since it doesn't seem
to affect the functionality we need this avoids filling the test logs
with useless messages.
2022-12-02 14:57:55 +01:00
Tobias Brunner
21af89f941 backtrace: Add ability to lookup function names via libbfd
dladdr() is not always able to determine the function names while
libbfd often can in such cases.
2022-12-02 14:57:47 +01:00
Tobias Brunner
02519ad60e af-alg: Fix compiler warning 2022-12-02 14:56:38 +01:00
Tobias Brunner
3809bdac90 farp: Remove unused variable 2022-12-02 14:56:38 +01:00
Tobias Brunner
4b8eb6e8d9 nm: Ignore lock file left behind by newer versions of intltool 2022-12-02 14:56:38 +01:00
Tobias Brunner
42165f81bc thread: Exclude thread_main() from AddressSanitizer
With GCC 11.3 AddressSanitizer causes the following crash when a thread
is cancelled (e.g. in the test_condvar_cancel test):

==84365==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_thread.cpp:367 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0)
    #0 0x7ff0801b2988 in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cpp:74
    #1 0x7ff0801d330e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:78
    #2 0x7ff0801b810c in __asan::AsanThread::GetStackFrameAccessByAddr(unsigned long, __asan::AsanThread::StackFrameAccess*) ../../../../src/libsanitizer/asan/asan_thread.cpp:367
    #3 0x7ff080122e9b in __asan::GetStackAddressInformation(unsigned long, unsigned long, __asan::StackAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:203
    #4 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:455
    #5 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:439
    #6 0x7ff080126a84 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) ../../../../src/libsanitizer/asan/asan_errors.cpp:389
    #7 0x7ff0801b1fa5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../src/libsanitizer/asan/asan_report.cpp:476
    #8 0x7ff080148fe8 in __interceptor_sigaltstack ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:9986
    #9 0x7ff0801af473 in __asan::PlatformUnpoisonStacks() ../../../../src/libsanitizer/asan/asan_posix.cpp:44
    #10 0x7ff0801b500c in __asan_handle_no_return ../../../../src/libsanitizer/asan/asan_rtl.cpp:612
    #11 0x7ff07fe04d50 in thread_main /media/sf_scratch/src/libstrongswan/threading/thread.c:321
    #12 0x7ff07d7d4b42 in start_thread nptl/pthread_create.c:442
    #13 0x7ff07d8669ff  (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff)
2022-12-02 14:56:31 +01:00
Tobias Brunner
6ce9aba022 tnccs: Fix Doxygen comments for callback 2022-11-28 17:23:13 +01:00
Tobias Brunner
9fe093c4e2 callback-cred: Document missing callback argument 2022-11-28 17:18:18 +01:00
Tobias Brunner
0fbdc9e925 Doxyfile: Remove obsolete options and replace obsolete paper type value 2022-11-28 17:18:18 +01:00
Tobias Brunner
977ab29fc1 Use Botan 2.19.3 for tests 2022-11-28 16:02:25 +01:00
Tobias Brunner
c1250c56ae testing: Use HTTPS for strongSwan tarballs 2022-11-28 15:57:57 +01:00
Tobias Brunner
4242c81243 testing: Fix URL for kernel patches 2022-11-28 15:55:31 +01:00
Tobias Brunner
4dd3d0e57b Merge branch 'number-formats'
Document the accepted number formats in swanctl.conf/strongswan.conf and
clarify some details for specific options.

Closes strongswan/strongswan#1329
2022-11-10 16:53:50 +01:00
Tobias Brunner
c1c85b0fd1 swanctl: Document the type/size of interface IDs 2022-11-10 16:50:02 +01:00
Tobias Brunner
284fc2f796 swanctl: Document the behavior of %unique[-dir] on IKE_SAs 2022-11-10 16:50:02 +01:00
Tobias Brunner
64b10dfb28 conf: Document accepted number and time formats 2022-11-10 16:50:02 +01:00
Tobias Brunner
185b1376a3 conf: Explicitly add time unit to default value for options that accept them 2022-11-10 16:49:35 +01:00
Tim Weller
af71f14ba3 wolfssl: Updates to resolve build conflicts
The wolfSSL's OpenSSL compatibility layer is not used by the plugin at
all and preventing its inclusion avoids conflicts with ASN1_ constants.

The inclusion of wolfssl/ssl.h is moved to the only file that requires
it as older wolfSSL versions defined a conflicting ASN1_GENERALIZEDTIME.

Other changes address issues with the FIPS use case.

Closes strongswan/strongswan#1332
2022-11-10 16:23:44 +01:00
Tobias Brunner
7db77fd32b Use wolfSSL 5.5.3 for tests 2022-11-10 16:15:36 +01:00
Tobias Brunner
652ce18120 github: Use OpenSSL 3.0.7 for tests 2022-11-10 16:15:36 +01:00
Tobias Brunner
2bf110d9f8 backtrace: Fix build with newer MinGW versions
A recent change added CALLBACK to PENUM_PAGE_FILE_CALLBACKW/A in psapi.h,
which conflicts with our own macro of the same name.  Our compat/windows.h
header undefs the Windows definition, but that only works if Windows
headers are included before ours, which wasn't the case for psapi.h.
2022-11-10 13:44:21 +01:00
Tobias Brunner
f16a12eae5 github: Fix URL to BoringSSL repository for Android build 2022-11-05 14:58:02 +01:00
Tobias Brunner
d42f4367dd cirrus: Don't explicitly install openldap*-client on FreeBSD
This avoids a conflicts as mysql80-client has a dependency on either
openldap24-client (FreeBSD 12) or openldap26-client (FreeBSD 13) so e.g.
installing openldap24-client on FreeBSD 13 causes

  openldap26-client-2.6.3 conflicts with openldap24-client-2.4.59_4 on /usr/local/bin/ldapadd

Similarly, when installing openldap26-client on FreeBSD 12.  So just let
the mysql80-client package decide which version is installed.
2022-10-06 12:26:50 +02:00
Tobias Brunner
68782f35c0 github: Try to avoid crashes by LeakSanitizer
There are spurious crashes after test runs (during the reporting phase
of LeakSanitizer) that are triggered by seemingly unrelated code changes.
It seems to be related to how glibc handles dynamic TLS allocations.
2022-10-06 11:11:35 +02:00
Tobias Brunner
7f46c76125 Make functions static that are only accessed from the same compilation unit
Also removed some declarations for undefined functions.
2022-10-05 19:00:46 +02:00
Tobias Brunner
c58ba0cb9f openssl: Remove unused openssl_hash_chunk() helper
Was used by the ECDSA implementation before 293a912c7de6 ("openssl: Fixes
for ECDSA with OpenSSL 3.0").
2022-10-05 18:15:26 +02:00
Thomas Egerer
4ea61dcbfe kernel-interface: Make first reqid configurable
This can be helpful to reserve low reqids for manual configuration.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2022-10-05 10:28:05 +02:00
Tobias Brunner
27da024a5d backtrace: Only define print_sourceline() and esc() if actually used 2022-10-03 17:36:17 +02:00