Ejemplo n.º 1
0
def serve(command):
    verb, args = command.split(None, 1)
    if verb == "git":
        try:
            subverb, args = args.split(None, 1)
        except ValueError:
            sys.exit('[ERROR] UnknownCommand')

        verb = '%s %s' % (verb, subverb)

    if (verb not in COMMANDS_WRITE and verb not in COMMANDS_READONLY):
        sys.exit('[ERROR] UnknownCommand')
    
    args = args.replace("'","") 
    accesses = []
    for username in usernames: 
        log("----->%s"%username)
        access = repo_access(username, re.sub("\.git$","",args))
        accesses.extend(access)

    if not accesses:
        sys.exit('[ERROR] You do not have any permission for this project')

    if "w" not in accesses and verb in COMMANDS_WRITE:
        sys.exit('[ERROR] You do not have write permission for this project')


    return verb + " '%(repo_dir)s/%(repo_path)s'"%dict(
            repo_dir=REPO_DIR,
            repo_path=args
        )
Ejemplo n.º 2
0
pubkey = sys.stdin.readline()

try:
    pubkey = re.match("(^ssh-(?:dss|rsa) [A-Za-z0-9+\/]+)", pubkey).group()
except:
    sys.exit(1)

#if not re.match('^ssh-(?:dss|rsa) [A-Za-z0-9+\/]+$', pubkey):
#    log("[ERROR] invalide key")
#    exit("[ERROR] invalide key")

try:
    sshkey_objects = filter_users_bykey(pubkey)
except Exception,e:
    log(str(e))

users = []
for sshkey in sshkey_objects:
    users.append(sshkey.user.username)

users = ",".join(users)

log(users)

params = [
    'command="'+ SCRIPT_PATH + ' %s"'%users,
    'no-port-forwarding',
    'no-X11-forwarding',
    'no-agent-forwarding',
    'no-pty'