from auth_chroot_config import *

import utils
from utils import myfnmatch
import os

def got_user(username, session, sessions):
    return 331, "Give me password", "", "", -1, 1

def got_pass(username, password, session, sessions):
    for i in chrootlist:
        if myfnmatch(username, i[0]):
            session.chrootdir = i[1]
    return 530, "Sorry", -1, 1

def v2fs(f, session):
    r = os.path.normpath(session.chrootdir+utils.v2fs(f, session))
    if os.path.commonprefix([r, session.chrootdir]) <> session.chrootdir: # make sure user cannot escape via /../..
        r = session.chrootdir
    return r
    
