From 7975d73cadbc60c320333fba78aca1e5e31dd23b Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 25 Oct 2018 14:56:12 +0200 Subject: [PATCH] [enh] Manual migration if not weak password --- locales/en.json | 1 + .../data_migrations/0006_migrate_pwd.py | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/locales/en.json b/locales/en.json index ab5569cfc..cb9d53560 100644 --- a/locales/en.json +++ b/locales/en.json @@ -287,6 +287,7 @@ "migration_0005_postgresql_94_not_installed": "Postgresql was not installed on your system. Nothing to do!", "migration_0005_postgresql_96_not_installed": "Postgresql 9.4 has been found to be installed, but not postgresql 9.6 !? Something weird might have happened on your system :( ...", "migration_0005_not_enough_space": "Not enough space is available in {path} to run the migration right now :(.", + "migration_0006_root_admin_sync_warning": "Yunohost now expect admin and root passwords to be synchronized. By running this migration, your root password is going to be replaced by your root password.", "migrations_backward": "Migrating backward.", "migrations_bad_value_for_target": "Invalid number for target argument, available migrations numbers are 0 or {}", "migrations_cant_reach_migration_file": "Can't access migrations files at path %s", diff --git a/src/yunohost/data_migrations/0006_migrate_pwd.py b/src/yunohost/data_migrations/0006_migrate_pwd.py index 93783d662..dec795ae3 100644 --- a/src/yunohost/data_migrations/0006_migrate_pwd.py +++ b/src/yunohost/data_migrations/0006_migrate_pwd.py @@ -21,14 +21,26 @@ class MyMigration(Migration): def migrate(self): - if self._is_root_pwd_listed(SMALL_PWD_LIST): - new_hash = self._get_admin_hash() - self._replace_root_hash(new_hash) + new_hash = self._get_admin_hash() + self._replace_root_hash(new_hash) def backward(self): - pass + @property + def mode(self): + if self._is_root_pwd_listed(SMALL_PWD_LIST): + return "auto" + + return "manual" + + @property + def disclaimer(self): + if self._is_root_pwd_listed(SMALL_PWD_LIST): + return None + + return m18n.n("migration_0006_root_admin_sync_warning") + def _get_admin_hash(self): """ Ask for admin hash the ldap db