When ipc-sshtunnel spawns ipc-tap and ipc-inject over ssh, it does
not correctly escape the arguments passed to ssh, causing arguments
to be expanded where no expansion is desired.
This commit modifies the way ipc-sshtunnel so that it correctly
quotes and escapes arguments that are passed to ssh.
return 0
}
+ssh_escape() {
+ local remote="$1"
+ local args=("${@:2}")
+
+ local arg
+ local escaped_args
+
+ escaped_args=()
+
+ for arg in "${args[@]}"; do
+ escaped_args+=("\"$arg\"")
+ done
+
+ ssh "$remote" "${escaped_args[*]}"
+ return "$?"
+}
+
establish_ipc_tunnel() {
local direction="$1"
local remote="$2"
case "$direction" in
"in")
- ( ssh -n "$remote" ipc-tap "${tap_args[@]}" | ipc-inject "${inject_args[@]}" ) &
+ ( ssh_escape "$remote" ipc-tap "${tap_args[@]}" </dev/null | ipc-inject "${inject_args[@]}" ) &
;;
"out")
- ( ipc-tap "${tap_args[@]}" | ssh "$remote" ipc-inject "${inject_args[@]}" ) &
+ ( ipc-tap "${tap_args[@]}" | ssh_escape "$remote" ipc-inject "${inject_args[@]}" ) &
;;
*)
log_error "Invalid direction: $direction"