Commit Graph
78 Commits
Author SHA1 Message Date
Dimitri Papadopoulos 4b216473d5 Fix calculation of avg_auth_time across sec-mod instances
Resolves: #736

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2026-05-24 11:47:26 +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
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
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 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
Dimitri Papadopoulos Orfanos 31b3d6b930 Merge branch 'tmp-cloexec' into 'master'
Update cloexec.* vendored files

See merge request openconnect/ocserv!439
2025-12-06 11:10:11 +01: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
Dimitri Papadopoulos e8139682fb Move cloexec.* files out of common
These files are only used by the main program.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2025-04-02 09:05:42 +02:00
Nikos Mavrogiannopoulos 78c65b5adf Updated code to follow with kernel coding style
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2024-12-01 17:01:05 +01:00
Dimitri Papadopoulos 6746d1d6f4 Check return value of remove()
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2024-06-25 22:13:21 +02: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
Dimitri Papadopoulos 5e881697e7 void function return statements are not generally useful
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-06-04 14:33:58 +02:00
Dimitri Papadopoulos 89c18daaf0 Suggestion from checkpatch.pl
please, no space before tabs

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
2023-01-20 10:15:51 +01:00
Dimitri Papadopoulos f28669bf60 Remove spaces
* Remove trailing spaces at end-of-line
* Remove blank lines at end-of-file

Signed-off-by: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com>
2022-11-28 11:22:33 +01:00
Nikos Mavrogiannopoulos 2d1bd947e2 ctl_handler_init: fixed resource leaks
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2021-04-01 17:09:25 +02:00
Nikos Mavrogiannopoulos 3d7c846ecd ocserv: renamed main_loop
This avoids warnings and static analyzers complains about
libev functions hiding the global 'loop' variable.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-12-09 15:56:29 +01:00
Yousong Zhou 5cb41a570b Fix display of rx/tx per sec limit
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2020-09-15 19:14:37 +08:00
Alan Jowett 945699097d Modify ocserv-sm to permit it to scale up to the number of CPUs. This permits a higher rate of client connections and prevents TLS signing from becoming a bottleneck for clients connecting.
Resolves: #341

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-08-26 09:46:04 -06:00
Nikos Mavrogiannopoulos 8aa39b0106 Improved user disconnection to avoid race conditions
Previously when we were disconnecting a user there were few seconds
after which the cookie was still valid, so a reconnect would succeed
by the same user. This change ensures that a disconnected (via occtl)
user cannot re-use the same cookie to connect. That enables a safe
user removal from the authentication database, and from run-time.

Resolves: #59

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
2020-07-25 21:38:55 +02:00
Alan JowettandAlan Jowett 722e030e58 Add reporting of RX latency
Resolve: #258

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2020-05-26 18:14:36 -06:00
Nikos Mavrogiannopoulos ba6921ed9a Introduced the notion of virtual hosts
This provides virtualized server configurations which take
effect after client connection when client hello is received.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2018-03-06 20:42:31 +01:00
Nikos MavrogiannopoulosandNikos Mavrogiannopoulos ccb80b5d4f occtl: improved presentation of printed statistics
Also added different values to keep authentication failures
and closed sessions, in total and per accounting period.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-04-14 16:39:00 +03:00
Nikos Mavrogiannopoulos 538d1bca21 occtl: print statistics provided by main
Also introduced the --debug option.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2017-04-14 16:39:00 +03:00
Nikos Mavrogiannopoulos e9cf88f8c2 main: store additional statistics globally
That is, store:
 * number of timed out sessions
 * number of timed out due being idle sessions
 * number of errored sessions
 * total number of session handled (closed)
 * total number of kbytes sent
 * total number of kbytes received
 * minimum MTU seen
 * maximum MTU seen
 * total authentication failures
 * average/max authentication time (in secs)
 * average/max session time (in minutes)

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2017-04-14 16:39:00 +03:00
Nikos Mavrogiannopoulos fdea01f4f5 Do not log the internal session ID nor re-use it in radius
Use instead a value derived from it, to avoid access to the debugging
log files, or radius result to access to the server.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2017-01-29 15:48:46 +01:00
Nikos Mavrogiannopoulos 3a834fad26 occtl: print the cookie associated with a user on user info
This allows to map existing cookies to connected users.
2016-05-14 20:37:12 +02:00
Nikos Mavrogiannopoulos da4e4fcf2a Improved error message propagation due to new combined APIs
This amends 8892eb1934
2016-03-07 13:51:55 +01:00
Nikos Mavrogiannopoulos e0947340bb ipc: pass the connection status as integer
Conversion to textual form now happens at the client (occtl)
instead of the main server.
2016-03-06 19:07:24 +01:00
Nikos Mavrogiannopoulos 8892eb1934 use a single format for all messages simplifying server
That patch also combines all the message generation or receiving
functions for to allow easier modifications to the format.
2016-03-06 19:07:07 +01:00
Nikos Mavrogiannopoulos f3338e84f7 Added occtl command to display cookies
This allows to display and examine valid cookies from occtl.
2016-03-06 12:05:36 +01:00
Nikos Mavrogiannopoulos ff5b2b7aad Use 32-bit length variable for transferring between occtl and ocserv
This allows to handle the transfer of long data between ocserv and occtl.
Reported by Liviu.

Resolves #29
2016-01-28 13:53:21 +01:00
Nikos Mavrogiannopoulos 353bd39686 replaced select() calls will poll() calls
This allows to handle descriptors more than the maximum limit
allowed by select(), and thus handle more clients than 1024.
2016-01-28 13:53:08 +01:00
Nikos Mavrogiannopoulos b66b1f6390 main: don't attempt to access client configuration if not already set
This prevents crash introduced by cefd77b633
2016-01-27 14:24:49 +01:00
Nikos Mavrogiannopoulos 01706859e0 occtl: print the restricted ports for the client 2015-12-08 14:14:27 +01:00
Nikos Mavrogiannopoulos e1fc1f3c45 TLS session resumption database was moved to sec-mod
This reduces the number of sensitive data available to main process.
Resolves #21
2015-12-07 19:52:30 +01:00
Nikos MavrogiannopoulosandNikos Mavrogiannopoulos fe28fd15cd Added occtl command 'show events', as well as the corresponding command in main
This allows the main process to handle a single listener which will
get all information about new and disconnecting users.
2015-12-05 11:23:06 +01:00
Nikos MavrogiannopoulosandNikos Mavrogiannopoulos 12bc8955bd main: allow multiple clients in control channel (occtl) 2015-12-05 11:23:01 +01:00
Nikos MavrogiannopoulosandNikos Mavrogiannopoulos 0e604b8a9f Master process was converted to use libev 2015-12-05 11:18:09 +01:00
Nikos MavrogiannopoulosandNikos Mavrogiannopoulos 9252e22298 Added reference counting to configuration values.
That is, to allow referencing to these values from proc_st
without fearing of them being invalidated on a config reload. We
perform a cleanup of these values on the server periodic check.
2015-12-05 11:08:51 +01:00
Nikos Mavrogiannopoulos cefd77b633 Simplified per-user/group configuration handling
We now use a common structure in SESSION_REPLY and AUTH_REP
messages. That structure is generated by sec-mod and forwarded
by main to worker, thus eliminating the need to create passing
code for each new user-config variable being added.
2015-11-26 18:29:14 +01:00
Nikos Mavrogiannopoulos f5fca982dc Added configuration option restrict-user-to-routes
This option, if set, will call /usr/bin/ocserv-fw for each user
connecting, i.e., adding firewall restrictions based on its allowed
routes.
2015-11-23 17:31:55 +01:00
Nikos Mavrogiannopoulos ba44c2a6c1 pass DPD and keepalive values to occtl 2015-11-19 12:23:37 +01:00
Nikos Mavrogiannopoulos aed34ebd62 ip banning: entries hold in raw IP format rather than textual 2015-11-10 13:47:51 +01:00
Nikos Mavrogiannopoulos 845fcbc891 forward all routes sent to client to occtl 2015-09-18 16:45:53 +02:00
Nikos Mavrogiannopoulos b674a46af6 occtl: print the configured split-dns domains 2015-08-28 11:41:58 +02:00
Nikos Mavrogiannopoulos f8c7bccfa1 occtl: print the Local Device IP (the IP the user connected to) 2015-08-22 20:13:46 +02:00
Nikos Mavrogiannopoulos ab93ea4d82 Log info message when the control socket is disabled 2015-08-17 14:27:11 +02:00
Nikos Mavrogiannopoulos 1ca573ff16 occtl: added --json option
This allows to parse the output data using automated tools.
2015-05-26 16:09:25 +02:00
Nikos Mavrogiannopoulos 41bcc9d0c0 radius: put the process ID into NAS-Port 2015-05-11 14:15:25 +02:00
Nikos Mavrogiannopoulos 02aa9c691e keep track of client entries in sec-mod and report them in status msg 2015-04-26 17:06:16 +02:00