Make paramiko password detection logic match ssh connection
This commit is contained in:
parent
3d77723e3d
commit
2c98b271c8
1 changed files with 21 additions and 19 deletions
|
@ -224,25 +224,27 @@ class Connection(ConnectionBase):
|
||||||
try:
|
try:
|
||||||
chan.exec_command(cmd)
|
chan.exec_command(cmd)
|
||||||
if self._connection_info.prompt:
|
if self._connection_info.prompt:
|
||||||
while True:
|
if self._connection_info.become and self._connection_info.become_pass:
|
||||||
debug('Waiting for Privilege Escalation input')
|
while True:
|
||||||
if self.check_become_success(become_output) or self.check_password_prompt(become_output):
|
debug('Waiting for Privilege Escalation input')
|
||||||
break
|
if self.check_become_success(become_output) or self.check_password_prompt(become_output):
|
||||||
chunk = chan.recv(bufsize)
|
break
|
||||||
if not chunk:
|
chunk = chan.recv(bufsize)
|
||||||
if 'unknown user' in become_output:
|
print("chunk is: %s" % chunk)
|
||||||
raise AnsibleError(
|
if not chunk:
|
||||||
'user %s does not exist' % become_user)
|
if 'unknown user' in become_output:
|
||||||
else:
|
raise AnsibleError(
|
||||||
raise AnsibleError('ssh connection ' +
|
'user %s does not exist' % become_user)
|
||||||
'closed waiting for password prompt')
|
else:
|
||||||
become_output += chunk
|
raise AnsibleError('ssh connection ' +
|
||||||
if not self.check_become_success(become_output):
|
'closed waiting for password prompt')
|
||||||
if self._connection_info.become:
|
become_output += chunk
|
||||||
chan.sendall(self._connection_info.become_pass + '\n')
|
if not self.check_become_success(become_output):
|
||||||
else:
|
if self._connection_info.become:
|
||||||
no_prompt_out += become_output
|
chan.sendall(self._connection_info.become_pass + '\n')
|
||||||
no_prompt_err += become_output
|
else:
|
||||||
|
no_prompt_out += become_output
|
||||||
|
no_prompt_err += become_output
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
raise AnsibleError('ssh timed out waiting for privilege escalation.\n' + become_output)
|
raise AnsibleError('ssh timed out waiting for privilege escalation.\n' + become_output)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue