Skip to content

Commit

Permalink
vyos.utils: image-tools: T6353: Fix broken import statement; Refactor…
Browse files Browse the repository at this point in the history
… password length check; Improve message format.
  • Loading branch information
oniko94 committed Feb 7, 2025
1 parent 3d5ae6e commit e59c6e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/op_mode/image_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from vyos.remote import download
from vyos.system import disk, grub, image, compat, raid, SYSTEM_CFG_VER
from vyos.template import render
from vyos.utils.auth import check_passwd_strength, is_passwd_valid
from vyos.utils.auth import check_passwd_strength
from vyos.utils.io import ask_input, ask_yes_no, select_entry
from vyos.utils.file import chmod_2775
from vyos.utils.process import cmd, run, rc_cmd
Expand Down Expand Up @@ -72,7 +72,7 @@
MSG_INPUT_PASSWORD: str = 'Please enter a password for the "vyos" user:'
MSG_INPUT_PASSWORD_CONFIRM: str = 'Please confirm password for the "vyos" user:'
MSG_INPUT_WEAK_PASSWORD_CONFIRM: str = 'This password is weak and may be easily compromised. It should '\
'\n rules \n to be more secure. Do you wish to continue with this password?'
'\nrules\n to be more secure. Do you wish to continue with this password?'
MSG_INPUT_ROOT_SIZE_ALL: str = 'Would you like to use all the free space on the drive?'
MSG_INPUT_ROOT_SIZE_SET: str = 'Please specify the size (in GB) of the root partition (min is 1.5 GB)?'
MSG_INPUT_CONSOLE_TYPE: str = 'What console should be used by default? (K: KVM, S: Serial)?'
Expand Down Expand Up @@ -783,15 +783,15 @@ def install_image() -> None:
user_password: str = ask_input(MSG_INPUT_PASSWORD, no_echo=True,
non_empty=True)
check_result = check_passwd_strength(user_password)
print(check_result['strength'])

confirm: str = ask_input(MSG_INPUT_PASSWORD_CONFIRM, no_echo=True,
non_empty=True)
print('Password Strength: {}'.format(check_result['strength']))

if len(user_password) < 4:
print(MSG_WARN_PASSWORD_TOO_SHORT)
continue

confirm: str = ask_input(MSG_INPUT_PASSWORD_CONFIRM, no_echo=True,
non_empty=True)

passwd_weak = check_result['strength'] not in ['Strong', 'Very Strong']

if user_password == confirm:
Expand Down

0 comments on commit e59c6e8

Please sign in to comment.