From ca90f39687cd147979e05901db21031892f6d96a Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sun, 10 Feb 2019 04:55:25 +0300 Subject: htpasswd: create tmp file before password asking --- kvmd/apps/htpasswd/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'kvmd/apps') diff --git a/kvmd/apps/htpasswd/__init__.py b/kvmd/apps/htpasswd/__init__.py index b325262a..c39243fe 100644 --- a/kvmd/apps/htpasswd/__init__.py +++ b/kvmd/apps/htpasswd/__init__.py @@ -55,13 +55,13 @@ def _cmd_list(config: Section, _: argparse.Namespace) -> None: def _cmd_set(config: Section, options: argparse.Namespace) -> None: - if options.read_stdin: - passwd = input() - else: - passwd = getpass.getpass("Password: ", stream=sys.stderr) - if getpass.getpass("Repeat: ", stream=sys.stderr) != passwd: - raise SystemExit("Sorry, passwords do not match") with _get_htpasswd_for_write(config) as htpasswd: + if options.read_stdin: + passwd = input() + else: + passwd = getpass.getpass("Password: ", stream=sys.stderr) + if getpass.getpass("Repeat: ", stream=sys.stderr) != passwd: + raise SystemExit("Sorry, passwords do not match") htpasswd.set_password(options.user, passwd) -- cgit v1.2.3