Пример #1
0
    def get_suspect(self):
        success = self.sess.getincomingmail()
        if not success:
            self.logger.error('incoming esmtp transfer did not finish')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        tempfilename = sess.tempfilename

        try:
            suspect = Suspect(fromaddr,
                              sess.recipients,
                              tempfilename,
                              att_cachelimit=self._att_mgr_cachesize)
        except ValueError as e:
            if len(sess.recipients) > 0:
                toaddr = sess.recipients[0]
            else:
                toaddr = ''
            self.logger.error(
                'failed to initialise suspect with from=<%s> to=<%s> : %s' %
                (fromaddr, toaddr, str(e)))
            raise

        if sess.xforward_helo is not None and sess.xforward_addr is not None and sess.xforward_rdns is not None:
            suspect.clientinfo = sess.xforward_helo, sess.xforward_addr, sess.xforward_rdns

        return suspect
Пример #2
0
 def _make_dummy_suspect(self,
                         senderdomain,
                         clientip,
                         helo='foo.example.com'):
     s = Suspect('sender@%s' % senderdomain, '*****@*****.**',
                 '/dev/null')
     s.clientinfo = (helo, clientip, 'ptr.example.com')
     return s
Пример #3
0
    def get_suspect(self):
        succ = self.sess.getincomingmail()
        if not succ:
            self.logger.error('MILTER SESSION NOT COMPLETED')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        tempfilename = sess.tempfilename
        suspect = Suspect(fromaddr, sess.recipients, tempfilename)

        if sess.helo is not None and sess.addr is not None and sess.rdns is not None:
            suspect.clientinfo = sess.helo, sess.addr, sess.rdns

        return suspect
Пример #4
0
    def get_suspect(self):
        succ = self.sess.getincomingmail()
        if not succ:
            self.logger.error('MILTER SESSION NOT COMPLETED')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        tempfilename = sess.tempfilename
        suspect = Suspect(fromaddr, sess.recipients, tempfilename)

        if sess.helo is not None and sess.addr is not None and sess.rdns is not None:
            suspect.clientinfo = sess.helo, sess.addr, sess.rdns

        return suspect
Пример #5
0
    def get_suspect(self):
        success = self.sess.getincomingmail()
        if not success:
            self.logger.error('incoming esmtp transfer did not finish')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        toaddr = sess.to_address
        tempfilename = sess.tempfilename

        suspect = Suspect(fromaddr, toaddr, tempfilename)
        suspect.recipients = set(sess.recipients)

        if sess.xforward_helo is not None and sess.xforward_addr is not None and sess.xforward_rdns is not None:
            suspect.clientinfo = sess.xforward_helo, sess.xforward_addr, sess.xforward_rdns

        return suspect
Пример #6
0
    def get_suspect(self):
        success = self.sess.getincomingmail()
        if not success:
            self.logger.error('incoming esmtp transfer did not finish')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        toaddr = sess.to_address
        tempfilename = sess.tempfilename

        suspect = Suspect(fromaddr, toaddr, tempfilename)
        suspect.recipients = set(sess.recipients)

        if sess.xforward_helo is not None and sess.xforward_addr is not None and sess.xforward_rdns is not None:
            suspect.clientinfo = sess.xforward_helo, sess.xforward_addr, sess.xforward_rdns

        return suspect
Пример #7
0
    def get_suspect(self):
        if not self.sess.getincomingmail():
            self.logger.error('MILTER SESSION NOT COMPLETED')
            return None
        self.logger.debug("After getting incoming mail...")

        sess = self.sess
        from_address = sess.get_cleaned_from_address()
        recipients = sess.get_cleaned_recipients()

        # If there's no file
        temp_filename = sess.tempfilename
        if not temp_filename:
            return None

        # If there is a filename but no file
        if temp_filename and not os.path.exists(temp_filename):
            self.logger.warning(
                "File '%s' not found for suspect creation! from: %s, to: %s" %
                (temp_filename, str(from_address), str(recipients)))
            return None

        suspect = Suspect(from_address,
                          recipients,
                          temp_filename,
                          att_cachelimit=self._att_mgr_cachesize,
                          sasl_login=sess.sasl_login,
                          sasl_sender=sess.sasl_sender,
                          sasl_method=sess.sasl_method,
                          queue_id=sess.queueid)

        logging.getLogger('fuglu.MilterHandler.queueid').info(
            '"%s" "%s"' %
            (suspect.id, sess.queueid if sess.queueid else "NOQUEUE"))

        if sess.heloname is not None and sess.addr is not None and sess.rdns is not None:
            suspect.clientinfo = sess.heloname, sess.addr, sess.rdns

        return suspect
Пример #8
0
 def _make_dummy_suspect(self, senderdomain, clientip, helo='foo.example.com'):
     s = Suspect('sender@%s' %
                 senderdomain, '*****@*****.**', '/dev/null')
     s.clientinfo = (helo, clientip, 'ptr.example.com')
     return s