diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-10-06 08:22:08 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2011-10-06 08:28:15 +0200 |
commit | 185ca8f6fc5e69e989e473c8b1d066aa2d8e5cb1 (patch) | |
tree | 5e74685f51c038463b24e9de7fe231fd84fc5c3e /ipaserver/install | |
parent | 7d5106de976140e8425152a83a300be9dc49372a (diff) | |
download | freeipa-185ca8f6fc5e69e989e473c8b1d066aa2d8e5cb1.tar.gz freeipa-185ca8f6fc5e69e989e473c8b1d066aa2d8e5cb1.tar.xz freeipa-185ca8f6fc5e69e989e473c8b1d066aa2d8e5cb1.zip |
Install tools crash when password prompt is interrupted
When getpass.getpass() function is interrupted via CTRL+D, EOFError
exception is thrown. Most of the install tools are not prepared for
this event and crash with this exception. Make sure that it is
handled properly and nice error message is printed.
https://fedorahosted.org/freeipa/ticket/1916
Diffstat (limited to 'ipaserver/install')
-rw-r--r-- | ipaserver/install/installutils.py | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 6ae117cb4..b3ee7e991 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -319,30 +319,33 @@ def _read_password_default_validator(password): def read_password(user, confirm=True, validate=True, retry=True, validator=_read_password_default_validator): correct = False - pwd = "" - while not correct: - if not retry: - correct = True - pwd = get_password(user + " password: ") - if not pwd: - continue - if validate: - try: - validator(pwd) - except ValueError, e: - print str(e) - pwd = "" + pwd = None + try: + while not correct: + if not retry: + correct = True + pwd = get_password(user + " password: ") + if not pwd: continue - if not confirm: - correct = True - continue - pwd_confirm = get_password("Password (confirm): ") - if pwd != pwd_confirm: - print "Password mismatch!" - print "" - pwd = "" - else: - correct = True + if validate: + try: + validator(pwd) + except ValueError, e: + print str(e) + pwd = None + continue + if not confirm: + correct = True + continue + pwd_confirm = get_password("Password (confirm): ") + if pwd != pwd_confirm: + print "Password mismatch!" + print "" + pwd = None + else: + correct = True + except EOFError: + return None print "" return pwd |