ssh: propagate prompt to _communicate()

_communicate() uses the prompt variable to detect wrong passwords early,
therefore it needs to be passed to it from exec_command().
pull/6787/head
Till Maas 11 years ago
parent 225eca6311
commit 2cae7472ad

@ -258,6 +258,7 @@ class Connection(object):
sudocmd, prompt, success_key = utils.make_su_cmd(su_user, executable, cmd) sudocmd, prompt, success_key = utils.make_su_cmd(su_user, executable, cmd)
ssh_cmd.append(sudocmd) ssh_cmd.append(sudocmd)
elif not self.runner.sudo or not sudoable: elif not self.runner.sudo or not sudoable:
prompt = None
if executable: if executable:
ssh_cmd.append(executable + ' -c ' + pipes.quote(cmd)) ssh_cmd.append(executable + ' -c ' + pipes.quote(cmd))
else: else:
@ -327,7 +328,7 @@ class Connection(object):
elif su: elif su:
stdin.write(self.runner.su_pass + '\n') stdin.write(self.runner.su_pass + '\n')
(returncode, stdout, stderr) = self._communicate(p, stdin, in_data, su=su, sudoable=sudoable) (returncode, stdout, stderr) = self._communicate(p, stdin, in_data, su=su, sudoable=sudoable, prompt=prompt)
if C.HOST_KEY_CHECKING and not_in_host_file: if C.HOST_KEY_CHECKING and not_in_host_file:
# lock around the initial SSH connectivity so the user prompt about whether to add # lock around the initial SSH connectivity so the user prompt about whether to add

Loading…
Cancel
Save