feat(login-sessions): the interactive logins a host recorded, 4.55.0 (NetOrk/netork#2881) #143

Merged
christianmanivong merged 2 commits from feature/login-sessions into main 2026-12-01 08:54:18 +00:00
Owner

LoginSessionsMixin.get_login_sessions(): the interactive logins a Linux host recorded over the last seven days, for NetOrk/netork#2881 (C1: shells that did not go through the application).

  • Reads wtmpdb last and last (wtmp) with --time-format iso -w, -i where the tool takes it (the address, not a name), bounded with --since on the host; without --since the window is applied in the parse. A session in both records is one.
  • Only terminal logins count (is_interactive): pts/N, ttyN, serial and hypervisor consoles; not reboot/shutdown entries, X displays, ssh:notty, FTP lines or windows of screen.
  • own_address: the driver's own SSH client address from SSH_CONNECTION (an IPv4-mapped address as IPv4). Its sessions are left out on the host already (awk), since a client that opens a terminal adds one per connection; the newest 1000 others are read.
  • Template form as LoginAccountsMixin: the command and parse are here, a driver supplies _run_login_sessions_command(command), run as the login user (sudo would reset SSH_CONNECTION; wtmp is world-readable). A host without a readable record (BusyBox last) raises LoginSessionsUnavailable.

Tests: fixtures for Debian 12 (util-linux), Debian 13 (wtmpdb, offsets without a colon), AlmaLinux 9 without -i/--since, crash/down durations, gone - no logout, dedup across records, and a run of the real command on the CI host.

Two commits: the feature, and chore(release): 4.55.0.

`LoginSessionsMixin.get_login_sessions()`: the interactive logins a Linux host recorded over the last seven days, for NetOrk/netork#2881 (C1: shells that did not go through the application). - Reads `wtmpdb last` and `last` (wtmp) with `--time-format iso -w`, `-i` where the tool takes it (the address, not a name), bounded with `--since` on the host; without `--since` the window is applied in the parse. A session in both records is one. - Only terminal logins count (`is_interactive`): `pts/N`, `ttyN`, serial and hypervisor consoles; not reboot/shutdown entries, X displays, `ssh:notty`, FTP lines or windows of `screen`. - `own_address`: the driver's own SSH client address from `SSH_CONNECTION` (an IPv4-mapped address as IPv4). Its sessions are left out on the host already (awk), since a client that opens a terminal adds one per connection; the newest 1000 others are read. - Template form as `LoginAccountsMixin`: the command and parse are here, a driver supplies `_run_login_sessions_command(command)`, run as the login user (sudo would reset `SSH_CONNECTION`; wtmp is world-readable). A host without a readable record (BusyBox `last`) raises `LoginSessionsUnavailable`. Tests: fixtures for Debian 12 (util-linux), Debian 13 (wtmpdb, offsets without a colon), AlmaLinux 9 without `-i`/`--since`, crash/down durations, `gone - no logout`, dedup across records, and a run of the real command on the CI host. Two commits: the feature, and `chore(release): 4.55.0`.
christianmanivong added 2 commits 2026-12-01 08:41:45 +00:00
LoginSessionsMixin reads wtmpdb's and wtmp's records of the last seven
days with ISO times, bounded on the host, keeps terminal logins only and
names the driver's own SSH client address (SSH_CONNECTION), whose sessions
it leaves out. A driver supplies _run_login_sessions_command; a host
without a readable record raises LoginSessionsUnavailable.
chore(release): 4.55.0
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 21s
driver / lowest (pull_request) Successful in 43s
driver / types (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / test (3.13) (pull_request) Successful in 1m9s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m10s
CI / driver (pull_request) Successful in 2m14s
driver / publish (pull_request) Skipped
6c72089315
christianmanivong merged commit 2df46741f2 into main 2026-12-01 08:54:18 +00:00
christianmanivong deleted branch feature/login-sessions 2026-12-01 08:54:18 +00:00
Sign in to join this conversation.