diff options
author | Devaev Maxim <[email protected]> | 2019-02-10 04:55:25 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-02-10 04:55:25 +0300 |
commit | ca90f39687cd147979e05901db21031892f6d96a (patch) | |
tree | 27371b9e2f045400cee155f944260377a82c0a71 /kvmd | |
parent | 06a0b77e35fca35ae3554e3dafba0838b23e91b8 (diff) |
htpasswd: create tmp file before password asking
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/htpasswd/__init__.py | 12 |
1 files changed, 6 insertions, 6 deletions
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) |