feat(logins): every account a person can log in with, as one read-only reading, 4.51.0 (NetOrk/netork#2707) #138

Merged
christianmanivong merged 4 commits from feature/host-logins into main 2026-11-28 09:31:37 +00:00
Owner

LoginAccountsMixin.get_login_accounts() (NetOrk/netork#2707, decided 2026-11-28: option A, plus the failed attempts as a number only):

  • Accounts: root and UID 1000 on with a login shell (login_capable), from /etc/passwd -- name, UID, home and shell only, never the comment field. Directory accounts (SSSD, AD join) are not in /etc/passwd and are not read; the directory reviews them.
  • Last login: the newest any of lastlog2, lastlog, wtmpdb last and last knows (a host upgraded to lastlog2 keeps an old lastlog; a desktop login reaches wtmp only), as ISO UTC, with the remote host, the terminal and the tool that told it.
  • Lock and expiry: passwd -S (shadow's and libuser's words: set, locked, none) and chage -l (password change, password and account expiry: ISO date, never, must_change). locked is the password locked or the account expired on the host's date (usermod -L -e 1 does both).
  • Failed attempts since the last login, a number: lastb (the newest 1000 per account, failed_logins_capped when reached), else pam_faillock's tally. No warning comes of it.
  • One fixed command, read-only, LC_ALL=C, exec </dev/null so a sudo password never reaches a tool, no password hash read. Root first; where root is refused, as the login user: the last logins only, the rest None.

Tests: tests/test_login_accounts.py (39), with fixtures for Debian 12 (lastlog, wtmp, lastb, shadow's passwd -S), Debian 13 (lastlog2, wtmpdb, faillock), AlmaLinux 9 (libuser's passwd -S) and a read without root, plus the command run and parsed on a Linux host. ruff and mypy clean.

Version 4.51.0: v4.50.0 went to #140, which is merged into this branch (by merge). napalm-linux carries it in NAPALM/napalm-linux (0.21.0). napalm-linux carries it in NAPALM/napalm-linux (0.21.0).

`LoginAccountsMixin.get_login_accounts()` (NetOrk/netork#2707, decided 2026-11-28: option A, plus the failed attempts as a number only): - **Accounts:** root and UID 1000 on with a login shell (`login_capable`), from `/etc/passwd` -- name, UID, home and shell only, never the comment field. Directory accounts (SSSD, AD join) are not in `/etc/passwd` and are not read; the directory reviews them. - **Last login:** the newest any of `lastlog2`, `lastlog`, `wtmpdb last` and `last` knows (a host upgraded to lastlog2 keeps an old lastlog; a desktop login reaches wtmp only), as ISO UTC, with the remote host, the terminal and the tool that told it. - **Lock and expiry:** `passwd -S` (shadow's and libuser's words: `set`, `locked`, `none`) and `chage -l` (password change, password and account expiry: ISO date, `never`, `must_change`). `locked` is the password locked or the account expired on the host's date (`usermod -L -e 1` does both). - **Failed attempts since the last login,** a number: `lastb` (the newest 1000 per account, `failed_logins_capped` when reached), else `pam_faillock`'s tally. No warning comes of it. - One fixed command, read-only, `LC_ALL=C`, `exec </dev/null` so a sudo password never reaches a tool, no password hash read. Root first; where root is refused, as the login user: the last logins only, the rest `None`. Tests: `tests/test_login_accounts.py` (39), with fixtures for Debian 12 (lastlog, wtmp, lastb, shadow's `passwd -S`), Debian 13 (lastlog2, wtmpdb, faillock), AlmaLinux 9 (libuser's `passwd -S`) and a read without root, plus the command run and parsed on a Linux host. ruff and mypy clean. Version 4.51.0: v4.50.0 went to #140, which is merged into this branch (by merge). napalm-linux carries it in NAPALM/napalm-linux (0.21.0). napalm-linux carries it in NAPALM/napalm-linux (0.21.0).
christianmanivong added 2 commits 2026-11-28 02:53:21 +00:00
LoginAccountsMixin.get_login_accounts: root and UID 1000 on with a login
shell, from /etc/passwd without the comment field; the newest last login of
lastlog2, lastlog, wtmpdb last and last, with where it came from; the
password state and expiry from passwd -S and chage -l; the failed attempts
since the last login from lastb, else faillock. Root first, the login user
where root is refused, when what needs root is None.
chore(release): 4.50.0
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m24s
driver / lowest (pull_request) Successful in 45s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Failing after 1m2s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
14217b6eeb
christianmanivong changed title from feat(logins): every account a person can log in with, as one read-only reading, 4.50.0 (NetOrk/netork#2707) to feat(logins): every account a person can log in with, as one read-only reading, 4.51.0 (NetOrk/netork#2707) 2026-11-28 07:28:12 +00:00
christianmanivong added 1 commit 2026-11-28 07:35:09 +00:00
Merge NAPALM/napalm-device-types main (4.50.0) into feature/host-logins
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 21s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m26s
driver / lowest (pull_request) Successful in 47s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Failing after 1m5s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped
4b4797e383
v4.50.0 went to #140, so this branch's release is 4.51.0 now.
christianmanivong added 1 commit 2026-11-28 09:06:08 +00:00
fix(logins): the password states are named constants, not literals in a comparison (NetOrk/netork#2707)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 17s
driver / types (pull_request) Successful in 52s
driver / test (3.13) (pull_request) Successful in 1m0s
driver / lowest (pull_request) Successful in 38s
driver / test (3.12) (pull_request) Successful in 1m18s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 2m19s
driver / publish (pull_request) Skipped
e25aebbe45
bandit reads password == "locked" as a hardcoded password (B105) and fails
the security job. A state word is none; STATE_SET, STATE_LOCKED and
STATE_NONE name them.
christianmanivong merged commit 5b4195f028 into main 2026-11-28 09:31:37 +00:00
Sign in to join this conversation.