Ignore broken pipe errors if the sshpass process has exited (#16515)
This fix prevents a broken pipe exception from occurring when password-less SSH is configured and the sshpass process exits and closes the pipe before the password is written to the pipe.
This commit is contained in:
parent
b3ca0c02c5
commit
9b7d782abb
1 changed files with 7 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import errno
|
||||
import fcntl
|
||||
import os
|
||||
import pipes
|
||||
|
@ -346,7 +347,12 @@ class Connection(ConnectionBase):
|
|||
|
||||
if self._play_context.password:
|
||||
os.close(self.sshpass_pipe[0])
|
||||
os.write(self.sshpass_pipe[1], "{0}\n".format(to_bytes(self._play_context.password)))
|
||||
try:
|
||||
os.write(self.sshpass_pipe[1], "{0}\n".format(to_bytes(self._play_context.password)))
|
||||
except OSError as e:
|
||||
# Ignore broken pipe errors if the sshpass process has exited.
|
||||
if e.errno != errno.EPIPE or p.poll() is None:
|
||||
raise
|
||||
os.close(self.sshpass_pipe[1])
|
||||
|
||||
## SSH state machine
|
||||
|
|
Loading…
Reference in a new issue