Backward compatibility with Python 3.4 (server)

These changes will allow sshuttle to be used with servers that
have python 3.4 installed (e.g. CentOS 7, Debian 8, Ubuntu 14.04).
This commit is contained in:
vieira 2015-12-07 01:19:52 +00:00
parent df89afe365
commit dcce29605c
3 changed files with 6 additions and 5 deletions

View File

@ -4,7 +4,7 @@ import imp
z = zlib.decompressobj()
while 1:
name = sys.stdin.readline().strip()
name = sys.stdin.readline().strip().decode("ASCII")
if name:
nbytes = int(sys.stdin.readline())
if verbosity >= 2:

View File

@ -12,7 +12,7 @@ import sshuttle.helpers as helpers
import sshuttle.hostwatch as hostwatch
import subprocess as ssubprocess
from sshuttle.ssnet import Handler, Proxy, Mux, MuxWrapper
from sshuttle.helpers import log, debug1, debug2, debug3, Fatal, \
from sshuttle.helpers import b, log, debug1, debug2, debug3, Fatal, \
resolvconf_random_nameserver
@ -61,7 +61,7 @@ def _list_routes():
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE)
routes = []
for line in p.stdout:
cols = re.split(r'\s+', line)
cols = re.split(r'\s+', line.decode("ASCII"))
ipw = _ipmatch(cols[0])
if not ipw:
continue # some lines won't be parseable; never mind
@ -246,7 +246,7 @@ def main(latency_control):
routepkt = ''
for r in routes:
routepkt += '%d,%s,%d\n' % r
mux.send(0, ssnet.CMD_ROUTES, routepkt)
mux.send(0, ssnet.CMD_ROUTES, b(routepkt))
hw = Hostwatch()
hw.leftover = ''

View File

@ -89,8 +89,9 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
b"\n")
pyscript = r"""
import sys;
import sys, os;
verbosity=%d;
sys.stdin = os.fdopen(0, "rb");
exec(compile(sys.stdin.read(%d), "assembler.py", "exec"))
""" % (helpers.verbose or 0, len(content))
pyscript = re.sub(r'\s+', ' ', pyscript.strip())