mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
win_script: work when argument exceeds stdin buffer size (#33855)
* win_script: work when argument exceeds stdin buffer size * Added test for large argument being passed
This commit is contained in:
parent
e6d01ff7e3
commit
f0134079e3
3 changed files with 46 additions and 24 deletions
|
@ -391,8 +391,6 @@ class Connection(ConnectionBase):
|
|||
stdin_push_failed = False
|
||||
command_id = self.protocol.run_command(self.shell_id, to_bytes(command), map(to_bytes, args), console_mode_stdin=(stdin_iterator is None))
|
||||
|
||||
# TODO: try/except around this, so we can get/return the command result on a broken pipe or other failure (probably more useful than the 500 that
|
||||
# comes from this)
|
||||
try:
|
||||
if stdin_iterator:
|
||||
for (data, is_last) in stdin_iterator:
|
||||
|
@ -400,12 +398,9 @@ class Connection(ConnectionBase):
|
|||
|
||||
except Exception as ex:
|
||||
from traceback import format_exc
|
||||
display.warning("FATAL ERROR DURING FILE TRANSFER: %s" % format_exc())
|
||||
display.warning("FATAL ERROR DURING FILE TRANSFER: %s" % to_text(ex))
|
||||
stdin_push_failed = True
|
||||
|
||||
if stdin_push_failed:
|
||||
raise AnsibleError('winrm send_input failed')
|
||||
|
||||
# NB: this can hang if the receiver is still running (eg, network failed a Send request but the server's still happy).
|
||||
# FUTURE: Consider adding pywinrm status check/abort operations to see if the target is still running after a failure.
|
||||
resptuple = self.protocol.get_command_output(self.shell_id, command_id)
|
||||
|
@ -423,7 +418,11 @@ class Connection(ConnectionBase):
|
|||
display.vvvvvv('WINRM STDERR %s' % to_text(response.std_err), host=self._winrm_host)
|
||||
|
||||
if stdin_push_failed:
|
||||
raise AnsibleError('winrm send_input failed; \nstdout: %s\nstderr %s' % (response.std_out, response.std_err))
|
||||
stderr = to_bytes(response.std_err, encoding='utf-8')
|
||||
if self.is_clixml(stderr):
|
||||
stderr = self.parse_clixml_stream(stderr)
|
||||
|
||||
raise AnsibleError('winrm send_input failed; \nstdout: %s\nstderr %s' % (response.std_out, stderr))
|
||||
|
||||
return response
|
||||
finally:
|
||||
|
@ -456,7 +455,9 @@ class Connection(ConnectionBase):
|
|||
'powershell_modules': {},
|
||||
'actions': ['exec'],
|
||||
'exec': to_text(base64.b64encode(to_bytes(leaf_exec))),
|
||||
'environment': environment
|
||||
'environment': environment,
|
||||
'min_ps_version': None,
|
||||
'min_os_version': None
|
||||
}
|
||||
|
||||
return json.dumps(payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue