Skip to content

Commit

Permalink
Fix argument splitting for multi-word arguments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
F30 authored and brianmay committed Oct 4, 2016
1 parent c0c3612 commit 0ed5ef9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sshuttle/methods/pf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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
Expand Down Expand Up @@ -342,7 +343,7 @@ def _get_natlook_port(self, xport):


def pfctl(args, stdin=None):
argv = ['pfctl'] + list(args.split(" "))
argv = ['pfctl'] + shlex.split(args)
debug1('>> %s\n' % ' '.join(argv))

env = {
Expand Down
3 changes: 2 additions & 1 deletion sshuttle/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import zlib
import imp
import subprocess as ssubprocess
import shlex
import sshuttle.helpers as helpers
from sshuttle.helpers import debug2

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0ed5ef9

Please sign in to comment.