Example #1
0
        def cbLoggedIn(e, config):
            mail = only(e, config.getLDAPAttributeMailbox())
            username = mail.split('@', 1)[0]
            hostname = mail.split('@', 1)[1]

            username = quot(username)
            hostname = quot(hostname)

            userpad = (username+'__')[:2]

            mailhost = only(e, config.getLDAPAttributeMailHost())

            userdir = os.path.join(
                config.getSpool(),
                hostname,
                mailhost,
                userpad)

            switchUID(uid=pwd.getpwnam('scalemail')[2],
                      gid=grp.getgrnam('scalemail')[2])

            if not os.path.isdir(userdir):
                os.mkdir(userdir, 0700)
            os.chdir(userdir)

            if not os.path.isdir(username):
                initializeMaildir(username)
            os.chdir(username)

            os.execlp(sys.argv[1], *sys.argv[1:])
            print >>sys.stderr, "scalemail-courier-login: Cannot exec command."
            sys.exit(2)
Example #2
0
def cbLoggedIn(e, config, env):
    mail = only(e, config.getLDAPAttributeMailbox())
    username = mail.split('@', 1)[0]
    hostname = mail.split('@', 1)[1]

    username = quot(username)
    hostname = quot(hostname)

    userpad = (username+'__')[:2]

    mailhost = only(e, config.getLDAPAttributeMailHost())

    userdir = os.path.join(config.getSpool(),
                           hostname,
                           mailhost,
                           userpad)

    env['MAILDIR'] = '.'
    env['AUTHENTICATED'] = mail
    return (userdir, username)