49 return path |
49 return path |
50 |
50 |
51 def get_cmd(rules, remoteuser, cmd): |
51 def get_cmd(rules, remoteuser, cmd): |
52 if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'): |
52 if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'): |
53 repo = getpath(cmd[6:-14]) |
53 repo = getpath(cmd[6:-14]) |
54 if rules.allow("read", user=remoteuser, repo=repo, file=None): |
54 if rules.allow("read", user=remoteuser, repo=repo, branch=None, file=None): |
55 os.environ["HG_REPO_PATH"] = repo |
55 os.environ["HG_REPO_PATH"] = repo |
56 return ['-R', repo, 'serve', '--stdio'] |
56 return ['-R', repo, 'serve', '--stdio'] |
57 elif cmd.startswith('hg init '): |
57 elif cmd.startswith('hg init '): |
58 repo = getpath(cmd[8:]) |
58 repo = getpath(cmd[8:]) |
59 if rules.allow("init", user=remoteuser, repo=repo, file=None): |
59 if rules.allow("init", user=remoteuser, repo=repo, branch=None, file=None): |
60 os.environ["HG_REPO_PATH"] = repo |
60 os.environ["HG_REPO_PATH"] = repo |
61 return ['init', repo] |
61 return ['init', repo] |
62 fail("Illegal command %r" % cmd) |
62 fail("Illegal command %r" % cmd) |
63 |
63 |
64 #logfile = open("/tmp/hg-ssh.%d.txt" % os.getpid(), "w") |
64 #logfile = open("/tmp/hg-ssh.%d.txt" % os.getpid(), "w") |