Skip to content

Commit

Permalink
util/ssh: explicitly pass /dev/null for stdin
Browse files Browse the repository at this point in the history
This avoids a problem where SSH tries to interact with the terminal,
which shouldn't happen here.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information
jluebbe committed Nov 11, 2018
1 parent 1904b81 commit bece7ac
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions labgrid/util/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def _run_socket_command(self, command, forward=None):
complete_cmd.append(self.host)
res = subprocess.check_call(
complete_cmd,
timeout=2
stdin=subprocess.DEVNULL,
timeout=2,
)

return res
Expand Down Expand Up @@ -201,7 +202,8 @@ def run_command(self, command):
complete_cmd = ["ssh"] + self._get_ssh_args()
complete_cmd += [self.host, command]
res = subprocess.check_call(
complete_cmd
complete_cmd,
stdin=subprocess.DEVNULL,
)

return res
Expand All @@ -214,7 +216,10 @@ def get_file(self, remote_file, local_file):
"{}:{}".format(self.host, remote_file),
"{}".format(local_file)
]
subprocess.check_call(complete_cmd)
subprocess.check_call(
complete_cmd,
stdin=subprocess.DEVNULL,
)

@_check_connected
def put_file(self, local_file, remote_path):
Expand All @@ -224,7 +229,10 @@ def put_file(self, local_file, remote_path):
"{}".format(local_file),
"{}:{}".format(self.host, remote_path)
]
subprocess.check_call(complete_cmd)
subprocess.check_call(
complete_cmd,
stdin=subprocess.DEVNULL,
)

@_check_connected
def add_port_forward(self, remote_host, remote_port):
Expand Down Expand Up @@ -280,9 +288,9 @@ def _check_external_master(self):
# capture and parse it.
proc = subprocess.Popen(
args,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
)
stdout, _ = proc.communicate(timeout=60)
check = proc.wait(args)
Expand Down Expand Up @@ -314,9 +322,9 @@ def _start_own_master(self):
assert self._master is None
self._master = subprocess.Popen(
args,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
)

try:
Expand Down Expand Up @@ -361,9 +369,9 @@ def _start_keepalive(self):
assert self._keepalive is None
self._keepalive = subprocess.Popen(
args,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)

self._logger.debug('Started keepalive for %s', self.host)
Expand Down

0 comments on commit bece7ac

Please sign in to comment.