Stop displaying kinit pass input on a failure (#41882)

* Stop displaying kinit pass input on a failure

* Fixed up minor logic info and added tests
This commit is contained in:
Jordan Borean 2018-06-26 05:49:19 +10:00 committed by GitHub
commit 9b7b564d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 2 deletions

View file

@ -294,7 +294,7 @@ class Connection(ConnectionBase):
% principal)
try:
child = pexpect.spawn(command, kinit_cmdline, timeout=60,
env=krb5env)
env=krb5env, echo=False)
except pexpect.ExceptionPexpect as err:
err_msg = "Kerberos auth failure when calling kinit cmd " \
"'%s': %s" % (command, to_native(err))
@ -336,8 +336,13 @@ class Connection(ConnectionBase):
rc = p.returncode != 0
if rc != 0:
# one last attempt at making sure the password does not exist
# in the output
exp_msg = to_native(stderr.strip())
exp_msg = exp_msg.replace(to_native(password), "<redacted>")
err_msg = "Kerberos auth failure for principal %s with %s: %s" \
% (principal, proc_mechanism, to_native(stderr.strip()))
% (principal, proc_mechanism, exp_msg)
raise AnsibleConnectionFailure(err_msg)
display.vvvvv("kinit succeeded for principal %s" % principal)