add option to allow the remote python binary's name/path to be specified

This commit is contained in:
chocolateboy 2010-09-03 15:46:25 +01:00 committed by Avery Pennarun
parent 5bf8687ce3
commit ee74110cff
3 changed files with 9 additions and 7 deletions

View File

@ -92,7 +92,7 @@ class FirewallClient:
raise Fatal('cleanup: %r returned %d' % (self.argv, rv))
def _main(listener, fw, use_server, remotename, seed_hosts, auto_nets):
def _main(listener, fw, use_server, remotename, python, seed_hosts, auto_nets):
handlers = []
if use_server:
if helpers.verbose >= 1:
@ -100,7 +100,7 @@ def _main(listener, fw, use_server, remotename, seed_hosts, auto_nets):
else:
helpers.logprefix = 'client: '
debug1('connecting to server...\n')
(serverproc, serversock) = ssh.connect(remotename)
(serverproc, serversock) = ssh.connect(remotename, python)
mux = Mux(serversock, serversock)
handlers.append(mux)
@ -188,7 +188,7 @@ def _main(listener, fw, use_server, remotename, seed_hosts, auto_nets):
mux.check_fullness()
def main(listenip, use_server, remotename, seed_hosts, auto_nets,
def main(listenip, use_server, remotename, python, seed_hosts, auto_nets,
subnets_include, subnets_exclude):
debug1('Starting sshuttle proxy.\n')
listener = socket.socket()
@ -220,6 +220,6 @@ def main(listenip, use_server, remotename, seed_hosts, auto_nets,
try:
return _main(listener, fw, use_server, remotename,
seed_hosts, auto_nets)
python, seed_hosts, auto_nets)
finally:
fw.done()

View File

@ -52,6 +52,7 @@ sshuttle --server
l,listen= transproxy to this ip address and port number [0.0.0.0:0]
H,auto-hosts scan for remote hostnames and update local /etc/hosts
N,auto-nets automatically determine subnets to route
python= specify the name/path of the python interpreter on the remote server [python]
r,remote= ssh hostname (and optional username) of remote sshuttle server
x,exclude= exclude this subnet (can be used more than once)
v,verbose increase debug message verbosity
@ -99,6 +100,7 @@ try:
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'),
not opt.noserver,
remotename,
(opt.python or "python"),
sh,
opt.auto_nets,
parse_subnets(includes),

6
ssh.py
View File

@ -19,7 +19,7 @@ def empackage(z, filename):
return '%s\n%d\n%s' % (filename,len(content), content)
def connect(rhostport):
def connect(rhostport, python):
main_exe = sys.argv[0]
l = (rhostport or '').split(':', 1)
rhost = l[0]
@ -48,9 +48,9 @@ def connect(rhostport):
if not rhost:
argv = ['python', '-c', pyscript]
argv = [python, '-c', pyscript]
else:
argv = ['ssh'] + portl + [rhost, '--', "python -c '%s'" % pyscript]
argv = ['ssh'] + portl + [rhost, '--', "'%s' -c '%s'" % (python, pyscript)]
(s1,s2) = socket.socketpair()
def setup():
# runs in the child process