src/hg-ssh
changeset 374 7a1d6b228af6
parent 306 f832a8aeef44
equal deleted inserted replaced
373:a286d6c6b19c 374:7a1d6b228af6
    36 
    36 
    37 for k,v in config.getEnv():
    37 for k,v in config.getEnv():
    38     os.environ[k.upper()] = v
    38     os.environ[k.upper()] = v
    39 
    39 
    40 if len(sys.argv) == 3 and sys.argv[1] == "--base64":
    40 if len(sys.argv) == 3 and sys.argv[1] == "--base64":
    41     ruleset.rules.set(user = base64.b64decode(sys.argv[2]))
    41     user = base64.b64decode(sys.argv[2])
       
    42     ruleset.rules.set(user = user)
    42 elif len(sys.argv) == 2:
    43 elif len(sys.argv) == 2:
    43     ruleset.rules.set(user = sys.argv[1])
    44     user = sys.argv[1]
       
    45     ruleset.rules.set(user = user)
    44 else:
    46 else:
    45     fail("hg-ssh wrongly called, is authorized_keys corrupt? (%s)"
    47     fail("hg-ssh wrongly called, is authorized_keys corrupt? (%s)"
    46         % sys.argv)
    48         % sys.argv)
       
    49 
       
    50 paths = []
       
    51 path = user
       
    52 while path:
       
    53     path, tail = os.path.split(path)
       
    54     paths.append(tail)
       
    55 paths.reverse()
       
    56 i = config.getUserPathIndex()
       
    57 if i >= 0 and i < len(paths):
       
    58     user = paths[i]
       
    59 os.environ['LOGNAME'] = user
    47 
    60 
    48 os.chdir(config.getReposPath())
    61 os.chdir(config.getReposPath())
    49 
    62 
    50 for f in config.getAccessPaths():
    63 for f in config.getAccessPaths():
    51     if os.path.isfile(f):
    64     if os.path.isfile(f):