Show More
@@ -31,15 +31,20 b' from mercurial import demandimport; dema' | |||||
31 |
|
31 | |||
32 | from mercurial import dispatch |
|
32 | from mercurial import dispatch | |
33 |
|
33 | |||
34 | import sys, os |
|
34 | import sys, os, shlex | |
35 |
|
35 | |||
36 | cwd = os.getcwd() |
|
36 | cwd = os.getcwd() | |
37 | allowed_paths = [os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) |
|
37 | allowed_paths = [os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) | |
38 | for path in sys.argv[1:]] |
|
38 | for path in sys.argv[1:]] | |
39 | orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?') |
|
39 | orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?') | |
|
40 | try: | |||
|
41 | cmdargv = shlex.split(orig_cmd) | |||
|
42 | except ValueError, e: | |||
|
43 | sys.stderr.write("Illegal command %r: %s\n" % (orig_cmd, e)) | |||
|
44 | sys.exit(-1) | |||
40 |
|
45 | |||
41 | if orig_cmd.startswith('hg -R ') and orig_cmd.endswith(' serve --stdio'): |
|
46 | if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']: | |
42 |
path = |
|
47 | path = cmdargv[2] | |
43 | repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) |
|
48 | repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) | |
44 | if repo in allowed_paths: |
|
49 | if repo in allowed_paths: | |
45 | dispatch.dispatch(dispatch.request(['-R', repo, 'serve', '--stdio'])) |
|
50 | dispatch.dispatch(dispatch.request(['-R', repo, 'serve', '--stdio'])) |
@@ -275,6 +275,19 b' Test remote paths with spaces (issue2983' | |||||
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 |
General Comments 0
You need to be logged in to leave comments.
Login now