From f9ebdb892b94d13218630cfdf069df511d022928 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Feb 2023 17:43:14 +0300 Subject: [PATCH] =?UTF-8?q?Fix:=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=D0=B4=D0=B5=D0=B6=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/install/variables/system.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) 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]