src/hg-ssh
changeset 378 a788cfad4cfa
parent 374 7a1d6b228af6
equal deleted inserted replaced
377:18869fcfbc92 378:a788cfad4cfa
    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):