Show More
@@ -33,8 +33,10 b' from mercurial import dispatch' | |||||
33 |
|
33 | |||
34 | import sys, os, shlex |
|
34 | import sys, os, shlex | |
35 |
|
35 | |||
|
36 | def main(): | |||
36 | cwd = os.getcwd() |
|
37 | cwd = os.getcwd() | |
37 |
allowed_paths = [os.path.normpath(os.path.join(cwd, |
|
38 | allowed_paths = [os.path.normpath(os.path.join(cwd, | |
|
39 | os.path.expanduser(path))) | |||
38 | for path in sys.argv[1:]] |
|
40 | for path in sys.argv[1:]] | |
39 | orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?') |
|
41 | orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?') | |
40 | try: |
|
42 | try: | |
@@ -47,7 +49,9 b" if cmdargv[:2] == ['hg', '-R'] and cmdar" | |||||
47 | path = cmdargv[2] |
|
49 | path = cmdargv[2] | |
48 | repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) |
|
50 | repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path))) | |
49 | if repo in allowed_paths: |
|
51 | if repo in allowed_paths: | |
50 |
dispatch.dispatch(dispatch.request(['-R', repo, |
|
52 | dispatch.dispatch(dispatch.request(['-R', repo, | |
|
53 | 'serve', | |||
|
54 | '--stdio'])) | |||
51 | else: |
|
55 | else: | |
52 | sys.stderr.write('Illegal repository "%s"\n' % repo) |
|
56 | sys.stderr.write('Illegal repository "%s"\n' % repo) | |
53 | sys.exit(255) |
|
57 | sys.exit(255) | |
@@ -55,3 +59,5 b' else:' | |||||
55 | sys.stderr.write('Illegal command "%s"\n' % orig_cmd) |
|
59 | sys.stderr.write('Illegal command "%s"\n' % orig_cmd) | |
56 | sys.exit(255) |
|
60 | sys.exit(255) | |
57 |
|
61 | |||
|
62 | if __name__ == '__main__': | |||
|
63 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now