mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-05-19 07:30:55 +02:00
Fix shell quoting
Due to nested shells, we need to have multiple layers of quoting. Yuck. Closes #80
This commit is contained in:
parent
efdb9b8f94
commit
3541e4bdfe
@ -8,6 +8,12 @@ import subprocess as ssubprocess
|
|||||||
import sshuttle.helpers as helpers
|
import sshuttle.helpers as helpers
|
||||||
from sshuttle.helpers import debug2
|
from sshuttle.helpers import debug2
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python >= 3.5
|
||||||
|
from shlex import quote
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.x
|
||||||
|
from pipes import quote
|
||||||
|
|
||||||
def readfile(name):
|
def readfile(name):
|
||||||
tokens = name.split(".")
|
tokens = name.split(".")
|
||||||
@ -108,8 +114,9 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
|
|||||||
if python:
|
if python:
|
||||||
pycmd = "'%s' -c '%s'" % (python, pyscript)
|
pycmd = "'%s' -c '%s'" % (python, pyscript)
|
||||||
else:
|
else:
|
||||||
pycmd = ("exec /bin/sh -c \'P=python3.5; $P -V 2>/dev/null || P=python; "
|
pycmd = ("P=python3.5; $P -V 2>/dev/null || P=python; "
|
||||||
"exec \"$P\" -c \\'%s\\'\'") % pyscript
|
"exec \"$P\" -c %s") % quote(pyscript)
|
||||||
|
pycmd = ("exec /bin/sh -c %s" % quote(pycmd))
|
||||||
argv = (sshl +
|
argv = (sshl +
|
||||||
portl +
|
portl +
|
||||||
[rhost, '--', pycmd])
|
[rhost, '--', pycmd])
|
||||||
|
Loading…
Reference in New Issue
Block a user