mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-25 01:13:37 +01:00
Print to console with \r\n line endings.
If we run sudo with the use_pty option, the firewall process is started in a new pseudoterminal. Other processes that are still printing to the terminal (i.e., the main sshuttle client process, messages from the shuttle server) have their output incorreclty displayed. A newline character simply moves the output to the next line without returning the cursor to the beginning of the line. Simply changing all print commands to use \r\n line endings fixes the problem and does not appear to cause any trouble in other configurations.
This commit is contained in:
parent
286bd3fa80
commit
8e826cfa7d
@ -18,7 +18,7 @@ while 1:
|
||||
name = name.decode("ASCII")
|
||||
nbytes = int(sys.stdin.readline())
|
||||
if verbosity >= 2:
|
||||
sys.stderr.write(' s: assembling %r (%d bytes)\n'
|
||||
sys.stderr.write(' s: assembling %r (%d bytes)\r\n'
|
||||
% (name, nbytes))
|
||||
content = z.decompress(sys.stdin.read(nbytes))
|
||||
|
||||
|
@ -18,15 +18,19 @@ def log(s):
|
||||
# Put newline at end of string if line doesn't have one.
|
||||
if not s.endswith("\n"):
|
||||
s = s+"\n"
|
||||
# Allow multi-line messages
|
||||
if s.find("\n") != -1:
|
||||
prefix = logprefix
|
||||
s = s.rstrip("\n")
|
||||
for line in s.split("\n"):
|
||||
sys.stderr.write(prefix + line + "\n")
|
||||
prefix = " "
|
||||
else:
|
||||
sys.stderr.write(logprefix + s)
|
||||
|
||||
prefix = logprefix
|
||||
s = s.rstrip("\n")
|
||||
for line in s.split("\n"):
|
||||
# We output with \r\n instead of \n because when we use
|
||||
# sudo with the use_pty option, the firewall process, the
|
||||
# other processes printing to the terminal will have the
|
||||
# \n move to the next line, but they will fail to reset
|
||||
# cursor to the beginning of the line. Printing output
|
||||
# with \r\n endings fixes that problem and does not appear
|
||||
# to cause problems elsewhere.
|
||||
sys.stderr.write(prefix + line + "\r\n")
|
||||
prefix = " "
|
||||
sys.stderr.flush()
|
||||
except IOError:
|
||||
# this could happen if stderr gets forcibly disconnected, eg. because
|
||||
|
Loading…
Reference in New Issue
Block a user