diff options
author | Felix Dreissig <f30@f30.me> | 2016-09-28 20:37:16 +0200 |
---|---|---|
committer | Brian May <brian@linuxpenguins.xyz> | 2016-10-04 18:19:59 +1100 |
commit | 0ed5ef9a97dfce517c0dcfa515b011867d90be62 (patch) | |
tree | 61b9f179f5655be29574f27d131ece31dfef9681 | |
parent | c0c3612e6d8539896333df52b98159b18c000739 (diff) |
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.
-rw-r--r-- | sshuttle/methods/pf.py | 3 | ||||
-rw-r--r-- | sshuttle/ssh.py | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/sshuttle/methods/pf.py b/sshuttle/methods/pf.py index 75d85e7..410a67f 100644 --- a/sshuttle/methods/pf.py +++ b/sshuttle/methods/pf.py @@ -4,6 +4,7 @@ import re import socket import struct import subprocess as ssubprocess +import shlex from fcntl import ioctl from ctypes import c_char, c_uint8, c_uint16, c_uint32, Union, Structure, \ sizeof, addressof, memmove @@ -342,7 +343,7 @@ else: def pfctl(args, stdin=None): - argv = ['pfctl'] + list(args.split(" ")) + argv = ['pfctl'] + shlex.split(args) debug1('>> %s\n' % ' '.join(argv)) env = { diff --git a/sshuttle/ssh.py b/sshuttle/ssh.py index 3214bda..a4f11cb 100644 --- a/sshuttle/ssh.py +++ b/sshuttle/ssh.py @@ -5,6 +5,7 @@ import socket import zlib import imp import subprocess as ssubprocess +import shlex import sshuttle.helpers as helpers from sshuttle.helpers import debug2 @@ -109,7 +110,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options): argv = [sys.executable, '-c', pyscript] else: if ssh_cmd: - sshl = ssh_cmd.split(' ') + sshl = shlex.split(ssh_cmd) else: sshl = ['ssh'] if python: |