|
|
@ -378,54 +378,53 @@ class Connection(ConnectionBase):
|
|
|
|
|
|
|
|
|
|
|
|
self._display.debug("Handling privilege escalation password prompt.")
|
|
|
|
self._display.debug("Handling privilege escalation password prompt.")
|
|
|
|
|
|
|
|
|
|
|
|
if self._play_context.become and self._play_context.become_pass:
|
|
|
|
|
|
|
|
|
|
|
|
fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
|
|
|
|
fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
|
|
|
|
fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
|
|
|
|
fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
|
|
|
|
|
|
|
|
|
|
|
|
become_output = ''
|
|
|
|
become_output = ''
|
|
|
|
become_errput = ''
|
|
|
|
become_errput = ''
|
|
|
|
passprompt = False
|
|
|
|
passprompt = False
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
self._display.debug('Waiting for Privilege Escalation input')
|
|
|
|
self._display.debug('Waiting for Privilege Escalation input')
|
|
|
|
|
|
|
|
|
|
|
|
if self.check_become_success(become_output + become_errput):
|
|
|
|
if self.check_become_success(become_output + become_errput):
|
|
|
|
self._display.debug('Succeded!')
|
|
|
|
self._display.debug('Succeded!')
|
|
|
|
break
|
|
|
|
break
|
|
|
|
elif self.check_password_prompt(become_output) or self.check_password_prompt(become_errput):
|
|
|
|
elif self.check_password_prompt(become_output) or self.check_password_prompt(become_errput):
|
|
|
|
self._display.debug('Password prompt!')
|
|
|
|
self._display.debug('Password prompt!')
|
|
|
|
passprompt = True
|
|
|
|
passprompt = True
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
self._display.debug('Read next chunks')
|
|
|
|
self._display.debug('Read next chunks')
|
|
|
|
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout], self._play_context.timeout)
|
|
|
|
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout], self._play_context.timeout)
|
|
|
|
if not rfd:
|
|
|
|
if not rfd:
|
|
|
|
# timeout. wrap up process communication
|
|
|
|
# timeout. wrap up process communication
|
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
raise AnsibleError('Connection error waiting for privilege escalation password prompt: %s' % become_output)
|
|
|
|
raise AnsibleError('Connection error waiting for privilege escalation password prompt: %s' % become_output)
|
|
|
|
|
|
|
|
|
|
|
|
elif p.stderr in rfd:
|
|
|
|
elif p.stderr in rfd:
|
|
|
|
chunk = p.stderr.read()
|
|
|
|
chunk = p.stderr.read()
|
|
|
|
become_errput += chunk
|
|
|
|
become_errput += chunk
|
|
|
|
self._display.debug('stderr chunk is: %s' % chunk)
|
|
|
|
self._display.debug('stderr chunk is: %s' % chunk)
|
|
|
|
self.check_incorrect_password(become_errput)
|
|
|
|
self.check_incorrect_password(become_errput)
|
|
|
|
|
|
|
|
|
|
|
|
elif p.stdout in rfd:
|
|
|
|
elif p.stdout in rfd:
|
|
|
|
chunk = p.stdout.read()
|
|
|
|
chunk = p.stdout.read()
|
|
|
|
become_output += chunk
|
|
|
|
become_output += chunk
|
|
|
|
self._display.debug('stdout chunk is: %s' % chunk)
|
|
|
|
self._display.debug('stdout chunk is: %s' % chunk)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not chunk:
|
|
|
|
if not chunk:
|
|
|
|
break
|
|
|
|
break
|
|
|
|
#raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output)
|
|
|
|
#raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output)
|
|
|
|
|
|
|
|
|
|
|
|
if passprompt:
|
|
|
|
if passprompt:
|
|
|
|
self._display.debug("Sending privilege escalation password.")
|
|
|
|
self._display.debug("Sending privilege escalation password.")
|
|
|
|
stdin.write(self._play_context.become_pass + '\n')
|
|
|
|
stdin.write(self._play_context.become_pass + '\n')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
no_prompt_out = become_output
|
|
|
|
no_prompt_out = become_output
|
|
|
|
no_prompt_err = become_errput
|
|
|
|
no_prompt_err = become_errput
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(returncode, stdout, stderr) = self._communicate(p, stdin, in_data, sudoable=sudoable)
|
|
|
|
(returncode, stdout, stderr) = self._communicate(p, stdin, in_data, sudoable=sudoable)
|
|
|
|