Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
#2902 show stderr of ssh subprocess on windows
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@27678 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaamwin32 committed Oct 16, 2020
1 parent ac6bc36 commit b10c231
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/xpra/net/ssh.py
Expand Up @@ -15,6 +15,7 @@
from xpra.platform import get_username
from xpra.scripts.config import parse_bool
from xpra.net.bytestreams import SocketConnection, SOCKET_TIMEOUT, ConnectionClosedException
from xpra.make_thread import start_thread
from xpra.exit_codes import (
EXIT_SSH_KEY_FAILURE, EXIT_SSH_FAILURE,
EXIT_CONNECTION_FAILED,
Expand Down Expand Up @@ -154,7 +155,6 @@ def __init__(self, ssh_channel, sock, sockname, peername, target, info=None, soc
self._raw_socket = sock

def start_stderr_reader(self):
from xpra.make_thread import start_thread
start_thread(self._stderr_reader, "ssh-stderr-reader", daemon=True)

def _stderr_reader(self):
Expand All @@ -166,8 +166,10 @@ def _stderr_reader(self):
v = stderr.readline()
if not v:
log("SSH EOF on stderr of %s", chan.get_name())
return
errs.append(bytestostr(v.rstrip(b"\n\r")))
break
s = bytestostr(v.rstrip(b"\n\r"))
if s:
errs.append(s)
if errs:
log.warn("remote SSH stderr:")
for e in errs:
Expand Down Expand Up @@ -964,4 +966,20 @@ def stop_tunnel():
conn.endpoint = host_target_string("ssh", username, host, port, display)
conn.timeout = 0 #taken care of by abort_test
conn.process = (child, "ssh", cmd)
if kwargs.get("stderr")==PIPE:
def stderr_reader():
errs = []
while not abort_test():
v = child.stderr.readline()
if not v:
log("SSH EOF on stderr of %s", cmd)
break
s = bytestostr(v.rstrip(b"\n\r"))
if s:
errs.append(s)
if errs:
log.warn("remote SSH stderr:")
for e in errs:
log.warn(" %s", e)
start_thread(stderr_reader, "ssh-stderr-reader", daemon=True)
return conn

0 comments on commit b10c231

Please sign in to comment.