Commit 2303044f by Will Thames

Applied fix for sudo with no prompt to paramiko

Effectively reproduces @sivel's work from #8900 but for
the paramiko connection. Fixes #8418 when using paramiko

This allows `_remote_md5` to work if a sudo password is
passed in when no sudo password is required.
parent de77f337
...@@ -204,6 +204,8 @@ class Connection(object): ...@@ -204,6 +204,8 @@ class Connection(object):
msg += ": %s" % str(e) msg += ": %s" % str(e)
raise errors.AnsibleConnectionFailed(msg) raise errors.AnsibleConnectionFailed(msg)
no_prompt_out = ''
no_prompt_err = ''
if not (self.runner.sudo and sudoable) and not (self.runner.su and su): if not (self.runner.sudo and sudoable) and not (self.runner.su and su):
if executable: if executable:
...@@ -259,6 +261,9 @@ class Connection(object): ...@@ -259,6 +261,9 @@ class Connection(object):
chan.sendall(self.runner.sudo_pass + '\n') chan.sendall(self.runner.sudo_pass + '\n')
elif su: elif su:
chan.sendall(self.runner.su_pass + '\n') chan.sendall(self.runner.su_pass + '\n')
else:
no_prompt_out += sudo_output
no_prompt_err += sudo_output
except socket.timeout: except socket.timeout:
...@@ -267,7 +272,7 @@ class Connection(object): ...@@ -267,7 +272,7 @@ class Connection(object):
stdout = ''.join(chan.makefile('rb', bufsize)) stdout = ''.join(chan.makefile('rb', bufsize))
stderr = ''.join(chan.makefile_stderr('rb', bufsize)) stderr = ''.join(chan.makefile_stderr('rb', bufsize))
return (chan.recv_exit_status(), '', stdout, stderr) return (chan.recv_exit_status(), '', no_prompt_out + stdout, no_prompt_out + stderr)
def put_file(self, in_path, out_path): def put_file(self, in_path, out_path):
''' transfer a file from local to remote ''' ''' transfer a file from local to remote '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment