From 9551b7434a6c696f894b889d219a483716f261b4 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Wed, 4 Nov 2026 15:22:51 +0100 Subject: [PATCH] feat(local-accounts): a deleted key can take the password with it napalm-device-types 4.29.0 lets remove_local_account_keys clear the password and sudo too (NetOrk/netork#2033). This driver's _account_clear_password already does the work; a test pins the commands, and the floor rises to 4.29.0. --- CHANGELOG.md | 6 +++++- pyproject.toml | 2 +- tests/test_local_accounts.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a09f0e..6898c5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,13 @@ All notable changes to this driver. The format follows account open, and `add_local_account(..., clear_password=True)` removes the password (`usermod -p '*'`, as napalm-linux does): the account logs in with its key only and has no sudo. Keys the person added stay. +- A deleted key can take the password with it on OpenMediaVault (NetOrk/netork#2033): + through napalm-device-types' `remove_local_account_keys(..., clear_password=True)` the + keys go through OMV's key store, the password goes (`usermod -p '*'`), and so does + sudo. The account stays open and in `_ssh`. ### Changed -- Needs napalm-device-types 4.28.0 and napalm-linux 0.17.0. +- Needs napalm-device-types 4.29.0 and napalm-linux 0.17.0. ### Added - Scheduled jobs (NetOrk/netork#1933, #18), on top of napalm-linux's reading and writers. diff --git a/pyproject.toml b/pyproject.toml index a0161d9..d31a6f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ classifiers = [ ] dependencies = [ "napalm>=4.0", - "napalm-device-types>=4.28.0", + "napalm-device-types>=4.29.0", "napalm-linux>=0.17.0", ] diff --git a/tests/test_local_accounts.py b/tests/test_local_accounts.py index 7e1ce97..3a55c59 100644 --- a/tests/test_local_accounts.py +++ b/tests/test_local_accounts.py @@ -367,3 +367,19 @@ def test_a_deleted_key_goes_through_omv_and_the_account_stays_open() -> None: assert result["success"], result["output"] assert omv.users["alice"]["sshpubkeys"] == [] assert not [c for c, _ in driver.ran if c.startswith(("usermod", "gpasswd"))] + + +def test_a_deleted_key_takes_the_password_and_sudo_with_it_on_omv() -> None: + """NetOrk/netork#2033: the key goes through OMV, the password with usermod as on + napalm-linux, and sudo; the account stays open and in _ssh.""" + omv = Omv() + driver = _Account(omv) + + result = driver.remove_local_account_keys("alice", [OWN_KEY], clear_password=True) + + assert result["success"], result["output"] + assert [s["step"] for s in result["steps"]] == ["keys", "password", "sudo"] + assert omv.users["alice"]["sshpubkeys"] == [] + assert ("usermod -p '*' alice", True) in driver.ran + assert ("rm -f -- /etc/sudoers.d/80-account-alice", True) in driver.ran + assert not [c for c, _ in driver.ran if c.startswith("gpasswd -d alice _ssh")] -- 2.54.1