Skip to content
Browse files

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...)
  • Loading branch information...
1 parent 65b0390 commit 7712c60c36e1bf5a4432b146502b0533307417f4 @apenwarr committed May 3, 2011
Showing with 8 additions and 1 deletion.
  1. +7 −0 client.py
  2. +1 −1 server.py
View
7 client.py
@@ -198,7 +198,14 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
handlers.append(mux)
expected = 'SSHUTTLE0001'
+
try:
+ v = 'x'
+ while v and v != '\0':
+ v = serversock.recv(1)
+ v = 'x'
+ while v and v != '\0':
+ v = serversock.recv(1)
initstring = serversock.recv(len(expected))
except socket.error, e:
if e.args[0] == errno.ECONNRESET:
View
2 server.py
@@ -173,7 +173,7 @@ def main():
debug1(' %s/%d\n' % r)
# synchronization header
- sys.stdout.write('SSHUTTLE0001')
+ sys.stdout.write('\0\0SSHUTTLE0001')
sys.stdout.flush()
handlers = []

0 comments on commit 7712c60

Please sign in to comment.
Something went wrong with that request. Please try again.