From 8485ebc75a9425ae90d44a466dbf81140112e21c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 3 Feb 2023 21:13:17 +0100 Subject: [PATCH] admin->admins migration: try to handle boring case where the 'first' user cant be identified because it doesnt have the root@ alias --- src/migrations/0026_new_admins_group.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/migrations/0026_new_admins_group.py b/src/migrations/0026_new_admins_group.py index 98f2a54be..a260074fd 100644 --- a/src/migrations/0026_new_admins_group.py +++ b/src/migrations/0026_new_admins_group.py @@ -46,6 +46,19 @@ class MyMigration(Migration): new_admin_user = user break + # For some reason some system have no user with root@ alias, + # but the user does has admin / postmaster / ... alias + # ... try to find it instead otherwise this creashes the migration + # later because the admin@, postmaster@, .. aliases will already exist + if not new_admin_user: + for user in all_users: + aliases = user_info(user).get("mail-aliases", []) + if any(alias.startswith(f"admin@{main_domain}") for alias in aliases) \ + and any(alias.startswith(f"postmaster@{main_domain}") for alias in aliases): + new_admin_user = user + break + + self.ldap_migration_started = True if new_admin_user: