Commit Graph
375 Commits
Author SHA1 Message Date
Nikos Mavrogiannopoulos bb9bcd7461 main: remove cgroup support in favour of systemd resource controls
Native cgroup placement is removed. Delegating resource enforcement
to systemd eliminates the privileged /sys/fs/cgroup writes from
the main process and simplifies the code.

Administrators who previously relied on the 'cgroup' option should use
the [Service] section of the ocserv unit file instead; see
systemd.resource-control(5) for details.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-23 07:09:23 +02:00
Grigory Trenin 61f013ae3a pam: add 'service' sub-option to auth directive
This allows users to specify a custom PAM service name, enabling
per-virtual-host PAM stacks.For example:
auth = "pam[service=vpn1,gid-min=1000]"

Resolves: #718

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-05-08 21:00:07 -04:00
Nikos Mavrogiannopoulos 22bbad4eb5 worker: add per-worker memory limit via RLIMIT_DATA
Introduce a per-worker heap cap as defense-in-depth against
memory-exhaustion DoS attacks. The limit uses RLIMIT_DATA rather
than RLIMIT_AS: since Linux 4.7 RLIMIT_DATA covers brk and private
anonymous mmap regions, i.e, the paths used by malloc and talloc, while
ignoring shared-library file mappings that inflate RLIMIT_AS without
reflecting actual allocation.

This aligns with haproxy's handling. See also:
https://github.com/torvalds/linux/commit/84638335900f1995495838fe1bd4870c43ec1f67
https://sources.debian.org/src/haproxy/3.2.17-1/src/limits.c?hl=486#L486
https://www.kernel.org/doc/html/latest/mm/overcommit-accounting.html

The cap is computed at worker startup by reading the data+stack field
from /proc/self/statm.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-06 13:54:40 +02:00
Nikos Mavrogiannopoulos 8913ffadff doc: updated for nft/iptables dependencies
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-05-02 18:49:43 +02:00
Nikos Mavrogiannopoulos 139ff827d9 config: restructure per-vhost configuration for clarity and maintainability
Introduce a protobuf-generated ReloadableConfig (cfg.proto) to hold all
fields that reload on SIGHUP, and separate them from static_cfg_st, which
holds fields that require a server restart.  Named vhosts inherit from the
default vhost via a pack/unpack round-trip. Adding a new config field
only requires editing cfg.proto.  Struct and accessor names (ReloadableConfig,
static_cfg_st, GETRCONFIG, GETSCONFIG) now reflect each field's lifetime.
A new unit test covers the full inheritance path.

Resolves: #705

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-22 20:29:15 +02:00
Nikos Mavrogiannopoulos caacc92c28 Merge branch 'doc-user-config' into 'master'
doc: clarify reload behavior for per-user/group configs

See merge request openconnect/ocserv!526
2026-04-21 18:58:01 +00:00
Nikos Mavrogiannopoulos 745d7883be design.md: include auth state in the diagram
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-21 19:19:32 +02:00
Grigory Trenin 50c59cd53b doc: clarify reload behavior for per-user/group configs
Document that there is no need to reload ocserv after modifying per-user
or per-group configuration.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-19 09:08:07 -04:00
Grigory Trenin db125634b8 Allow using no-udp option in vhosts
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-14 13:26:32 -04:00
Nikos Mavrogiannopoulos 4a0a087996 config: align default values with sample.config
Several options had hardcoded or named defaults in apply_default_conf()
that diverged from the values documented in doc/sample.config, leading
to silent behaviour differences for servers running without explicit
configuration.

Relates: #680

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-14 18:57:45 +02:00
Nikos Mavrogiannopoulos 611eb00527 config: add scope annotations and validation script
Add machine-readable [scope: X] annotations to doc/sample.config and
src/vpn.h struct fields to document which config options are permanent,
global-only, per-vhost, or per-user/group overridable.

Scope vocabulary:
  global (non-reloadable)  -- in perm_cfg_st; requires restart; cannot differ per vhost
  vhost (non-reloadable)   -- in perm_cfg_st; requires restart; can differ per vhost
  global            -- in cfg_st; reloadable; cannot be set in [vhost:] sections
  vhost             -- in cfg_st; reloadable; can differ per vhost
  vhost user        -- in cfg_st; reloadable; also overridable per user/group

Add tests/check-config-scope.py: a script that cross-checks the annotations
against the actual code:
  (a) every option in sample.config has a [scope:] annotation
  (b-c) [global] options match error_on_vhost() calls in config.c
  (d-e) [vhost user] options match handlers in src/sup-config/file.c
  (f) every field in cfg_st and perm_cfg_st has a [scope:] comment

Also fix a pre-existing bug in src/sup-config/file.c: the tunnel-all-dns
option was compared using an underscore ("tunnel_all_dns") instead of
the correct dash ("tunnel-all-dns"), silently ignoring the per-user
setting.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-14 18:57:45 +02:00
Nikos Mavrogiannopoulos db50c02cbd Merge branch 'tmp-radius-group-separator' into 'master'
radius: add group-separator option for OU= Class attributes

Closes #428

See merge request openconnect/ocserv!513
2026-04-10 04:29:39 +00:00
Grigory Trenin bf12b9fe9c Fix global option inheritance for virtual hosts
Ensure global options are properly copied to virtual hosts when not
explicitly specified.

This change also:
- Documents global options that cannot be overridden in virtual hosts.
- Adds a 'VIRTUAL HOSTS' section to the man page to clarify behavior.

Closes #698

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-09 20:20:45 -04:00
Nikos Mavrogiannopoulos 828fca691e radius: add group-separator option for OU= Class attributes
Freeradius deployments may send groups in the Class attribute using a
comma as separator (e.g. "OU=group1,group2") rather than the semicolon
that ocserv expects by default. Add a group-separator option to the
radius auth configuration to allow this to be changed:

  auth = "radius[config=...,group-separator=comma]"

Accepted values are 'semicolon' (default) and 'comma'. The literal
character is not accepted in the config syntax as it conflicts with the
key=value pair delimiter.

Resolves: #428

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-04-06 21:27:28 +02:00
Nikos Mavrogiannopoulos 598bcf405e Added ocserv-fw for nftables
This also introduces a basic functional test for ocserv-fw.

Resolves: #397

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-29 16:55:12 +02:00
Nikos Mavrogiannopoulos c223f51c91 occtl.8.md: document available commands
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-22 12:30:04 +01:00
Nikos Mavrogiannopoulos 18401eb298 Replaced autoconf with meson build files
Resolves: #699

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-20 20:47:27 +01:00
Ivan Verbin a8730a6997 occtl: add terminate commands for session cookie invalidation
Add 'terminate user', 'terminate id' and 'terminate session' commands
to occtl that disconnect users and invalidate their session cookies,
preventing reconnection with cached credentials.

Short session IDs are resolved to full safe_id by fetching the cookie
list from sec-mod via CTL_CMD_LIST_COOKIES with prefix matching and
ambiguity detection. Active sessions trigger a warning before
invalidation.

Add integration tests for all three terminate commands.

Signed-off-by: Ivan Verbin <verbinivan@gmail.com>
2026-03-15 17:05:29 +03:00
Nikos Mavrogiannopoulos 071f1e18ee design.md: moved all diagrams to mermaid
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-01 20:11:07 +01:00
Nikos Mavrogiannopoulos 4ba99fc18b VPN overview: expanded diagram
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-01 20:11:04 +01:00
Nikos Mavrogiannopoulos 87cd179117 Removed design.dia in favor of design.md
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2026-03-01 20:10:59 +01:00
Dimitri Papadopoulos 2b178b22ba Small doc improvements
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-02-01 18:41:51 +01:00
Grigory Trenin b080d7dd2b Rename min-reauth-time to ban-time (#676)
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-23 05:44:05 -05:00
Grigory Trenin 08c321c41a docs: tidy up man pages
- Updated the SYNOPSIS of ocserv(8), occtl(8), and ocpasswd(8)
  to match their --help output
- Corrected usage syntax (eg: '-c config' is optional for ocserv,
  'username' is required for ocpasswd).
- Removed non-standard ':' trailing from options definitions
- Documented missing command-line options: --log-stderr,  --syslog,
  --no-chdir, --traceable
- Added default configuration file paths:
  /etc/ocserv/ocserv.conf, /etc/ocserv/ocpasswd
- Documented USER_AGENT environment variable
- Fixed typos

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-10 18:05:02 -05:00
Dimitri Papadopoulos 4a4c341b45 Option listen-host expects a single IP address
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2025-03-02 19:07:22 +01:00
Nikos Mavrogiannopoulos 344c717319 README-oidc.md: mention that only the microsoft client supports OIDC [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-06-03 21:11:07 +02:00
Nikos Mavrogiannopoulos dd13e5db65 design.md: added basic mermaid diagram
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-05-09 17:33:08 +02:00
Nikos Mavrogiannopoulos 48d7057fb3 config: auto-select-group made global not per vhost
The group functionality is available globally only and
there is no benefit from this option being per vhost.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-04-23 21:35:44 +02:00
Marcin OchabandNikos Mavrogiannopoulos 3f966ae8ca Allow selecting group by URL or profile
This introduces the 'select-group-by-url' config option
that allows selecting an authgroup just by connecting to
a dedicated URI.

Signed-off-by: Marcin Ochab <marcin.ochab@gmail.com>
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-04-23 21:35:00 +02:00
Nikos Mavrogiannopoulos 72b8e19cac updated copyright notices and minor text update
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-04-01 12:19:46 +02:00
Dimitri PapadopoulosandNikos Mavrogiannopoulos ab58d9e9d7 Retrieve connection speed from RADIUS
Hijack Roaring Penguin's RADIUS attributes for that purpose:
* RP-Upstream-Speed-Limit → rx_per_sec
* RP-Downstream-Speed-Limit → tx_per_sec

While the ocserv configuration options use b/s, ocserv uses kb/s
internally. The radius attributes are already expressed in kb/s,
so we don't need to convert them.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2024-01-20 20:12:34 +01:00
Nikos Mavrogiannopoulos 29dba5cee8 web: updated links to web page
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-01-05 16:47:18 +01:00
Dimitri Papadopoulos b41130163d Reorder man pages
Follow the conventions for writing Linux man pages:
https://man7.org/linux/man-pages/man7/man-pages.7.html

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-12-30 22:48:02 +01:00
Nikos Mavrogiannopoulos 7c9e9b76a6 doc: mention issue tracker to manpage
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-30 18:03:51 +01:00
Dimitri Papadopoulos 715b9b2ea1 Use proper symbol for second, prefix for kilo
The SI symbol for second is s:
https://www.bipm.org/en/si-base-units/second

The SI prefix for a multiplying factor of 10³ is k:
https://www.bipm.org/en/measurement-units/si-prefixes

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-12-24 10:40:21 +01:00
Dimitri Papadopoulos 311433b4db Minor typo
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-12-22 15:56:47 +01:00
Nikos Mavrogiannopoulos d504ba832b sample.config: added warning for compression [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-19 22:36:33 +01:00
Nikos Mavrogiannopoulos f0067ae0ea Cleanup of the logging subsystem; allow logging to stderr only
Separated the logging logically from any remaining debugging
features. Introduced command line option for logging to stderr
only (for systemd and containers). The default log level is set
to (2) info.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-15 13:04:40 +01:00
Nikos Mavrogiannopoulos 86cd25dafb sample.config: further clarify RX and TX meaning [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-10 02:11:13 +01:00
Nikos Mavrogiannopoulos d192340484 sample.config: clarified RX and TX meaning [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-07 16:06:14 +01:00
Dimitri Papadopoulos Orfanos a711aa4a22 Merge branch 'libexec' into 'master'
bin/ocserv-fw → libexec/ocserv-fw

Closes #78

See merge request openconnect/ocserv!388
2023-12-06 17:51:37 +00:00
Nikos Mavrogiannopoulos 30cf47ad60 sample.config: set default logging priority to 2
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-12-06 16:47:00 +01:00
Dimitri Papadopoulos 8ada82ff5c bin/ocserv-fw → libexec/ocserv-fw
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-11-28 21:57:02 +01:00
Dimitri Papadopoulos b29d915699 Fix misspelling newly reported by codespell
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-09-11 19:18:37 +02:00
Nikos Mavrogiannopoulos 6aad62e266 debug: increased default log-level to debug
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-08-28 20:48:02 +02:00
Nikos Mavrogiannopoulos 70ceee36d6 sample.config: corrected documentation [ci skip]
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-07-11 14:54:57 +02:00
Nikos Mavrogiannopoulos 9e457abda8 Merge branch 'cisco-ipphone' into 'master'
Add support for Cisco IP-Phone Enterprise firmware VPN

See merge request openconnect/ocserv!356
2023-07-11 12:46:40 +00:00
Gareth Palmer 996d021e1b Add support for Cisco IP-Phone Enterprise firmware VPN client.
The VPN client that comes with the Cisco IP-Phone Enterprise
firmware is based on AnyConnect but was unable to authenticate
with ocserv.

The phone makes an initial GET request and looks for a cookie
named 'webvpn' that has an expiry attribute and a cookie named
'webvpnlogin' containing a non-empty value.

When username+password mode is configured, the phone will then
send a POST request containing those credentials. When using
certificate authentication an empty POST request is sent.

A handler that implements this new behaviour has been added
under the '/svc' path.

To use DTLS 'dtls-legacy' must be enabled and 'udp-port' must
be 443, a new 'cisco-svc-client-compat' option automatically
checks those settings.

New test cases test-pass-svc and test-cert-svc check the above
behaviour.

Older versions of the phone's firmware will fail to create the
DTLS tunnel if the cipher negotiated for HTTPS does not match
that selected for DTLS.

To work-around this either disable DTLS or only allow the
RSA-AES-256-CBC/SHA1 or RSA-AES-128-CBC/SHA1 cipher to be used.

doc/README-cisco-svc.md includes additional information.

Note: 'Enterprise' here is used to differentiate between that
firmware and the MPP (Multi-Platform) firmware which uses the
same hardware.

Signed-off-by: Gareth Palmer <gareth.palmer3@gmail.com>
2023-07-11 22:48:22 +12:00
Nikos Mavrogiannopoulos 52f64c4032 sample.config: added more information on how logging works
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-07-05 18:37:46 +02:00
Nikos MavrogiannopoulosandDimitri Papadopoulos 1373a11f57 tests: added a test for groups defined over multiple AVPs
This adds a test for the available multi-group options as
well as documentation for the feature. This tests two options:
 * Separate group names in separate class attributes
 * Separate group names in separate class attributes with the OU= format

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2023-06-17 00:25:55 +02:00