fine tuned password handling as we were getting false positives, probably caused by other changes up the stack that now call these functions in more cases.

This commit is contained in:
Brian Coca 2015-08-07 16:26:23 -04:00
commit dbab703265
2 changed files with 28 additions and 10 deletions

View file

@ -371,11 +371,19 @@ class Connection(ConnectionBase):
become_output = ''
become_errput = ''
passprompt = False
while True:
self._display.debug('Waiting for Privilege Escalation input')
if self.check_become_success(become_output + become_errput) or self.check_password_prompt(become_output + become_errput):
if self.check_become_success(become_output + become_errput):
self._display.debug('Succeded!')
break
elif self.check_password_prompt(become_output) or self.check_password_prompt(become_errput):
self._display.debug('Password prompt!')
passprompt = True
break
self._display.debug('Read next chunks')
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout], self._play_context.timeout)
if not rfd:
# timeout. wrap up process communication
@ -385,16 +393,20 @@ class Connection(ConnectionBase):
elif p.stderr in rfd:
chunk = p.stderr.read()
become_errput += chunk
self._display.debug('stderr chunk is: %s' % chunk)
self.check_incorrect_password(become_errput)
elif p.stdout in rfd:
chunk = p.stdout.read()
become_output += chunk
self._display.debug('stdout chunk is: %s' % chunk)
if not chunk:
raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output)
break
#raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output)
if not self.check_become_success(become_output + become_errput):
if passprompt:
self._display.debug("Sending privilege escalation password.")
stdin.write(self._play_context.become_pass + '\n')
else: