src/hg-ssh
changeset 108 00b48d7bdfa0
parent 107 84e9e33d866b
child 109 72100d3ed1bd
equal deleted inserted replaced
107:84e9e33d866b 108:00b48d7bdfa0
    87     paths.getEtcPath() + "/access.conf", 
    87     paths.getEtcPath() + "/access.conf", 
    88     os.getcwd() + "/hgadmin/access.conf"]:
    88     os.getcwd() + "/hgadmin/access.conf"]:
    89     if os.path.isfile(f):
    89     if os.path.isfile(f):
    90         ruleset.rules.readfile(f)
    90         ruleset.rules.readfile(f)
    91 
    91 
    92 cmd = os.environ.get('SSH_ORIGINAL_COMMAND', '')
    92 cmd = os.environ.get('SSH_ORIGINAL_COMMAND', None)
    93 try:
    93 try:
    94     if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
    94     if cmd is None:
       
    95         fail("direct logins on the hg account prohibited")
       
    96     elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
    95         repo = getrepo("read", cmd[6:-14])
    97         repo = getrepo("read", cmd[6:-14])
    96         if not os.path.isdir(repo + "/.hg"):
    98         if not os.path.isdir(repo + "/.hg"):
    97             fail("no such repository %s" % repo)
    99             fail("no such repository %s" % repo)
    98         dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
   100         dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
    99     elif cmd.startswith('hg init '):
   101     elif cmd.startswith('hg init '):
   102             fail("%s exists" % repo)
   104             fail("%s exists" % repo)
   103         d = os.path.dirname(repo)
   105         d = os.path.dirname(repo)
   104         if d != "" and not os.path.isdir(d):
   106         if d != "" and not os.path.isdir(d):
   105             os.makedirs(d)
   107             os.makedirs(d)
   106         dispatch.dispatch(['init', repo])
   108         dispatch.dispatch(['init', repo])
   107     elif cmd == "":
       
   108         fail("direct logins on the hg account prohibited ")
       
   109     else:
   109     else:
   110         fail("illegal command %r" % cmd)
   110         fail("illegal command %r" % cmd)
   111 except ruleset.AccessException:
   111 except ruleset.AccessException:
   112     fail("access denied")
   112     fail("access denied")
   113 
   113