--- a/src/hg-ssh Mon Oct 12 16:52:06 2009 +0100
+++ b/src/hg-ssh Mon Oct 12 17:04:26 2009 +0100
@@ -46,7 +46,7 @@
if path == "":
return
if os.path.exists(path + "/.hg"):
- raise ruleset.AccessException()
+ fail("Cannot create repo under existing repo")
checkpath(path)
def getrepo(op, repo):
@@ -59,7 +59,8 @@
if component.startswith("."):
fail("paths cannot contain dot file components")
ruleset.rules.set(repo=repo)
- ruleset.rules.check(op, branch=None, file=None)
+ if not ruleset.rules.allow(op, branch=None, file=None):
+ fail("access denied")
checkpath(repo)
return repo
@@ -90,24 +91,21 @@
ruleset.rules.readfile(f)
cmd = os.environ.get('SSH_ORIGINAL_COMMAND', None)
-try:
- if cmd is None:
- fail("direct logins on the hg account prohibited")
- elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
- repo = getrepo("read", cmd[6:-14])
- if not os.path.isdir(repo + "/.hg"):
- fail("no such repository %s" % repo)
- dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
- elif cmd.startswith('hg init '):
- repo = getrepo("init", cmd[8:])
- if os.path.exists(repo):
- fail("%s exists" % repo)
- d = os.path.dirname(repo)
- if d != "" and not os.path.isdir(d):
- os.makedirs(d)
- dispatch.dispatch(['init', repo])
- else:
- fail("illegal command %r" % cmd)
-except ruleset.AccessException:
- fail("access denied")
+if cmd is None:
+ fail("direct logins on the hg account prohibited")
+elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
+ repo = getrepo("read", cmd[6:-14])
+ if not os.path.isdir(repo + "/.hg"):
+ fail("no such repository %s" % repo)
+ dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
+elif cmd.startswith('hg init '):
+ repo = getrepo("init", cmd[8:])
+ if os.path.exists(repo):
+ fail("%s exists" % repo)
+ d = os.path.dirname(repo)
+ if d != "" and not os.path.isdir(d):
+ os.makedirs(d)
+ dispatch.dispatch(['init', repo])
+else:
+ fail("illegal command %r" % cmd)