Beispiel #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)
Beispiel #2
0
 def __init__(self, path):
     maildir.initializeMaildir(path)
     self.listeners = []
     self.path = path
     self.open_flags()
     self.lastadded = None
     self.__check_flags_()
 def validateTo(self, user):
     maildirpath = self.service.maildirDirectory()
     if not os.path.exists(maildirpath):
         maildir.initializeMaildir(maildirpath)
     fname = maildir._generateMaildirName()
     filename = os.path.join(maildirpath,'tmp',fname)
     fp = open(filename,'w')
     return lambda: maildir.MaildirMessage(
         '%s@%s' % (user.dest.local, user.dest.domain), 
         fp, filename, os.path.join(maildirpath, 'new', fname))
Beispiel #4
0
def run():
    import traceback
    from twisted.trial import util

    try:
        cfg = config.ScalemailConfig()
        authfile = os.fdopen(3, 'r')
        service = authfile.readline().rstrip()
        authtype = authfile.readline().rstrip()
        authdata = authfile.read()
        authfile.close()
        try:
            d = main(config=cfg,
                     argv=sys.argv,
                     env=os.environ,
                     service=service,
                     authtype=authtype,
                     authdata=authdata)
            r = util.wait(d, timeout=60.0)
            userdir, username = r

            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:])
            die("Something is very wrong")
        except (error.UnauthorizedLogin,
                ChainLogin):
            # TODO pass on authinfo
            os.execlp(sys.argv[1], *sys.argv[1:])
            die("Something is very wrong")
        except RetryLogin:
            # TODO pass on authinfo
            l = []

            argc = int(os.environ['AUTHARGC'])
            for i in range(argc):
                l.append(os.environ['AUTHARGV%d' % i])
            os.execlp(*l)
            die("Something is very wrong")
    except SystemExit:
        raise
    except:
        try:
            traceback.print_exc(file=sys.stderr)
        finally:
            sys.exit(EX_TEMPFAIL)
Beispiel #5
0
 def store(self, item):
     maildir.initializeMaildir(self.dir)
     fname = maildir._generateMaildirName()
     filename = os.path.join(self.dir, 'tmp', fname)
     fp = open(filename, 'w')
     msg = maildir.MaildirMessage(
         'toursst@invalid',
         fp,
         filename,
         os.path.join(self.dir, 'new', fname))
     data = self.formatter.format(item, self.feed)
     for line in data.splitlines():
         msg.lineReceived(line)
     msg.eomReceived()
Beispiel #6
0
 def getNamedBox(self, nameBox, create = False):
     split = nameBox.split(".")
     
     if split[0].lower() == "inbox":
         split[0] = "Inbox"
     NamedBox = ".".join(split)
     
     if not self.mailBoxCache.has_key(NamedBox):
         #"/home/greenlamp/Maildir/greenlamp/Inbox"
         self.pathMailDirBox = os.path.join(self.pathMailDirAvatar, NamedBox)
         if not os.path.exists(self.pathMailDirBox):
             if create == True:
                 maildir.initializeMaildir(self.pathMailDirBox)
             else:
                 raise KeyError("No such Box")
         self.mailBoxCache[NamedBox] = self.specMessages.getMailBoxMessages(self.pathMailDirBox)
     return self.mailBoxCache[NamedBox]
    def _getMailbox(self, path, create=False):
        """
        Helper function to get a mailbox object at the given
        path, optionally creating it if it doesn't already exist.
        """
        # According to the IMAP spec, Inbox is case-insensitive
        pathParts = path.split(MAILBOXDELIMITER)
        if pathParts[0].lower() == 'inbox': pathParts[0] = 'Inbox'
        path = MAILBOXDELIMITER.join(pathParts)

        if not self.mailboxCache.has_key(path):
            fullPath = os.path.join(self.dir, path)
            if not os.path.exists(fullPath):
                if create:
                    maildir.initializeMaildir(fullPath)
                else:
                    raise KeyError, "No such mailbox"
            self.mailboxCache[path] = IMAPMailbox(fullPath)
        return self.mailboxCache[path]
Beispiel #8
0
 def _getMailbox(self, path, create=False):
     """
     Helper function to get a mailbox object at the given
     path, optionally creating it if it doesn't already exist.
     """
     # According to the IMAP spec, Inbox is case-insensitive
     pathParts = path.split(MAILBOXDELIMITER)
     if pathParts[0].lower() == 'inbox': pathParts[0] = 'Inbox'
     path = MAILBOXDELIMITER.join(pathParts)
     
     if not self.mailboxCache.has_key(path):
         fullPath = os.path.join(self.dir, path)
         if not os.path.exists(fullPath):
             if create:
                 maildir.initializeMaildir(fullPath)
             else:
                 raise KeyError, "No such mailbox"
         self.mailboxCache[path] = IMAPMailbox(fullPath)
     return self.mailboxCache[path]
Beispiel #9
0
    def getNamedBox(self, nameBox, create=False):
        split = nameBox.split(".")

        if split[0].lower() == "inbox":
            split[0] = "Inbox"
        NamedBox = ".".join(split)

        if not self.mailBoxCache.has_key(NamedBox):
            #"/home/greenlamp/Maildir/greenlamp/Inbox"
            self.pathMailDirBox = os.path.join(self.pathMailDirAvatar,
                                               NamedBox)
            if not os.path.exists(self.pathMailDirBox):
                if create == True:
                    maildir.initializeMaildir(self.pathMailDirBox)
                else:
                    raise KeyError("No such Box")
            self.mailBoxCache[NamedBox] = self.specMessages.getMailBoxMessages(
                self.pathMailDirBox)
        return self.mailBoxCache[NamedBox]
Beispiel #10
0
def maildirmake(dir):
    maildir.initializeMaildir(dir)