diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2025-03-18 17:21:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-18 17:21:08 +0200 |
| commit | 0af5728700b0b5da30e7713a4596aeadaf537b49 (patch) | |
| tree | b5422af7268dac20dda715b5b13fb1b7488b0502 /src/op_mode | |
| parent | 95af91597c94856a38722daa5ea388646f9b735f (diff) | |
| parent | 93f02429533fdaa0b520779a82c992f6e3d43466 (diff) | |
| download | vyos-1x-0af5728700b0b5da30e7713a4596aeadaf537b49.tar.gz vyos-1x-0af5728700b0b5da30e7713a4596aeadaf537b49.zip | |
Merge pull request #4390 from oniko94/feature/T6353-add-password-complexity-validation
T6353: Add password complexity validation for system login user
Diffstat (limited to 'src/op_mode')
| -rwxr-xr-x | src/op_mode/image_installer.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py index 609b0b347..c6e9c7f6f 100755 --- a/src/op_mode/image_installer.py +++ b/src/op_mode/image_installer.py @@ -32,10 +32,16 @@ from errno import ENOSPC from psutil import disk_partitions +from vyos.base import Warning from vyos.configtree import ConfigTree 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 ( + DEFAULT_PASSWORD, + EPasswdStrength, + evaluate_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 @@ -83,6 +89,9 @@ MSG_WARN_ROOT_SIZE_TOOBIG: str = 'The size is too big. Try again.' MSG_WARN_ROOT_SIZE_TOOSMALL: str = 'The size is too small. Try again' MSG_WARN_IMAGE_NAME_WRONG: str = 'The suggested name is unsupported!\n'\ 'It must be between 1 and 64 characters long and contains only the next characters: .+-_ a-z A-Z 0-9' + +MSG_WARN_CHANGE_PASSWORD: str = 'Default password used. Consider changing ' \ + 'it on next login.' MSG_WARN_PASSWORD_CONFIRM: str = 'The entered values did not match. Try again' 'Installing a different image flavor may cause functionality degradation or break your system.\n' \ 'Do you want to continue with installation?' @@ -778,10 +787,20 @@ def install_image() -> None: while True: user_password: str = ask_input(MSG_INPUT_PASSWORD, no_echo=True, non_empty=True) + + if user_password == DEFAULT_PASSWORD: + Warning(MSG_WARN_CHANGE_PASSWORD) + else: + result = evaluate_strength(user_password) + if result['strength'] == EPasswdStrength.WEAK: + Warning(result['error']) + confirm: str = ask_input(MSG_INPUT_PASSWORD_CONFIRM, no_echo=True, non_empty=True) + if user_password == confirm: break + print(MSG_WARN_PASSWORD_CONFIRM) # ask for default console |
