feat(accounts): take replaced and deleted keys out of OMV's database #22

Merged
christianmanivong merged 1 commits from fix/local-account-key-replace into main 2026-11-04 11:33:46 +00:00
Owner

What

Personal accounts on OpenMediaVault now follow what the person changes. See NetOrk/netork#2013.

Needs the releases first: napalm-device-types (NAPALM/napalm-device-types#90, assumed to be 4.28.0) and napalm-linux (NAPALM/napalm-linux#69, assumed to be 0.17.0). The floors are raised to napalm-device-types>=4.28.0 and napalm-linux>=0.17.0. CI pre-installs both from git main.

OMV keeps a user's keys in its own database and deploys them to /var/lib/openmediavault/ssh/authorized_keys/<user>, which the person cannot write to. If only the mixin's ~/.ssh handling ran, the replaced key would stay deployed. The red tests show exactly that: "alice still has a key that was to go". So _account_drop_keys is overridden:

  1. UserMgmt.getUser, then the stored keys minus the ones to go (matched by base64, RFC 4716 or OpenSSH form).
  2. When something changed: UserMgmt.setUser with every other field as getUser returned it and an empty password (meaning "keep"), then Config.applyChanges with only the modules that made dirty (ssh, postfix). Changes already pending in the web UI stay pending.
  3. Then napalm-linux and the mixin take the keys out of ~/.ssh as the person and check that none of them is left in any key file, including OMV's deployed one.

The same applies to add_local_account(..., replaces=[...]) (step old keys) and to remove_local_account_keys. Clearing the password is napalm-linux's usermod -p '*'. OMV keeps no password of its own, and setUser is never sent one.

Tests

Fixtures only, no device. Three tests failed first: test_a_replaced_key_goes_from_omvs_database_and_the_others_stay, test_a_person_who_replaced_a_key_and_removed_the_password_gets_both_on_omv and test_a_deleted_key_goes_through_omv_and_the_account_stays_open. Further tests cover a key in ~/.ssh only (no OMV write), a deploy that does not happen (the step fails) and the inherited clear command. 129 tests pass against the device-types and napalm-linux branches. ruff, napalm-standard check and ratchet are clean, and mypy reports nothing in napalm_openmediavault.

## What Personal accounts on OpenMediaVault now follow what the person changes. See NetOrk/netork#2013. **Needs the releases first:** napalm-device-types (NAPALM/napalm-device-types#90, assumed to be 4.28.0) and napalm-linux (NAPALM/napalm-linux#69, assumed to be 0.17.0). The floors are raised to `napalm-device-types>=4.28.0` and `napalm-linux>=0.17.0`. CI pre-installs both from git main. OMV keeps a user's keys in its own database and deploys them to `/var/lib/openmediavault/ssh/authorized_keys/<user>`, which the person cannot write to. If only the mixin's `~/.ssh` handling ran, the replaced key would stay deployed. The red tests show exactly that: "alice still has a key that was to go". So `_account_drop_keys` is overridden: 1. `UserMgmt.getUser`, then the stored keys minus the ones to go (matched by base64, RFC 4716 or OpenSSH form). 2. When something changed: `UserMgmt.setUser` with every other field as `getUser` returned it and an empty password (meaning "keep"), then `Config.applyChanges` with only the modules that made dirty (`ssh`, `postfix`). Changes already pending in the web UI stay pending. 3. Then napalm-linux and the mixin take the keys out of `~/.ssh` as the person and check that none of them is left in any key file, including OMV's deployed one. The same applies to `add_local_account(..., replaces=[...])` (step `old keys`) and to `remove_local_account_keys`. **Clearing the password** is napalm-linux's `usermod -p '*'`. OMV keeps no password of its own, and `setUser` is never sent one. ## Tests Fixtures only, no device. Three tests failed first: `test_a_replaced_key_goes_from_omvs_database_and_the_others_stay`, `test_a_person_who_replaced_a_key_and_removed_the_password_gets_both_on_omv` and `test_a_deleted_key_goes_through_omv_and_the_account_stays_open`. Further tests cover a key in `~/.ssh` only (no OMV write), a deploy that does not happen (the step fails) and the inherited clear command. 129 tests pass against the device-types and napalm-linux branches. ruff, `napalm-standard check` and `ratchet` are clean, and mypy reports nothing in `napalm_openmediavault`.
christianmanivong added 1 commit 2026-11-04 10:50:36 +00:00
feat(accounts): take replaced and deleted keys out of OMV's database
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m40s
driver / test (3.12) (pull_request) Successful in 1m44s
driver / lowest (pull_request) Successful in 38s
driver / test (3.13) (pull_request) Successful in 1m50s
driver / build (pull_request) Successful in 35s
driver / security (pull_request) Successful in 1m15s
CI / driver (pull_request) Successful in 3m29s
driver / publish (pull_request) Skipped
ed083df018
napalm-device-types 4.28.0 lets add_local_account remove the old keys
(replaces) and adds remove_local_account_keys. OMV keeps a user's keys
in its own database and deploys them where the person cannot write, so
the mixin's key files alone would leave the old key deployed. The keys
go through UserMgmt.setUser, applying only what that made dirty, and
then out of ~/.ssh. Clearing the password is napalm-linux 0.17.0's.

See NetOrk/netork#2013
christianmanivong merged commit 6727f0a79c into main 2026-11-04 11:33:46 +00:00
christianmanivong deleted branch fix/local-account-key-replace 2026-11-04 11:33:46 +00:00
Sign in to join this conversation.