src/hg-ssh
changeset 77 8d14aac93b5d
parent 72 582808b47653
child 78 2a3407a14654
--- a/src/hg-ssh	Fri Mar 06 13:06:36 2009 +0000
+++ b/src/hg-ssh	Fri Mar 06 13:26:35 2009 +0000
@@ -48,17 +48,17 @@
         fail("Disallowing path: %s" % path)
     return path
 
-def try_cmd(rules, cmd):
+def try_cmd(cmd):
     if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
         repo = getpath(cmd[6:-14])
-        if rules.allow("read", repo=repo):
-            os.environ["HG_REPO_PATH"] = repo
+        ruleset.rules.set(repo=repo)
+        if ruleset.rules.allow("read", branch=None, file=None):
             dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
             return
     elif cmd.startswith('hg init '):
         repo = getpath(cmd[8:])
-        if rules.allow("init", repo=repo):
-            os.environ["HG_REPO_PATH"] = repo
+        ruleset.rules.set(repo=repo)
+        if ruleset.rules.allow("init", branch=None, file=None):
             dispatch.dispatch(['init', repo])
             return
     fail("Illegal command %r" % cmd)
@@ -80,11 +80,11 @@
 
 os.chdir('repos')
 
-os.environ['HG_ACCESS_RULES_PATH'] = (
-    paths.getEtcPath() + "/access.conf" + ":" + 
-    os.getcwd() + "/hgadmin/access.conf")
+for f in [
+    paths.getEtcPath() + "/access.conf", 
+    os.getcwd() + "/hgadmin/access.conf"]:
+    if os.path.isfile(f):
+        ruleset.rules.readfile(f)
 
-rules = ruleset.rules_from_env()
-rules.set(user = getpath(remote_user))
-rules.set(branch = None, file = None)
-try_cmd(rules, os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
+ruleset.rules.set(user = getpath(remote_user))
+try_cmd(os.environ.get('SSH_ORIGINAL_COMMAND', '?'))