Merge pull request 'feat: netOrk's own account with a fixed uid on FreeBSD (NetOrk/netork#1817)' (#24) from feature/system-user-uid-1817 into main
driver / standard (push) Successful in 18s
driver / lint (push) Successful in 15s
driver / test (3.12) (push) Successful in 1m12s
driver / types (push) Successful in 1m18s
driver / test (3.13) (push) Successful in 1m14s
driver / lowest (push) Successful in 36s
driver / build (push) Successful in 29s
driver / security (push) Successful in 1m22s
CI / driver (push) Successful in 2m58s
driver / publish (push) Skipped
driver / standard (push) Successful in 18s
driver / lint (push) Successful in 15s
driver / test (3.12) (push) Successful in 1m12s
driver / types (push) Successful in 1m18s
driver / test (3.13) (push) Successful in 1m14s
driver / lowest (push) Successful in 36s
driver / build (push) Successful in 29s
driver / security (push) Successful in 1m22s
CI / driver (push) Successful in 2m58s
driver / publish (push) Skipped
This commit was merged in pull request #24.
This commit is contained in:
commit
405239d5df
3 files changed
+26
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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]]:
|
||||
|
||||
@@ -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"]
|
||||
]
|
||||
Reference in new issue
Block a user