diff options
author | Abhijit Menon-Sen <ams@2ndQuadrant.com> | 2015-11-25 21:07:17 +0530 |
---|---|---|
committer | Abhijit Menon-Sen <ams@2ndQuadrant.com> | 2015-11-26 06:06:01 +0530 |
commit | f20e2630b0c20507acc5105e1d6394ab3f742750 (patch) | |
tree | 20cd17fd14b8f36679303e43f6cb8e70c46bb848 /lib/ansible | |
parent | 157230c3e83731eef1318c4b63373bc1e3c6aac3 (diff) | |
download | ansible-f20e2630b0c20507acc5105e1d6394ab3f742750.tar.gz |
Explicitly accept become_success in awaiting_prompt state
If we request escalation with a password, we start in expecting_prompt
state. If the escalation then succeeds without the password, i.e., the
become_success response arrives, we must explicitly move into the next
state (awaiting_escalation, which immediately goes into ready_to_send),
so that we no longer try to apply the timeout.
Otherwise, we would leak the success notification and eventually
timeout. But if the module response did arrive before the timeout
expired, the "process has already exited" test would do the right
thing by accident (which is why it didn't fail more often).
Fixes #13289
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/plugins/connection/ssh.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index d3a8877b60..debe36bd32 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -457,12 +457,17 @@ class Connection(ConnectionBase): tmp_stdout = tmp_stderr = '' # If we see a privilege escalation prompt, we send the password. + # (If we're expecting a prompt but the escalation succeeds, we + # didn't need the password and can carry on regardless.) - if states[state] == 'awaiting_prompt' and self._flags['become_prompt']: - display.debug('Sending become_pass in response to prompt') - stdin.write(self._play_context.become_pass + '\n') - self._flags['become_prompt'] = False - state += 1 + if states[state] == 'awaiting_prompt': + if self._flags['become_prompt']: + display.debug('Sending become_pass in response to prompt') + stdin.write(self._play_context.become_pass + '\n') + self._flags['become_prompt'] = False + state += 1 + elif self._flags['become_success']: + state += 1 # We've requested escalation (with or without a password), now we # wait for an error message or a successful escalation. |