src/hg-ssh
changeset 39 f5055ce263c7
parent 36 b3237aabd0fe
child 43 0a7fc4652793
equal deleted inserted replaced
38:f1ee930c4ba8 39:f5055ce263c7
    15 mercurial-server.
    15 mercurial-server.
    16 
    16 
    17 This script is called by hg-ssh-wrapper with no arguments - everything
    17 This script is called by hg-ssh-wrapper with no arguments - everything
    18 should be in enviroment variables:
    18 should be in enviroment variables:
    19 
    19 
    20 HG_ACCESS_RULES_FILE identifies the path to the rules file
    20 HG_ACCESS_RULES_PATH identifies the paths to the rule files
    21 REMOTE_USER the remote user (which is the key used by ssh)
    21 REMOTE_USER the remote user (which is the key used by ssh)
    22 SSH_ORIGINAL_COMMAND the command the user was trying to run
    22 SSH_ORIGINAL_COMMAND the command the user was trying to run
    23 
    23 
    24 It uses SSH_ORIGINAL_COMMAND to determine what the user was trying to
    24 It uses SSH_ORIGINAL_COMMAND to determine what the user was trying to
    25 do and to what repository, and then checks each rule in the rule file
    25 do and to what repository, and then checks each rule in the rule file
    66 
    66 
    67 if len(sys.argv) != 1:
    67 if len(sys.argv) != 1:
    68     fail("hg-ssh must have no arguments (%s)" 
    68     fail("hg-ssh must have no arguments (%s)" 
    69         % sys.argv)
    69         % sys.argv)
    70 
    70 
    71 rules = ruleset.Ruleset.readfile(os.environ['HG_ACCESS_RULES_FILE'])
    71 rules = ruleset.rules_from_env()
    72 rules.set(user = getpath(os.environ['REMOTE_USER']))
    72 rules.set(user = getpath(os.environ['REMOTE_USER']))
    73 rules.set(branch = None, file = None)
    73 rules.set(branch = None, file = None)
    74 todispatch = get_cmd(rules, 
    74 todispatch = get_cmd(rules, 
    75     os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
    75     os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
    76 dispatch.dispatch(todispatch)
    76 dispatch.dispatch(todispatch)