Mercurial > hg
comparison tests/test-ssh.t @ 15897:cc021114fc98
hg-ssh: use shlex for shell-like parsing of SSH_ORIGINAL_COMMAND
The Mercurial ssh protocol is defined as if it was ssh-ing to a shell account on
an ordinary ssh server, and where hg was available in $PATH and it executed
the command "hg -R REPOPATH serve --stdio".
The Mercurial ssh client can in most cases just pass REPOPATH to the shell, but
if it contains unsafe characters the client will have to quote it so the shell
will pass the right -R value to hg. Correct quoting of repopaths was introduced
in d8fa35c28335 and tweaked in 86fc364ca5f8.
hg-ssh doesn't create the command via a shell and used a simple parser instead.
It worked fine for simple paths without any quoting, but if any kind of quoting
was used it failed to parse the command like the shell would do it.
This makes hg-ssh behave more like a normal shell with hg in the path would do.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Thu, 08 Dec 2011 16:28:18 +0100 |
parents | 79cc89de5be1 |
children | 90f8b8dd0326 |
comparison
equal
deleted
inserted
replaced
15896:30c34fde40cc | 15897:cc021114fc98 |
---|---|
273 $ hg init --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" | 273 $ hg init --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" |
274 $ hg -R 'a repo' tag tag | 274 $ hg -R 'a repo' tag tag |
275 $ hg id --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" | 275 $ hg id --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" |
276 3fb238f49e8c | 276 3fb238f49e8c |
277 | 277 |
278 Test hg-ssh: | |
279 | |
280 $ SSH_ORIGINAL_COMMAND="'hg' -R 'a repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP/a repo\"" "ssh://user@dummy/a repo" | |
281 3fb238f49e8c | |
282 $ SSH_ORIGINAL_COMMAND="'hg' -R 'a repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP\"" "ssh://user@dummy/a repo" | |
283 remote: Illegal repository '$TESTTMP/a repo' | |
284 abort: no suitable response from remote hg! | |
285 [255] | |
286 $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP\"" "ssh://user@dummy/a repo" | |
287 remote: Illegal command "'hg' -R 'a'repo' serve --stdio": No closing quotation | |
288 abort: no suitable response from remote hg! | |
289 [255] | |
290 | |
278 $ cat dummylog | 291 $ cat dummylog |
279 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio | 292 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio |
280 Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio | 293 Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio |
281 Got arguments 1:user@dummy 2:hg -R remote serve --stdio | 294 Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
282 Got arguments 1:user@dummy 2:hg -R remote serve --stdio | 295 Got arguments 1:user@dummy 2:hg -R remote serve --stdio |