8000 Quote SSH arguments by chitoku-k · Pull Request #91 · xxh/xxh · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Quote SSH arguments #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2020
Merged

Quote SSH arguments #91

merged 2 commits into from
Jun 20, 2020

Conversation

chitoku-k
Copy link
Contributor
@chitoku-k chitoku-k commented Jun 19, 2020

Summary

This PR fixes shell quotation issues where SSH arguments were not properly passed to intended commands if they contain space(s).

In the following example, a user connects to server2 whose connection is required to be established against a proxy (server1).

get_host_info (pexpect)

Current Behaviour

Command # Argument
bash 1 -c
bash 2 echo -e "..." | ssh -v -o ProxyCommand=ssh -W %h:%p server1 server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh
ssh 4 -W
ssh 5 %h:%p
ssh 6 server1
ssh 7 server2
ssh 8 -T
ssh 9 bash -s

Expected Behaviour

Command # Argument
bash 1 -c
bash 2 echo -e "..." | ssh -v "-o" "ProxyCommand=ssh -W %h:%p server1" server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh -W %h:%p server1
ssh 4 server2
ssh 5 -T
ssh 6 bash -s

get_host_info (without pexpect)

Current Behaviour

Command # Argument
bash 1 -c
bash 2 echo -e "..." | ssh -v -o ProxyCommand=ssh -W %h:%p server1 server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh
ssh 4 -W
ssh 5 %h:%p
ssh 6 server1
ssh 7 server2
ssh 8 -T
ssh 9 bash -s

Expected Behaviour

Command # Argument
bash 1 -c
bash 2 echo -e "..." | ssh -v "-o" "ProxyCommand=ssh -W %h:%p server1" server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh -W %h:%p server1
ssh 4 server2
ssh 5 -T
ssh 6 bash -s

prepare_env_args (ssh)

Command # Argument
bash 1 -c
bash 2 echo "..." | ssh -v -o ProxyCommand=ssh -W %h:%p server1 server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh
ssh 4 -W
ssh 5 %h:%p
ssh 6 server1
ssh 7 server2
ssh 8 -T
ssh 9 bash -s

Expected Behaviour

Command # Argument
bash 1 -c
bash 2 echo "..." | ssh -v "-o" "ProxyCommand=ssh -W %h:%p server1" server2 -T "bash -s"
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh -W %h:%p server1
ssh 4 server2
ssh 5 -T
ssh 6 bash -s

prepare_env_args (rsync)

Current Behaviour

Command # Argument
bash 1 -c
bash 2 shopt -s dotglob && rsync -v -e "ssh -v -o ProxyCommand=ssh -W %h:%p server1" -az --cvs-exclude --include core build/ server2:build/ 1>&2
< 8000 /tr>
Command # Argument
rsync 1 -v
rsync 2 -e
rsync 3 ssh -v -o ProxyCommand=ssh -W %h:%p server1
rsync 4 -az
rsync 5 --cvs-exclude
rsync 6 --include
rsync 7 core
rsync 8 build/
rsync 9 server2:build/
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh
ssh 4 -W
ssh 5 %h:%p
ssh 6 server1

Expected Behaviour

Command # Argument
bash 1 -c
bash 2 shopt -s dotglob && rsync -v -e "ssh -v \"-o\" \"ProxyCommand=ssh -W %h:%p server1\"" -az --cvs-exclude --include core build/ server2:build/ 1>&2
Command # Argument
rsync 1 -v
rsync 2 -e
rsync 3 ssh -v "-o" "ProxyCommand=ssh -W %h:%p server1"
rsync 4 -az
rsync 5 --cvs-exclude
rsync 6 --include
rsync 7 core
rsync 8 build/
rsync 9 server2:build/
Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh -W %h:%p server1

prepare_env_args (scp)

Current Behaviour

Command # Argument
bash 1 -c
bash 2 shopt -s dotglob && scp -v -o ProxyCommand=ssh -W %h:%p server1 -r -C build server2:build/ 1>&2
Command # Argument
scp 1 -v
scp 2 -o
scp 3 ProxyCommand=ssh
scp 4 -W
scp 5 %h:%p
scp 6 server1
scp 7 -r
scp 8 -C
scp 9 build
scp 10 server2:build/

Expected Behaviour

Command # Argument
bash 1 -c
bash 2 shopt -s dotglob && scp -v '-o' 'ProxyCommand=ssh -W %h:%p server1' -r -C build server2:build/ 1>&2
Command # Argument
scp 1 -v
scp 2 -o
scp 3 ProxyCommand=ssh -W %h:%p server1
scp 4 -r
scp 5 -C
scp 6 build
scp 7 server2:build/

prepare_env_args (entrypoint)

Current Behaviour

Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh
ssh 4 -W
ssh 5 %h:%p
ssh 6 server1
ssh 7 server2
ssh 8 -T
ssh 9 bash -s

Expected Behaviour

Command # Argument
ssh 1 -v
ssh 2 -o
ssh 3 ProxyCommand=ssh -W %h:%p server1
ssh 4 server2
ssh 5 -T
ssh 6 bash -s

@anki-code anki-code merged commit 04019d1 into xxh:master Jun 20, 2020
@anki-code
Copy link
Member

Great improvement! Thanks and welcome!

@chitoku-k chitoku-k deleted the fix/escape-arguments branch June 20, 2020 08:51
@anki-code anki-code added this to the 0.8.4 milestone Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0