diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-07-30 13:07:18 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-08-06 10:34:26 +0200 |
commit | fb08402b718b3e05fa11031f04237eaa12ce4f85 (patch) | |
tree | 56d94df07e8fca38fedad6270c143f7d361d0cfa /ipaserver/install/installutils.py | |
parent | f954f2d1b92db10113b766759897d66c57e1e3ab (diff) | |
download | freeipa-fb08402b718b3e05fa11031f04237eaa12ce4f85.tar.gz freeipa-fb08402b718b3e05fa11031f04237eaa12ce4f85.tar.xz freeipa-fb08402b718b3e05fa11031f04237eaa12ce4f85.zip |
Fix installutils.get_password without a TTY
If stdin is a TTY, ipaserver.install.installutils uses getpass and all
is well. Without a TTY, though, there were two problems:
* The prompt was not printed
* On end of file, an empty string was returned, which caused read_password
to enter an infinite loop.
Fix both problems.
https://fedorahosted.org/freeipa/ticket/3824
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r-- | ipaserver/install/installutils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 6a6841a11..d17d53d1d 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -256,7 +256,13 @@ def get_password(prompt): if os.isatty(sys.stdin.fileno()): return getpass.getpass(prompt) else: - return sys.stdin.readline().rstrip() + sys.stdout.write(prompt) + sys.stdout.flush() + line = sys.stdin.readline() + if not line: + raise EOFError() + return line.rstrip() + def _read_password_default_validator(password): if len(password) < 8: |