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

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 14 additions and 0 deletions

No files matched your search

+3
View File
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- netOrk's own account with a fixed uid (NetOrk/netork#1817): `_account_create_with_uid`
makes it with `useradd -m -u <uid>`. Below `UID_MIN` useradd warns and goes on, as a
system's account.
- Personal accounts (NetOrk/netork#1793), through napalm-device-types' `LocalAccountsMixin`:
`get_local_accounts()`, `add_local_account()` and `lock_local_account()` with
shadow-utils' commands (`useradd -m -s /bin/bash`, `usermod`, `gpasswd -d`). A locked
+4
View File
@@ -29,6 +29,10 @@ class LinuxLocalAccountsMixin(LocalAccountsMixin):
password = ["-p", password_hash] if password_hash else []
return [["useradd", "-m", "-s", self.ACCOUNT_SHELL, *password, name]]
def _account_create_with_uid(self, name: str, uid: int) -> list[list[str]]:
# Below UID_MIN useradd warns and goes on: netOrk's own account is a system's.
return [["useradd", "-m", "-u", str(uid), "-s", self.ACCOUNT_SHELL, name]]
def _account_open(
self, name: str, password_hash: str | None, *, locked: bool
) -> list[list[str]]:
+7
View File
@@ -101,3 +101,10 @@ def test_leaving_a_group_is_gpasswd() -> None:
"alice",
"sudo",
]
def test_netorks_own_account_is_made_with_its_uid() -> None:
"""A fixed uid on every host, below UID_MIN (NetOrk/netork#1817)."""
assert _Driver()._account_create_with_uid("netork", 900) == [
["useradd", "-m", "-u", "900", "-s", "/bin/bash", "netork"]
]