Commit Graph
36 Commits
Author SHA1 Message Date
Grigory Trenin 2ff4154159 Distinguish reason codes in AnyConnect BYE packets
Cisco AnyConnect clients may send a BYE packet with a 0x91 payload,
followed by ASCII text "Reconnecting the VPN tunnel."

Resolves: #732

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-05-23 08:36:18 -04: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
Grigory Trenin 86972b7200 Fix compiler warning when PAM/RADIUS are disabled
This fixes a -Wtype-limits warning encountered in builds without
PAM and RADIUS (e.g., OpenWRT). When the avail_acct_types array is
empty, ARRAY_SIZE evaluates to 0, making the unsigned comparison
always false.

Reported in #709.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-27 12:00:09 -04:00
Grigory Trenin a79e2f1cd5 Respect tunnel-all-dns in per-user/group config
Ensure that 'tunnel-all-dns' setting is honoured when overridden
in user or group-specific configuration files.

Resolves: #708

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-26 21:05:06 -04:00
Grigory Trenin eddd29f59b Do not forward UDP until client is authenticated
Do not forward DTLS packets until the client is authenticated to
prevent the race between AUTH_COOKIE_REP and CMD_UDP_FD messages
on the command socket.

Closes #706

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-21 07:06:59 -04: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 3af9edaa8e build: remove obsolete build-aux directory
This directory contained scripts (install-sh, compile, etc.) used
by Autotools. Since the project has migrated to Meson, these files
are no longer needed.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-14 16:40:59 -04:00
Grigory Trenin cde58c22be protobuf: use 64-bit signed integers for timestamp fields
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-04-14 13:59:05 -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
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
Grigory Trenin cab071aa78 tests: Fix intermittent namespace conflicts in CI
Fix PID-based namespace name collisions by:
- Extracting last 9 digits of PID (instead of first 4)
- Shortening interface names to fit 15-character IFNAMSIZ limit

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-03-11 18:58:24 -04:00
Grigory Trenin 016c1b7f51 Use separate port for second iperf3 daemon
Avoids race condition when the first daemon's port release is delayed

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-28 18:19:03 -05:00
Grigory Trenin fb41d4203d Fix session timeout bypass
- Fixes an issue #599 where the session timeout could be bypassed
  by reconnecting, such as through a laptop lid close/open cycle.
- Adds 'Session started at:' field to 'occtl show user' output.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-25 18:59:13 -05:00
Grigory Trenin a644718fd7 Fix worker process title not being set
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-25 07:33:21 -05:00
Grigory Trenin 9cc0191236 occtl: Fix 'show ip bans' may produce invalid JSON (#683)
Modified the printing logic to use a 'comma-before' approach instead of
'comma-after'.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-23 12:54:43 -05: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 0ed29607b6 .gitignore: add generated and cleanup legacy files (gnulib, libopts)
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-19 08:43:45 -05:00
Grigory TreninandNikos Mavrogiannopoulos 74ebc5ec8a Strip domain suffix from hostname
The hostname validation was rejecting any hostname containg a '.'
character (eg: 'MacBook-Air.local'). This was overly restrictive and
prevented the HOSTNAME environment variable from being populated for
a signifficant number of clients, particularly on macOS.

Strip the domain suffix from such hostnames instead of discarding them.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-11 09:15:14 +01: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
Grigory Trenin 8636464880 tests: replace strcpy() with strlcpy()
- Replaced strcpy() with strlcpy() in test files
- Added linking to libcommon.a (and its dependency libnettle)
  as not all systems provide strlcpy()
- Centralized syslog_open variable by moving it from multiple definitions
  in main.c, worker.c, and test files into log.c. This avoids duplication
  and resolves a linking conflict with libcommon.a

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-07 15:46:16 -05:00
Grigory Trenin e40d735316 occtl: Fix column misalignment in ban command outputs
- Increase the width from 14 to 15 characters for 'show bans' and
'show ban points' commands. This ensures proper column alignment
for all valid IPv4 addresses.

- Reduce Score column to 10 characters since UINT_MAX is typically
10 digits.

- Remove unnecessary (unsinged int) cast since 'score' is an actual
unsigned int.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-04 13:32:51 -05:00
Grigory Trenin 98015b1b24 Fix max_mtu calculation in server stats
proc->mtu was incorrectly compared against min_mtu instead of max_mtu

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-02 16:34:59 -05:00
Grigory TreninandNikos Mavrogiannopoulos 1893047e8f Fix irregular stats-report-time
Currently 'ocserv' sends session accounting statistics at irregular intervals.
For example, if 'stats-report-time' is set to 60, the actual intervals may vary
between 50, 60, 70, or even 80 seconds.  Moreover, these intervals are not
constant - they fluctuate arbitrarily with each statistics update.

This behavior was intentionally introduced to avoid worker processes acting
simultaneously in scenarios like server restarts, where all clients reconnect
at the same time, which could impose heavy load on the secmod process.

However, it causes issues for RADIUS servers that require accurate and
consistent timing.

Summary of changes:
 - Apply randomization only once when the timer is initially set up, affecting
   only the first timer firing.  All subsequent firings will occur at regular
   intervals relative to the first one.
 - Remove fuzzing from 'interim_update_secs'. This value originates either from
   RADIUS or from 'stats-report-time' and should not be altered.

Closes: #630

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-01 17:31:01 +01:00
Grigory TreninandNikos Mavrogiannopoulos dbbe6de40c Fix premature ban score reset for short ban periods
When ban period is minimal, the 'now > e->expires' condition alone
cleared scores before a client was banned.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2026-01-01 17:15:37 +01:00
Grigory TreninandNikos Mavrogiannopoulos 0f53e0d6d9 Communicate secmod address to worker after successful authentication
This ensures all subsequent worker communications reach the original
secmod instance that authenticated the client, enabling correct session
accounting after IP address changes.

Closes: #674

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 11:41:51 +01:00
Grigory TreninandNikos Mavrogiannopoulos afa34bbd10 Fix ban score reset logic
The previous condition for resetting a ban score was insufficient.
It failed to reset the score for a client that had just exited a ban,
and also incorrectly reset the score of a currently banned client,
causing premature unbans.

Closes: #678

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 11:24:19 +01:00
Grigory TreninandNikos Mavrogiannopoulos d15b2af4b2 Fix 'occtl show ip bans' showing expired ban entries
Added current timestamp comparison to ensure only active bans
are shown by 'occtl show ip bans'.

Closes: #675.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 10:54:16 +01:00
Grigory TreninandNikos Mavrogiannopoulos 1c31314df4 occtl: Fix missing column headers in 'show ip bans' output
Existing code used the loop index 'i == 0' to determine when to print
column headers. However, a 'continue' statement inside the loop could
skip the 'i = 0' iteration, causing the headers to never be printed.

Introduced a separate boolean 'header_printed' variable to track
whether headers have been printed.

Closes: #677

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 10:52:20 +01:00
Grigory TreninandNikos Mavrogiannopoulos 3892e032d9 Fix DTLS with systemd socket activation
Remove IPV6_V6ONLY flag from per-client UDP sockets as it prevents
IPv4 traffic on systemd-provided IPv6 sockets. This was a legacy
from the old reopen_udp_port() code and is no longer needed.

Fixes: #647

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-12-21 10:48:59 +01:00
Grigory Trenin 4dcf3aa524 Fix iroute option processing
Return proper values (1 for success, 0 for error) from iroutes_handler()
to prevent premature parser termination

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-30 19:53:14 -05:00
Grigory Trenin a307bda153 Repair ping-leases option
A misplaced bracket passed 'sizeof(*addr1) == -1' instead of 'sizeof(*addr1)'
to sendto(), causing it to fail. This prevented icmp_ping4() from sending
ICMP echo requests.

Consequently, the 'ping-leases' option has been non-functional since
this bug was introduced in commit 2aaa287a.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-21 15:59:01 -05:00
Grigory Trenin 0017038bcd Ignore ENOENT error when removing occtl socket file
Silence misleading debug message on server startup since absence
of the socket file is normal and expected.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-16 14:40:04 -05:00
Grigory Trenin 22a762da43 Replace non-ASCII character in error message
Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-12 07:40:21 -05:00
Grigory Trenin 093051ea5f Fix printf argument order
Correct the argument order passed to the printf-like function
to match the format string "expected %d, received %d".

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-06 16:54:42 -05:00
Grigory Trenin 49a807a25f build: add gperf check
Check for gperf in ./configure to provide a clear, user-friendly
error message if it's not found and required generated files are
missing, instead of failing at compile time.

Also fix an invalid package name ('install') in README.md for
Fedora/RHEL build.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-06 15:57:19 -05:00
Grigory Trenin 1d76699731 Revert "combined CSCOT URLs"
This reverts commit 6fea92a961.

The URL consolidation caused worker to no longer recognize either of the original URLs.
This led to "unexpected URL" errors and immediate worker termination.

The original change was intended to simplify URL configuration,
but it inadvertently broke functionality for both endpoints.

Signed-off-by: Grigory Trenin <grigory.trenin@gmail.com>
2025-11-05 09:12:27 -05:00