feat: netOrk's own account with a fixed uid (NetOrk/netork#1817) #53
No files matched your search
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### 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`:
|
- Personal accounts (NetOrk/netork#1793), through napalm-device-types' `LocalAccountsMixin`:
|
||||||
`get_local_accounts()`, `add_local_account()` and `lock_local_account()` with
|
`get_local_accounts()`, `add_local_account()` and `lock_local_account()` with
|
||||||
shadow-utils' commands (`useradd -m -s /bin/bash`, `usermod`, `gpasswd -d`). A locked
|
shadow-utils' commands (`useradd -m -s /bin/bash`, `usermod`, `gpasswd -d`). A locked
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class LinuxLocalAccountsMixin(LocalAccountsMixin):
|
|||||||
password = ["-p", password_hash] if password_hash else []
|
password = ["-p", password_hash] if password_hash else []
|
||||||
return [["useradd", "-m", "-s", self.ACCOUNT_SHELL, *password, name]]
|
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(
|
def _account_open(
|
||||||
self, name: str, password_hash: str | None, *, locked: bool
|
self, name: str, password_hash: str | None, *, locked: bool
|
||||||
) -> list[list[str]]:
|
) -> list[list[str]]:
|
||||||
|
|||||||
@@ -101,3 +101,10 @@ def test_leaving_a_group_is_gpasswd() -> None:
|
|||||||
"alice",
|
"alice",
|
||||||
"sudo",
|
"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"]
|
||||||
|
]
|
||||||
Reference in new issue
Block a user