Skip to content

Commit 7712c60

Browse files
committed
Insert two binary NUL bytes (\0) before SSHUTTLE0001 sync string.
...and search for those null bytes before looking for the sync string. This helps when people have misconfigured .bashrc to print messages even in non-interactive mode. (On my Debian Lenny system, .bashrc doesn't seem to run when you do 'ssh localhost ls', but on MacOS servers, it does. Hmm...)
1 parent 65b0390 commit 7712c60

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,14 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
198198
handlers.append(mux)
199199

200200
expected = 'SSHUTTLE0001'
201+
201202
try:
203+
v = 'x'
204+
while v and v != '\0':
205+
v = serversock.recv(1)
206+
v = 'x'
207+
while v and v != '\0':
208+
v = serversock.recv(1)
202209
initstring = serversock.recv(len(expected))
203210
except socket.error, e:
204211
if e.args[0] == errno.ECONNRESET:

server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def main():
173173
debug1(' %s/%d\n' % r)
174174

175175
# synchronization header
176-
sys.stdout.write('SSHUTTLE0001')
176+
sys.stdout.write('\0\0SSHUTTLE0001')
177177
sys.stdout.flush()
178178

179179
handlers = []

0 commit comments

Comments
 (0)