feat(local-accounts): remove_local_account_keys can clear the password too #92

Merged
christianmanivong merged 1 commits from feat/remove-keys-clear-password into main 2026-11-04 14:29:43 +00:00
Owner

What

remove_local_account_keys(name, keys, *, clear_password=False). With clear_password the account's password goes too, and so do its sudo rule and its admin groups, because sudo asks for that password. The account stays open and keeps its other keys.

Steps: keys, then password and sudo (with the flag). Each step runs even when another failed: sudo goes even when the password could not be cleared. An account that is not there fails keys and clears nothing. A driver without _account_clear_password fails the password step and says so, as add_local_account(clear_password=True) does.

Why

When a person deletes their personal key, netOrk deletes the account password it kept for them along with it. The devices kept that password, and sudo kept working with it. The contract had no public way to clear a password without a key: add_local_account needs a public_key, and lock_local_account would lock an account that is meant to stay open. See NetOrk/netork#2033.

A keyword on remove_local_account_keys rather than a separate method, so a deleted key and the password that went with it are one change on the device and one result.

Tests

tests/test_local_accounts.py gains 5 tests: keys, password and sudo in one call; each step running when one failed; a driver that cannot clear a password; a missing account; the keyword-only flag. The first four failed before the change; the last one guards the signature. The full suite passes (1355), ruff and mypy are clean, and napalm-standard check and ratchet pass.

A minor release, assumed to be 4.29.0. The PRs for napalm-linux, napalm-bsd and napalm-openmediavault raise their floor to it. napalm-qnap-qts stays opted out.

## What `remove_local_account_keys(name, keys, *, clear_password=False)`. With `clear_password` the account's password goes too, and so do its sudo rule and its admin groups, because sudo asks for that password. The account stays open and keeps its other keys. Steps: `keys`, then `password` and `sudo` (with the flag). Each step runs even when another failed: sudo goes even when the password could not be cleared. An account that is not there fails `keys` and clears nothing. A driver without `_account_clear_password` fails the `password` step and says so, as `add_local_account(clear_password=True)` does. ## Why When a person deletes their personal key, netOrk deletes the account password it kept for them along with it. The devices kept that password, and sudo kept working with it. The contract had no public way to clear a password without a key: `add_local_account` needs a `public_key`, and `lock_local_account` would lock an account that is meant to stay open. See NetOrk/netork#2033. A keyword on `remove_local_account_keys` rather than a separate method, so a deleted key and the password that went with it are one change on the device and one result. ## Tests `tests/test_local_accounts.py` gains 5 tests: keys, password and sudo in one call; each step running when one failed; a driver that cannot clear a password; a missing account; the keyword-only flag. The first four failed before the change; the last one guards the signature. The full suite passes (1355), ruff and mypy are clean, and `napalm-standard check` and `ratchet` pass. A minor release, assumed to be **4.29.0**. The PRs for napalm-linux, napalm-bsd and napalm-openmediavault raise their floor to it. napalm-qnap-qts stays opted out.
christianmanivong added 1 commit 2026-11-04 14:21:03 +00:00
feat(local-accounts): remove_local_account_keys can clear the password too
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m1s
driver / test (3.13) (pull_request) Successful in 1m15s
driver / test (3.12) (pull_request) Successful in 1m18s
driver / lowest (pull_request) Successful in 39s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m36s
driver / publish (pull_request) Skipped
ac49e2b5d4
A person who deletes their key loses the password that went with it in netOrk, but the devices kept it, and sudo with it. remove_local_account_keys(name, keys, clear_password=True) takes the keys, the password and sudo in one call; the account stays open. Each step runs when another failed.

See NetOrk/netork#2033.
christianmanivong merged commit d45455adf1 into main 2026-11-04 14:29:43 +00:00
christianmanivong deleted branch feat/remove-keys-clear-password 2026-11-04 14:29:43 +00:00
Sign in to join this conversation.