diff options
author | John Estabrook <jestabro@vyos.io> | 2023-12-12 12:42:40 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-12-12 12:44:53 -0600 |
commit | cf83979636c686a459d6dc75dcd98e342c70b1b3 (patch) | |
tree | 681bbfaaa94a6d01f738c1d360fd3ea8a35c2447 | |
parent | 138fe52743703aa771f388da026816c671e7d25b (diff) | |
download | vyos-1x-cf83979636c686a459d6dc75dcd98e342c70b1b3.tar.gz vyos-1x-cf83979636c686a459d6dc75dcd98e342c70b1b3.zip |
image-tools: T5819: do not echo password on image install
-rw-r--r-- | python/vyos/utils/io.py | 9 | ||||
-rwxr-xr-x | src/op_mode/image_installer.py | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py index 74099b502..0afaf695c 100644 --- a/python/vyos/utils/io.py +++ b/python/vyos/utils/io.py @@ -26,13 +26,18 @@ def print_error(str='', end='\n'): sys.stderr.write(end) sys.stderr.flush() -def ask_input(question, default='', numeric_only=False, valid_responses=[]): +def ask_input(question, default='', numeric_only=False, valid_responses=[], + no_echo=False): + from getpass import getpass question_out = question if default: question_out += f' (Default: {default})' response = '' while True: - response = input(question_out + ' ').strip() + if not no_echo: + response = input(question_out + ' ').strip() + else: + response = getpass(question_out + ' ').strip() if not response and default: return default if numeric_only: diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py index b3e6e518c..9452c5e28 100755 --- a/src/op_mode/image_installer.py +++ b/src/op_mode/image_installer.py @@ -611,7 +611,8 @@ def install_image() -> None: print(MSG_WARN_IMAGE_NAME_WRONG) # ask for password - user_password: str = ask_input(MSG_INPUT_PASSWORD, default='vyos') + user_password: str = ask_input(MSG_INPUT_PASSWORD, default='vyos', + no_echo=True) # ask for default console console_type: str = ask_input(MSG_INPUT_CONSOLE_TYPE, |