A client sends data over CSTP while DTLS is up when DTLS stopped
working for it; the requirement now says that switching to CSTP is
there to keep serving such a client.
Relates: #769
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
tls_mainloop() took the return value of parse_cstp_data() for the packet
type. The parser returns 0 for every frame it accepts, and AC_PKT_DATA
is 0, so a keepalive or a DPD frame over TLS was treated as data: with
no UDP packet for 15 seconds the worker marked the DTLS channel inactive
and sent over TLS, whatever switch-to-tcp-timeout was set to, including
0.
parse_cstp_data() already marks the channel inactive as soon as an
uncompressed data frame arrives over TLS, so the timed check in
tls_mainloop() never acted on such frames; it delayed the switch for
compressed data and misfired on control frames. Remove it, together with
UDP_SWITCH_TIME, and let parse_cstp_data() treat compressed data like
uncompressed data.
Relates: #769
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
Document REQ-WORKER-NET-012 requested during review of !623.
Receiving framed CSTP data selects CSTP for outbound VPN traffic;
control records alone do not. Keep the independent UDP-idle policy
and DTLS reactivation explicit, with positive and negative acceptance
cases and the existing automated-test gap.
Relates: #769
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
When the client's UDP port changed, e.g. on a NAT rebinding, the worker
accepted the socket main forwarded for its DTLS session and closed the
old one, but left the watcher on the closed socket, so it read none of
the session's further records. dtls_set_socket() now moves the watcher
to the new socket (REQ-WORKER-NET-007, test-dtls-port-change).
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
A DTLS rehandshake looped on gnutls_handshake() over the non-blocking
socket for up to the 60 second handshake timeout, forwarding no
traffic, and a failure terminated the worker. It now runs in the
UP_HANDSHAKE state like the handshake of a new DTLS session, one step
per event, with traffic over CSTP meanwhile; periodic_check() also runs
a step, so that a handshake with a silent client times out
(REQ-WORKER-NET-010, REQ-WORKER-NET-011, test-dtls-rehandshake).
Resolves: #774
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
A fatal DTLS error while sending data, a DPD request or a DPD
response or while receiving, a too-early DTLS rehandshake, or a failed
DTLS setup terminated the worker and with it the CSTP connection, or,
for the DPD response, was ignored. dtls_fail() now ends only that DTLS
session, as a failed DTLS handshake already did; its traffic goes over
CSTP and the client can set up a new DTLS session (REQ-WORKER-NET-009,
test-dtls-error-fallback).
Relates: #774
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
On 32-bit systems glibc seeks with _llseek, which the worker's filter
did not allow, and glibc 2.36's dprintf() writes nothing when that seek
fails. On Debian 12 i386, isolated workers thus lost the stderr copy of
every log line. _llseek permits nothing that the allowed lseek does not
(REQ-WORKER-INIT-005).
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
contrib/run-test-suite-vng.sh runs meson setup, ninja and meson test as
root in a virtme-ng guest, either sharing the host root (--host-root)
or booting a separate Fedora rootfs in ~/tmp/vng-roots/<name>/ that it
builds with dnf, so the suite can also run without access to the rest
of the host. Its requirements are in
doc/requirements/contrib/run-test-suite.md (REQ-VNG-*), checked by
contrib/test-run-test-suite-vng.sh; README.md and AGENTS.md describe
how to run it.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The subject line fits in 72 characters and the body is wrapped at 72
columns, as git log and email-based review expect.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
A route = default in a user's or group's file, or from RADIUS, stayed in
the session's routes and was passed to ocserv-fw, which failed to
resolve it, refusing the login with restrict-user-to-routes. Main now
empties the routes once combined, so that such a session is a full
tunnel exactly like one requested by the vhost (REQ-CONFIG-CFG-013,
REQ-MAIN-NET-007), and the worker no longer needs its own check.
Resolves: #791
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Only a default route set in a user's or group's file forced it; a full
tunnel of the vhost sent the tunnel-all-dns value, by default false,
although sample.config documents true as the default with a default
route. tunnel-all-dns now applies to split tunnels only
(REQ-WORKER-NET-008).
Relates: #791
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Since 1.6.0 ip_route_sanity_check() rewrites 0.0.0.0/0 as
0.0.0.0/0.0.0.0 before the default route check, so the route was sent as
an IPv4 split route. The check now recognizes the rewritten form
(REQ-CONFIG-CFG-013), and tests/test-route-default checks the CONNECT
reply for it in the vhost and in a user's file.
Relates: #791
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
check_cfg() and the worker each compared routes against 'default' and
'0.0.0.0/0'. They now call ip_route_is_default() and
ip_routes_have_default(), which main will also need. No behavior change.
Relates: #791
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
It logs in, opens the tunnel and reports the headers the server sent, so
that tests can check the session configuration without openconnect and a
TUN device on the client side. A refused CONNECT is a refusal (exit 1)
for this command; for the existing tunnel commands it remains an error.
Relates: #791
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Its only caller is the socket activation code, so builds without libsystemd failed with clang -Werror on an unused function. The non-Linux stub is dropped as libsystemd is Linux-only.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The variable was copied from main when the worker became a separate executable but was never read there; the broken DTLS client check runs in main. clang 23 flags it with -Wunused-but-set-global.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
libGeoIP databases are no longer published, so occtl now looks up
locations with libmaxminddb only; the meson option 'geoip' is accepted
and ignored. As in ipcalc, the location includes the city, falls back to
the represented or registered country, and is read from the database
paths set by the new options maxminddb_location_country and
maxminddb_location_city; by default these are detected at build time,
preferring the DB-IP Lite databases over the GeoLite2 ones.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
test-listen-families starts the server in a network namespace of its own,
beside a dummy interface that carries one address family, and reads the
TCP and UDP listeners with ss. Without listen-host both wildcard addresses
must listen, whichever family the interface has; with an IPv4 address as
listen-host beside an IPv6-only interface that address alone; a
listen-host that is not a local address must still stop the server.
On the server without the previous commit the first case fails: it listens
on "[::]" only.
Relates: #594
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
The listen addresses are resolved once, when the server starts. With
AI_ADDRCONFIG getaddrinfo() returns only the address families that have an
address outside loopback at that moment. A server started without
listen-host on a host whose interfaces carry only IPv6 addresses listened
on "[::]" alone, and with an IPv4 address as listen-host it did not start:
"getaddrinfo() failed: Address family for hostname not supported".
Without the flag a host that has only IPv4 addresses at start also listens
on "[::]", and the reverse. An address the host cannot use fails in
socket() or bind() and is skipped, as before.
Adds REQ-MAIN-INIT-009.
Resolves: #594
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
generate_oidc_test_data kept the key created in main() and the two strings
returned by cjose_jwk_to_json() until exit. Built with AddressSanitizer it
fails on the leak report, 1849 bytes in 42 allocations, and the
gen_oidc_test_data test fails with it.
Resolves: #781
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
Both posted HTML form fields and differed only in path, User-Agent and
fields, so the form command now sends them, with the Cisco SVC client
chosen by --client svc; it prints the status and cookies and leaves
judging the answer to the test, and test-pam-abort now checks for the
401 rejection directly.
Relates: REQ-GEN-TEST-014
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The cstp-echo and cstp-malformed commands of oc-client.py replace the
separate cstp-burst-client.py in test-cstp-burst, and oc_client runs the
tool at localhost without socket_wrapper in tests that do not use it.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
test-http-limits and test-cookie-sid-overflow send their oversized bodies,
headers and cookies with the new oversized command. test-http-limits no
longer counts a request that did not reach the server, or got no answer
within 10 seconds, as a rejection.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
test-pass-svc and test-cert-svc send their /svc requests with the new svc
command, which presents the Cisco SVC client's User-Agent and prints the
cookies set, with each former curl check kept as an oc_expect line.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
test-pam-abort posts its username-only request with the new username-only
command and now requires it to be rejected, so that a request that never
reached the server can no longer pass the test, and test-gssapi-opt-pass
replaces its inline Python client with the negotiate-fallback command.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
test-group-name and test-group-cert-autoselect use the new init command
of oc-client.py, with each former curl check kept as an oc_expect line;
they no longer send the STRAP pubkey header and device details, which
ocserv does not parse. The shared oc_run and oc_fail helpers replace the
per-test copies in test-vhost-select-group.
Relates: REQ-GEN-TEST-014
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
oc_client and require_oc_client in common.sh run tests/oc-client.py
against the test server and skip a test without python3, and the tool
can present a client certificate, a User-Agent and HTML forms, which the
tests listed as technical debt in REQ-GEN-TEST-014 need.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The OpenID Connect logins of test-oidc and test-oidc-code-flow are out of
the scope of REQ-GEN-TEST-014, and the GSSAPI tests keep using curl
--negotiate for a real SPNEGO exchange, which the Python standard library
cannot do, as the one exception for curl; the tests the requirement listed
as technical debt are converted by the following commits, so the list is
removed.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
INSTALL still described the autotools build. README.md now covers
installing with meson, setting up the configuration and running ocserv
as a systemd service.
Resolves: #784
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The test gives the worker 20 seconds to drop a frozen client. That
covers the 10-second cstp_send() timeout only if the TCP send buffer
fills within a few seconds. With net.ipv4.tcp_congestion_control = bbr,
which the test namespaces inherit from the host, the send buffer grows
to about 1.85 MB and takes about 15 seconds to fill, so the test fails
although the worker behaves correctly.
Set output-buffer = 1 in the test configuration. The worker then sets
SO_SNDBUF, the buffer stays at a few kilobytes, and with bbr the
session is dropped about 11 seconds after the flood starts.
Relates: #638
Signed-off-by: Pavel Lavrukhin <14156456-dantte_lp@users.noreply.gitlab.com>
With expose-iroutes, a session with no routes, which is a full tunnel, was
given the other users' iroutes as its only routes; the client then tunneled
only them, and restrict-user-to-routes blocked its other traffic. A vhost
has no routes with route = default, route = 0.0.0.0/0 or no route at all,
so this hit every user without routes of its own on such a vhost.
append_routes() now leaves such a session without routes; the iroutes add
nothing to a full tunnel (REQ-CONFIG-CFG-012).
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
The checker did not require options read by cfg_ini_handler() to be in
sample.config, which let append-routes go undocumented, nor compared the
per-user and per-group option list with sup-config/file.c. Check (i) and
check (j) now do (REQ-CONFIG-CFG-001); the list gains hostname,
ipv6-subnet-prefix, client-bypass-protocol and user-profile, and
explicit-ipv4 and explicit-ipv6 are described.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
With append-routes, a session without routes of its own received each
route of its vhost twice: apply_default_config() gave it the vhost's
routes as its own, and append_routes() then appended them. The vhost's
routes are now added by append_routes() alone, before the exposed
iroutes, as REQ-CONFIG-CFG-012 now specifies; test-append-routes checks
the exact route and no-route lists a session receives, and append-routes
is documented.
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
With the new listen-mptcp option, the TCP listening sockets are created
with IPPROTO_MPTCP, so that clients supporting Multipath TCP can spread
the TLS connection over several paths and keep it when one path fails.
Clients without MPTCP support still connect: the kernel falls back to
TCP for them.
If the kernel refuses MPTCP sockets (built without MPTCP, the
net.mptcp.enabled sysctl set to 0, or Linux older than 5.6), ocserv
logs a warning and listens with TCP. Socket-activated listeners are
created by systemd, so the option cannot change them; ocserv warns when
listen-mptcp is set and the socket it was passed is not an MPTCP one,
and the sample socket unit documents SocketProtocol=mptcp. UDP (DTLS)
listeners are unchanged.
tests/test-listen-mptcp makes openconnect connect with MPTCP through an
LD_PRELOAD shim, as mptcpize does, and checks that occtl lists the
session as connected, that its worker holds an MPTCP socket and that the
tunnel carries traffic. The kernels of GitLab's hosted runners have no
MPTCP, so the new mptcp/Fedora CI job runs the MPTCP tests in a
virtme-ng guest with the Fedora image's kernel (build-images provides
the kernel, QEMU and virtme-ng), where OCSERV_TEST_REQUIRE_MPTCP=1 makes
them fail instead of skipping.
Adds REQ-MAIN-INIT-007 and REQ-MAIN-INIT-008.
Resolves: #762
Signed-off-by: Pierre-Yves Le Borgne <pylaterreur@gmail.com>
A vhost that sets auth now uses only its own enable-auth and acct, and one
that does not uses all three from the top-level configuration. A vhost that
does not set auth but sets enable-auth or acct is now a configuration error
instead of having them silently ignored, so a vhost never inherits a value
in place of one its section gives (REQ-CONFIG-CFG-011). The three are read
at startup only, so a reload neither changes nor re-checks the group.
kkdcp is not part of the group: its endpoint is served before
authentication whatever the vhost's methods. It is now inherited like any
other reloadable option, whether or not the vhost sets auth, where
previously no named vhost inherited it (REQ-CONFIG-CFG-010).
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>