diff -r f98f716b2ae8 -r 3a28047ec6dc src/hg-ssh --- a/src/hg-ssh Wed Dec 02 17:46:28 2009 +0000 +++ b/src/hg-ssh Wed Dec 02 17:48:40 2009 +0000 @@ -14,12 +14,8 @@ hg-ssh - limit access to hg repositories reached via ssh. Part of mercurial-server. -This script is called by hg-ssh-wrapper with no arguments - everything -should be in enviroment variables: - -HG_ACCESS_RULES_PATH identifies the paths to the rule files -REMOTE_USER the remote user (which is the key used by ssh) -SSH_ORIGINAL_COMMAND the command the user was trying to run +It is called by ssh due to an entry in the authorized_keys file, +with the name for the key passed on the command line. It uses SSH_ORIGINAL_COMMAND to determine what the user was trying to do and to what repository, and then checks each rule in the rule file @@ -35,7 +31,7 @@ import sys, os, os.path import base64 -from mercurialserver import ruleset, paths +from mercurialserver import config, ruleset def fail(message): sys.stderr.write("mercurial-server: %s\n" % message) @@ -71,7 +67,7 @@ checkParents(repo) return repo -paths.setExePath() +config.initExe() if len(sys.argv) == 3 and sys.argv[1] == "--base64": ruleset.rules.set(user = base64.b64decode(sys.argv[2])) @@ -81,14 +77,12 @@ fail("hg-ssh wrongly called, is authorized_keys corrupt? (%s)" % sys.argv) -# Use a different hgrc for remote pulls - this way you can set -# up access.py for everything at once without affecting local operations +for k,v in config.getEnv(): + os.environ[k] = v -os.environ['HGRCPATH'] = paths.getHgrcPaths() +os.chdir(config.getReposPath()) -os.chdir(paths.getReposPath()) - -for f in paths.getAccessPaths(): +for f in config.getAccessPaths(): if os.path.isfile(f): ruleset.rules.readfile(f)