diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-05-11 16:27:28 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-05-11 16:27:55 +0100 |
commit | bcd2b2fdf90bccd29c281f8143bc9ba73edda01d (patch) | |
tree | 0a8f9d8381e83ead69e27c7263cd562ad62971f2 /pykolab/utils.py | |
parent | 43cb3e58da39fd7c7566d952691d815488104dd6 (diff) | |
download | pykolab-bcd2b2fdf90bccd29c281f8143bc9ba73edda01d.tar.gz |
Do not echo passwords back even during confirmation
Diffstat (limited to 'pykolab/utils.py')
-rw-r--r-- | pykolab/utils.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py index 6326bf8..325446f 100644 --- a/pykolab/utils.py +++ b/pykolab/utils.py @@ -46,23 +46,37 @@ def ask_question(question, default="", password=False, confirm=False): else: answer = raw_input("%s [%s]: " % (question, default)) - if not answer == "" and not default == "": + if not answer == "": if confirm: answer_confirm = None answer_confirmed = False while not answer_confirmed: - if default == "": - answer_confirm = raw_input("Confirm %s: " % (question)) + if password: + if default == "": + answer = getpass.getpass(_("Confirm %s: ") % (question)) + else: + answer = getpass.getpass(_("Confirm %s [%s]: ") % (question, default)) else: - answer_confirm = raw_input("Confirm %s [%s]: " % (question, default)) + if default == "": + answer = raw_input(_("Confirm %s: ") % (question)) + else: + answer = raw_input(_("Confirm %s [%s]: ") % (question, default)) if not answer_confirm == answer: print >> sys.stderr, _("Incorrect confirmation. " + \ "Please try again.") - if default == "": - answer = raw_input("%s: " % (question)) + + if password: + if default == "": + answer = getpass.getpass(_("Confirm %s: ") % (question)) + else: + answer = getpass.getpass(_("Confirm %s [%s]: ") % (question, default)) else: - answer = raw_input("%s [%s]: " % (question, default)) + if default == "": + answer = raw_input(_("Confirm %s: ") % (question)) + else: + answer = raw_input(_("Confirm %s [%s]: ") % (question, default)) + else: answer_confirmed = True |