Merge pull request 'feat: netOrk's own account with a fixed uid (NetOrk/netork#1817)' (#53) from feature/system-user-uid-1817 into main
driver / standard (push) Successful in 17s
driver / lint (push) Successful in 17s
driver / types (push) Successful in 1m9s
driver / test (3.12) (push) Successful in 1m6s
driver / test (3.13) (push) Successful in 1m7s
driver / lowest (push) Successful in 39s
driver / build (push) Failing after 7s
driver / security (push) Successful in 1m15s
CI / driver (push) Failing after 2m57s
driver / publish (push) Skipped
driver / standard (push) Successful in 17s
driver / lint (push) Successful in 17s
driver / types (push) Successful in 1m9s
driver / test (3.12) (push) Successful in 1m6s
driver / test (3.13) (push) Successful in 1m7s
driver / lowest (push) Successful in 39s
driver / build (push) Failing after 7s
driver / security (push) Successful in 1m15s
CI / driver (push) Failing after 2m57s
driver / publish (push) Skipped
This commit was merged in pull request #53.
This commit is contained in:
commit
a729b35d8b
3 files changed
+14
No files matched your search
@@ -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
|
||||
|
||||
@@ -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]]:
|
||||
|
||||
@@ -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"]
|
||||
]
|
||||
Reference in new issue
Block a user