feat: personal accounts on FreeBSD with pw and chpass (NetOrk/netork#1793) #23

Merged
christianmanivong merged 1 commits from feat/local-accounts into main 2026-10-31 23:45:02 +00:00
Owner

Part of NetOrk/netork#1793. FreeBSDDriver mixes in napalm-device-types' LocalAccountsMixin (NAPALM/napalm-device-types#62), which needs to be merged first. CI pre-installs device-types main until that release is on PyPI.

Commands

  • Create: pw useradd -n <name> -m -s /bin/sh -w no, then chpass -p <hash> <name> when a password hash is given. chpass takes the crypt(3) string from root.
  • Lock: pw lock <name>, only when the account is not locked yet, because pw refuses a second lock. The *LOCKED* prefix makes sshd refuse a key login too. That matters here: nuageinit sets UsePAM no, so nothing else would refuse it.
  • Open again: pw unlock <name> when locked, plus chpass -p for a new hash.
  • Lock state: getent passwd <name> as root. getpwnam(3) shows the password field to root only. Only the prefix is looked at.
  • Leave a group: pw groupmod <group> -d <name>. The admin group is wheel.
  • Sudo rule: /usr/local/etc/sudoers.d/80-account-<name>. The port's sudoers ends in @includedir /usr/local/etc/sudoers.d, confirmed on the VM.

Verified

FreeBSD 15.1-RELEASE-p6 cloud image in QEMU, set up by nuageinit, tested with the real driver over SSH with sudo -S:

  • add with sudo: key login works, and sudo takes the person's password
  • lock: key login is refused (ssh 255), keys and sudo are gone
  • reopen without sudo: key login works, sudo is refused
  • an account in wheel leaves it
  • the login user's own account and root are refused

OpenBSD is left out (OpenBSDDriver offers none of it, and a test pins that) while OpenBSD work is deferred.

Part of NetOrk/netork#1793. `FreeBSDDriver` mixes in napalm-device-types' `LocalAccountsMixin` (NAPALM/napalm-device-types#62), which needs to be merged first. CI pre-installs device-types `main` until that release is on PyPI. ## Commands - Create: `pw useradd -n <name> -m -s /bin/sh -w no`, then `chpass -p <hash> <name>` when a password hash is given. chpass takes the crypt(3) string from root. - Lock: `pw lock <name>`, only when the account is not locked yet, because pw refuses a second lock. The `*LOCKED*` prefix makes sshd refuse a key login too. That matters here: nuageinit sets `UsePAM no`, so nothing else would refuse it. - Open again: `pw unlock <name>` when locked, plus `chpass -p` for a new hash. - Lock state: `getent passwd <name>` as root. getpwnam(3) shows the password field to root only. Only the prefix is looked at. - Leave a group: `pw groupmod <group> -d <name>`. The admin group is `wheel`. - Sudo rule: `/usr/local/etc/sudoers.d/80-account-<name>`. The port's sudoers ends in `@includedir /usr/local/etc/sudoers.d`, confirmed on the VM. ## Verified FreeBSD 15.1-RELEASE-p6 cloud image in QEMU, set up by nuageinit, tested with **the real driver** over SSH with `sudo -S`: - add with sudo: key login works, and `sudo` takes the person's password - lock: key login is refused (ssh 255), keys and sudo are gone - reopen without sudo: key login works, sudo is refused - an account in `wheel` leaves it - the login user's own account and `root` are refused OpenBSD is left out (`OpenBSDDriver` offers none of it, and a test pins that) while OpenBSD work is deferred.
christianmanivong added 1 commit 2026-10-31 22:32:14 +00:00
feat: personal accounts on FreeBSD with pw and chpass (NetOrk/netork#1793)
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Failing after 1m5s
driver / test (3.13) (pull_request) Failing after 55s
driver / test (3.12) (pull_request) Failing after 1m1s
driver / lowest (pull_request) Failing after 30s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m30s
CI / driver (pull_request) Failing after 3m1s
driver / publish (pull_request) Skipped
faa5f24182
FreeBSDDriver mixes in napalm-device-types' LocalAccountsMixin: pw useradd
-m -w no, chpass -p for the password hash, pw lock/unlock and pw groupmod
-d. A locked account carries *LOCKED*, which sshd refuses a key login too
(nuageinit sets UsePAM no, so nothing else would). getpwnam(3) shows the
password field to root only, so the lock is read with getent as root and
only its prefix is looked at. The sudo rule goes to the sudo package's
/usr/local/etc/sudoers.d.

Checked on a FreeBSD 15.1 cloud image with the real driver over SSH and
sudo -S: key login works after adding and after reopening and is refused
after locking, sudo takes the person's password, wheel is left when sudo
is not wanted. OpenBSD is left out for now.

CI pre-installs napalm-device-types from main until the release with
LocalAccountsMixin is on PyPI.
christianmanivong merged commit f394610468 into main 2026-10-31 23:45:02 +00:00
christianmanivong deleted branch feat/local-accounts 2026-10-31 23:45:02 +00:00
Sign in to join this conversation.