Commit 0ed5ef9a authored by Felix Dreissig's avatar Felix Dreissig Committed by Brian May

Fix argument splitting for multi-word arguments

By just splitting at spaces, multi-word arguments are torn apart even if
quoted. In case of custom ssh-cmd, this makes it practically impossible
to set certian options through `ssh -o`.
shlex splits arguments like a shell and e.g. respects quotes.
parent c0c3612e
...@@ -4,6 +4,7 @@ import re ...@@ -4,6 +4,7 @@ import re
import socket import socket
import struct import struct
import subprocess as ssubprocess import subprocess as ssubprocess
import shlex
from fcntl import ioctl from fcntl import ioctl
from ctypes import c_char, c_uint8, c_uint16, c_uint32, Union, Structure, \ from ctypes import c_char, c_uint8, c_uint16, c_uint32, Union, Structure, \
sizeof, addressof, memmove sizeof, addressof, memmove
...@@ -342,7 +343,7 @@ else: ...@@ -342,7 +343,7 @@ else:
def pfctl(args, stdin=None): def pfctl(args, stdin=None):
argv = ['pfctl'] + list(args.split(" ")) argv = ['pfctl'] + shlex.split(args)
debug1('>> %s\n' % ' '.join(argv)) debug1('>> %s\n' % ' '.join(argv))
env = { env = {
......
...@@ -5,6 +5,7 @@ import socket ...@@ -5,6 +5,7 @@ import socket
import zlib import zlib
import imp import imp
import subprocess as ssubprocess import subprocess as ssubprocess
import shlex
import sshuttle.helpers as helpers import sshuttle.helpers as helpers
from sshuttle.helpers import debug2 from sshuttle.helpers import debug2
...@@ -109,7 +110,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options): ...@@ -109,7 +110,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
argv = [sys.executable, '-c', pyscript] argv = [sys.executable, '-c', pyscript]
else: else:
if ssh_cmd: if ssh_cmd:
sshl = ssh_cmd.split(' ') sshl = shlex.split(ssh_cmd)
else: else:
sshl = ['ssh'] sshl = ['ssh']
if python: if python:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment