diff options
author | Rob Crittenden <rcritten@redhat.com> | 2011-08-24 18:10:22 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-08-24 15:25:53 -0400 |
commit | 1936b8050e5ee7861996f370d2171b751f18c1fb (patch) | |
tree | a9b63ae4a4a3a388223ebdeb9cd09f683a018fec /ipalib/cli.py | |
parent | 41d89d0d13d25943b7ac084adb58d112557033ca (diff) | |
download | freeipa-1936b8050e5ee7861996f370d2171b751f18c1fb.tar.gz freeipa-1936b8050e5ee7861996f370d2171b751f18c1fb.tar.xz freeipa-1936b8050e5ee7861996f370d2171b751f18c1fb.zip |
Add option to only prompt once for passwords, use in entitle_register
A Password param always prompted to confirm the entered password.
This doesn't make sense if you want to prompt for a password to another
system like we do with entitlements. This adds a new boolean option to
control the Password prompt parameter.
https://fedorahosted.org/freeipa/ticket/1695
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r-- | ipalib/cli.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 5e1365dc..536fe2ec 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -536,7 +536,7 @@ class textui(backend.Backend): If Default parameter is not None, user can enter an empty input instead of Yes/No answer. Value passed to Default is returned in that case. - + If Default parameter is None, user is asked for Yes/No answer until a correct answer is provided. Answer is then returned. @@ -568,7 +568,7 @@ class textui(backend.Backend): elif default is not None and data == u'': return default - def prompt_password(self, label): + def prompt_password(self, label, confirm=True): """ Prompt user for a password or read it in via stdin depending on whether there is a tty or not. @@ -577,6 +577,8 @@ class textui(backend.Backend): if sys.stdin.isatty(): while True: pw1 = getpass.getpass(u'%s: ' % unicode(label)) + if not confirm: + return self.decode(pw1) pw2 = getpass.getpass( unicode(_('Enter %(label)s again to verify: ') % dict(label=label)) ) @@ -1050,7 +1052,7 @@ class cli(backend.Executioner): (param.alwaysask and honor_alwaysask) or self.env.prompt_all: if param.password: kw[param.name] = self.Backend.textui.prompt_password( - param.label + param.label, param.confirm ) elif param.autofill: kw[param.name] = param.get_default(**kw) @@ -1070,7 +1072,7 @@ class cli(backend.Executioner): error = e.error elif param.password and kw.get(param.name, False) is True: kw[param.name] = self.Backend.textui.prompt_password( - param.label + param.label, param.confirm ) for callback in getattr(cmd, 'INTERACTIVE_PROMPT_CALLBACKS', []): |