diff --git a/CHANGELOG.md b/CHANGELOG.md index 8893d23..ea29083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 -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, diff --git a/napalm_bsd/accounts.py b/napalm_bsd/accounts.py index 4520145..213bdea 100644 --- a/napalm_bsd/accounts.py +++ b/napalm_bsd/accounts.py @@ -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]]: diff --git a/tests/test_local_accounts.py b/tests/test_local_accounts.py index 780adee..30b7865 100644 --- a/tests/test_local_accounts.py +++ b/tests/test_local_accounts.py @@ -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"] + ]