diff --git a/pym/install/variables/system.py b/pym/install/variables/system.py index 00ec2d4..2dde396 100644 --- a/pym/install/variables/system.py +++ b/pym/install/variables/system.py @@ -170,14 +170,12 @@ class VariableClMigrateRootPwdPlain(GrubHelper, UserHelper, Variable): if not value and not self.Get('cl_migrate_root_shadow_pwd'): raise PasswordError(_("Enter password for user %s") % "root") if value != self.stub_hash_value: - if len(value) < 8: - raise VariableError(_(f"Password should contain at least 8 symbols")) - elif not any([x.isupper() for x in value]): - raise VariableError(_(f"Password should contain at least 1 uppercase letter")) - elif not any([x.islower() for x in value]): - raise VariableError(_(f"Password should contain at least 1 lowercase letter")) - elif not any([x.isdigit() for x in value]): - raise VariableError(_(f"Password should contain at least 1 digit")) + if not all([len(value) > 7, + any([x.isupper() for x in value]), + any([x.islower() for x in value]), + any([x.isdigit() for x in value])]): + raise VariableError( + _("Password should contain at least 8 symbols, 1 uppercase letter, 1 lowercase letter, 1 digit")) # если plain пароля нет (есть только хэш), но требуется установить # пароль на grub (cl_grub_passwd_set), при этом нет 07_passwd if (value == self.stub_hash_value and @@ -566,14 +564,12 @@ class VariableClMigrateUserPwd(UserHelper, Variable): for pas in value: if pas == 'guest': pass - elif len(pas) < 8: - raise VariableError(_("Password should contain at least 8 symbols")) - elif not any([x.isupper() for x in pas]): - raise VariableError(_("Password should contain at least 1 uppercase letter")) - elif not any([x.islower() for x in pas]): - raise VariableError(_("Password should contain at least 1 lowercase letter")) - elif not any([x.isdigit() for x in pas]): - raise VariableError(_("Password should contain at least 1 digit")) + if not all([len(pas) > 7, + any([x.isupper() for x in pas]), + any([x.islower() for x in pas]), + any([x.isdigit() for x in pas])]): + raise VariableError( + _("Password should contain at least 8 symbols, 1 uppercase letter, 1 lowercase letter, 1 digit")) shadow_hash = get_shadow_hash() return [x if shadow_hash.identify(x) or not x else shadow_hash.hash(x) for x in value]