fix: the webui does not allow to disable the last admin now.
Release / release (push) Failing after 4s

This commit is contained in:
slawek committed 2026-11-22 19:48:02 +01:00
1 parent 5fff009320
commit ff0c93ed73
10 files changed
+46 -15

No files matched your search

@@ -765,9 +765,17 @@ def passwd(connection, name, password):
def disable(connection, name):
"""Lock the user out; the WireGuard peers of a disabled user are left out of wg0.conf."""
"""Lock the user out; the WireGuard peers of a disabled user are left out of wg0.conf.
The last enabled member of admins is not disabled, so the server keeps an administrator who can sign in;
Failure with status 4.
"""
current = entry(connection, name)
if current.get('pwdAccountLockedTime') != [LOCKED]:
admins = groups_of(connection, name).get(ADMIN_GROUP)
if admins is not None and not any(entry(connection, member).get('pwdAccountLockedTime') != [LOCKED]
for member in admins if member != name):
raise Failure(f'{name} is the last enabled member of {ADMIN_GROUP} and cannot be disabled', 4)
connection.modify_s(dn_of(name), [(ldap.MOD_REPLACE, 'pwdAccountLockedTime', [LOCKED])])
if 'linuxManagerWireGuardPeer' in current:
apply_wireguard()