Merge pull request 'feat(local-accounts): a deleted key can take the password with it' (#71) from feat/remove-keys-clear-password into main
driver / standard (push) Successful in 17s
driver / lint (push) Successful in 15s
driver / types (push) Successful in 1m3s
driver / test (3.12) (push) Successful in 1m5s
driver / lowest (push) Successful in 35s
driver / test (3.13) (push) Successful in 1m9s
driver / build (push) Successful in 32s
driver / security (push) Successful in 1m15s
CI / driver (push) Successful in 2m48s
driver / publish (push) Skipped

This commit was merged in pull request #71.
This commit is contained in:
christianmanivong committed 2026-11-04 14:45:06 +00:00
commit 249046512d
3 files changed
+27 -1

No files matched your search

+9
View File
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- A deleted key can take the password with it (NetOrk/netork#2033): through
napalm-device-types' `remove_local_account_keys(..., clear_password=True)` the keys go
as the person, the password goes (`usermod -p '*'`), and so do the sudo rule and the
admin groups. The account stays open and logs in with its other keys only.
### Changed
- Needs napalm-device-types 4.29.0.
## [0.17.0] - 2026-11-04
### Added
+1 -1
View File
@@ -34,7 +34,7 @@ classifiers = [
]
dependencies = [
"napalm>=4.0",
"napalm-device-types>=4.28.0",
"napalm-device-types>=4.29.0",
"netmiko>=4.0.0",
"paramiko>=5.0.0", # CVE-2026-44405
]
+17
View File
@@ -205,6 +205,23 @@ def test_a_replaced_key_is_written_out_of_the_key_file_as_the_person() -> None:
assert installs and all(c.startswith("sudo -n -u alice install") for c in installs)
def test_a_deleted_key_takes_the_password_and_sudo_with_it_when_asked() -> None:
"""NetOrk/netork#2033: the password went with the person's key, so it goes from the
host too, with sudo; the account stays open."""
host = _Host(_OPEN, keys=f"{ALICE_KEY}\n{OWN_KEY}\n")
result = host.remove_local_account_keys("alice", [ALICE_KEY], clear_password=True)
assert result["success"], result["output"]
assert [s["step"] for s in result["steps"]] == ["keys", "password", "sudo"]
assert host.files[_KEYS] == f"{OWN_KEY}\n"
assert host.as_root() == [
["usermod", "-p", "*", "alice"],
["rm", "-f", "--", "/etc/sudoers.d/80-account-alice"],
["gpasswd", "-d", "alice", "sudo"],
]
def test_a_deleted_key_goes_and_the_account_stays_open() -> None:
host = _Host(_OPEN, keys=f"{ALICE_KEY}\n{OWN_KEY}\n")