hg-ssh
changeset 10 524b4a45ef0a
parent 7 2935e7232bd3
child 15 f3654416d178
equal deleted inserted replaced
9:21d9048136dc 10:524b4a45ef0a
     9 #
     9 #
    10 # This software may be used and distributed according to the terms
    10 # This software may be used and distributed according to the terms
    11 # of the GNU General Public License, incorporated herein by reference.
    11 # of the GNU General Public License, incorporated herein by reference.
    12 
    12 
    13 """
    13 """
    14 hg-ssh - limit access to hg repositories reached via ssh.  Part of hg-admin-tools.
    14 hg-ssh - limit access to hg repositories reached via ssh.  Part of
       
    15 hg-admin-tools.
    15 
    16 
    16 This script is called by hg-ssh-wrapper with two arguments:
    17 This script is called by hg-ssh-wrapper with two arguments:
    17 
    18 
    18 hg-ssh <rulefile> <keyname>
    19 hg-ssh <rulefile> <keyname>
    19 
    20 
    20 It expects to find the command the SSH user was trying to run in the environment variable
    21 It expects to find the command the SSH user was trying to run in the
    21 SSH_ORIGINAL_COMMAND, and uses it to determine what the user was trying to do and to what repository, and then checks each rule in the rule file in turn for a matching rule which decides what to do, defaulting to disallowing the action.
    22 environment variable SSH_ORIGINAL_COMMAND, and uses it to determine
       
    23 what the user was trying to do and to what repository, and then checks
       
    24 each rule in the rule file in turn for a matching rule which decides
       
    25 what to do, defaulting to disallowing the action.
    22 """
    26 """
    23 
    27 
    24 # enable importing on demand to reduce startup time
    28 # enable importing on demand to reduce startup time
    25 from mercurial import demandimport; demandimport.enable()
    29 from mercurial import demandimport; demandimport.enable()
    26 
    30 
    87     fail("hg-ssh must have exactly two arguments (%s)" 
    91     fail("hg-ssh must have exactly two arguments (%s)" 
    88         % sys.argv)
    92         % sys.argv)
    89 
    93 
    90 rulefile = sys.argv[1]
    94 rulefile = sys.argv[1]
    91 keyname = sys.argv[2]
    95 keyname = sys.argv[2]
    92 todispatch = get_cmd(rulefile, keyname, os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
    96 todispatch = get_cmd(rulefile, keyname, 
       
    97     os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
    93 dispatch.dispatch(todispatch)
    98 dispatch.dispatch(todispatch)
    94 
    99