rsyslog/tests/sndrcv_tls_ossl_anon_ipv4.sh
Andre Lorbach cbc677b44f ci: Add macOS CI workflows
Add comprehensive macOS CI support with two new GitHub Actions
workflows:

- run_macos.yml: PR-triggered CI with matrix strategy covering macOS
  13–15, x64/arm64 architectures, and sanitizer combinations (none,
  ASAN, TSAN)
- run_macos_weekly.yml: Scheduled weekly testing with full matrix
  coverage and automated failure reporting via GitHub issues
- Set sin_len in tests/diagtalker.c on macOS to fix connect() EINVAL,
  unblocking TLS certvalid tests.

Root cause and fix details (macOS testbench)
- Why tests failed
  On macOS 14 the imdiag control listener often ended up IPv6-only.
  The plain TCP listener creates an IPv6 socket and sets IPV6_V6ONLY;
  the companion IPv4 bind can fail on macOS when sharing an ephemeral
  port, leaving only the IPv6 listener active. Our injector
  tests/diagtalker.c was IPv4-only (AF_INET to 127.0.0.1), so it could
  not reach the imdiag port, causing repeated connect retries and
  timeouts. CI logs showed “cannot connect to 127.0.0.1:<port> …
  Connection refused” alongside benign OpenSSL anon-mode warnings.

- What we changed
  1) Made the injector dual-stack by switching diagtalker to
     getaddrinfo(AF_UNSPEC) and trying both IPv6 and IPv4 (with fallback
     to 127.0.0.1 and ::1). This removes the hard dependency on IPv4
     reachability when the listener is IPv6-only on macOS.
  2) Added an opt-in testbench knob to enforce IPv4 where appropriate:
     generate_conf() now honors RSTB_FORCE_IPV4=1 (or
     RSTB_NET_IPPROTO=ipv4-only) to inject
     global(net.ipprotocol="ipv4-only"). We enable this only in the IPv4
     test variant so the IPv6 wrapper remains pure IPv6.

- Impact
  The injector/listener address-family mismatch is eliminated, resolving
  the macOS connect() failures and unblocking the TLS “certvalid” and
  anonymous tests on macOS runners.

Refs: https://github.com/rsyslog/rsyslog/issues/5635
Refs: https://github.com/Homebrew/homebrew-core/pull/221869
Refs: https://github.com/Homebrew/homebrew-core/pull/226378
2025-09-30 13:03:33 +02:00

71 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# testing sending and receiving via TLS with anon auth using bare ipv4, no SNI
# rgerhards, 2011-04-04
# This file is part of the rsyslog project, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
# Force IPv4 only when not explicitly running the IPv6 variant
if [ "${TARGET:=127.0.0.1}" != "[::1]" ]; then
export RSTB_FORCE_IPV4=1
fi
if [ "${TARGET:=127.0.0.1}" == "[::1]" ]; then
. $srcdir/diag.sh check-ipv6-available
fi
export NUMMESSAGES=10000
export QUEUE_EMPTY_CHECK_FUNC=wait_file_lines
# uncomment for debugging support:
#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
export RSYSLOG_DEBUGLOG="log"
generate_conf
add_conf '
global(
defaultNetstreamDriverCAFile="'$srcdir/testsuites/x.509/ca.pem'"
defaultNetstreamDriverCertFile="'$srcdir/testsuites/x.509/client-cert.pem'"
defaultNetstreamDriverKeyFile="'$srcdir/testsuites/x.509/client-key.pem'"
defaultNetstreamDriver="ossl"
# debug.whitelist="on"
# debug.files=["net_ossl.c", "nsd_ossl.c", "tcpsrv.c", "nsdsel_ossl.c", "nsdpoll_ptcp.c", "dnscache.c"]
)
module( load="../plugins/imtcp/.libs/imtcp"
StreamDriver.Name="ossl"
StreamDriver.Mode="1"
StreamDriver.AuthMode="anon" )
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
template(name="outfmt" type="string" string="%msg:F,58:2%\n")
:msg, contains, "msgnum:" action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
'
startup
export PORT_RCVR=$TCPFLOOD_PORT
export RSYSLOG_DEBUGLOG="log2"
#valgrind="valgrind"
generate_conf 2
add_conf '
global(
defaultNetstreamDriverCAFile="'$srcdir/tls-certs/ca.pem'"
defaultNetstreamDriverCertFile="'$srcdir/tls-certs/cert.pem'"
defaultNetstreamDriverKeyFile="'$srcdir/tls-certs/key.pem'"
defaultNetstreamDriver="ossl"
)
# set up the action
$ActionSendStreamDriverMode 1 # require TLS for the connection
$ActionSendStreamDriverAuthMode anon
*.* @@'${TARGET}':'$PORT_RCVR'
' 2
startup 2
# now inject the messages into instance 2. It will connect to instance 1,
# and that instance will record the data.
injectmsg2
# shut down sender when everything is sent, receiver continues to run concurrently
shutdown_when_empty 2
wait_shutdown 2
# now it is time to stop the receiver as well
shutdown_when_empty
wait_shutdown
seq_check
exit_test