feat: netOrk's own account with a fixed uid on FreeBSD (NetOrk/netork#1817) #24

Merged
christianmanivong merged 1 commits from feature/system-user-uid-1817 into main 2026-11-01 12:44:20 +00:00
3 changed files with 26 additions and 0 deletions

No files matched your search

+2
View File
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- netOrk's own account with a fixed uid on FreeBSD (NetOrk/netork#1817):
`_account_create_with_uid` makes it with `pw useradd -u <uid> -m -w no`.
- Personal accounts on FreeBSD (NetOrk/netork#1793), through napalm-device-types'
`LocalAccountsMixin`: `get_local_accounts()`, `add_local_account()` and
`lock_local_account()` with `pw useradd -m -w no`, `chpass -p` for the password hash,
+17
View File
@@ -29,6 +29,23 @@ class FreeBSDLocalAccountsMixin(LocalAccountsMixin):
create = ["pw", "useradd", "-n", name, "-m", "-s", self.ACCOUNT_SHELL, "-w", "no"]
return [create, *self._set_password(name, password_hash)]
def _account_create_with_uid(self, name: str, uid: int) -> list[list[str]]:
return [
[
"pw",
"useradd",
"-n",
name,
"-u",
str(uid),
"-m",
"-s",
self.ACCOUNT_SHELL,
"-w",
"no",
]
]
def _account_open(
self, name: str, password_hash: str | None, *, locked: bool
) -> list[list[str]]:
+7
View File
@@ -97,3 +97,10 @@ def test_leaving_a_group_is_pw_groupmod() -> None:
"-d",
"alice",
]
def test_netorks_own_account_is_made_with_its_uid() -> None:
"""NetOrk/netork#1817: a fixed uid on every host, no password."""
assert _Driver()._account_create_with_uid("netork", 900) == [
["pw", "useradd", "-n", "netork", "-u", "900", "-m", "-s", "/bin/sh", "-w", "no"]
]