feat(local-accounts): a deleted key can take the password with it #30
No files matched your search
+5
-1
@@ -14,9 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
leaves the account open, and `add_local_account(..., clear_password=True)` removes the
|
||||
password (`chpass -p '*'`): the account logs in with its key only and has no sudo.
|
||||
Keys the person added on the host stay.
|
||||
- A deleted key can take the password with it on FreeBSD (NetOrk/netork#2033): through
|
||||
napalm-device-types' `remove_local_account_keys(..., clear_password=True)` the keys go
|
||||
as the person, the password goes (`chpass -p '*'`), and so do the sudo rule and
|
||||
`wheel`. The account stays open.
|
||||
|
||||
### Changed
|
||||
- Needs napalm-device-types 4.28.0.
|
||||
- Needs napalm-device-types 4.29.0.
|
||||
|
||||
### Added
|
||||
- Scheduled jobs on FreeBSD and OpenBSD (NetOrk/netork#1933, #27), through
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ classifiers = [
|
||||
]
|
||||
dependencies = [
|
||||
"napalm>=5.1", # older releases import pkg_resources, which a 3.12 venv lacks
|
||||
"napalm-device-types>=4.28.0",
|
||||
"napalm-device-types>=4.29.0",
|
||||
"paramiko>=5.0.0", # CVE-2026-44405
|
||||
]
|
||||
|
||||
|
||||
@@ -180,6 +180,23 @@ def test_a_replaced_key_is_written_out_of_the_key_file_as_the_person() -> None:
|
||||
assert host.files[_KEYS] == f"{OWN_KEY}\n{ALICE_KEY}\n"
|
||||
|
||||
|
||||
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 chpass clears it
|
||||
and sudo goes; the account stays open."""
|
||||
host = _Host(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.changed_as_root() == [
|
||||
["chpass", "-p", "*", "alice"],
|
||||
["rm", "-f", "--", "/usr/local/etc/sudoers.d/80-account-alice"],
|
||||
["pw", "groupmod", "wheel", "-d", "alice"],
|
||||
]
|
||||
|
||||
|
||||
def test_a_deleted_key_goes_and_the_account_stays_open() -> None:
|
||||
host = _Host(keys=f"{ALICE_KEY}\n{OWN_KEY}\n")
|
||||
|
||||
|
||||
Reference in new issue
Block a user