def found_terminator(self): line = EMPTYSTRING.join(self.__line) print >> smtpd.DEBUGSTREAM, 'Data:', repr(line) self.__line = [] if self.__state == self.COMMAND: if not line: self.push('500 Error: bad syntax') return method = None i = line.find(' ') # If we are in authentication mode, and the line is NOT a valid # SMTP verb, then assume it is the password. if ((self.authenticating and not callable(getattr(self, 'smtp_' + line.upper(), None)))): arg = line.strip() command = 'AUTH' elif i < 0: command = line.upper() arg = None else: command = line[:i].upper() arg = line[i + 1:].strip() # White list of operations that are allowed prior to AUTH. if not command in ['AUTH', 'EHLO', 'HELO', 'NOOP', 'RSET', 'QUIT']: if self.authenticator and not self.authenticated: self.push('530 Authentication required') return method = getattr(self, 'smtp_' + command, None) if not method: self.push('502 Error: command "%s" not implemented' % command) return method(arg) return else: if self.__state != self.DATA: self.push('451 Internal confusion') return # Remove extraneous carriage returns and de-transparency according # to RFC 821, Section 4.5.2. data = [] for text in line.split('\r\n'): if text and text[0] == '.': data.append(text[1:]) else: data.append(text) self.__data = NEWLINE.join(data) status = self.__server.process_message(self.username, self.__peer, self.__mailfrom, self.__rcpttos, self.__data) self.__rcpttos = [] self.__mailfrom = None self.__state = self.COMMAND self.set_terminator('\r\n') if not status: self.push('250 Ok') else: self.push(status)
def found_terminator(self): line = EMPTYSTRING.join(self.__line) print >> DEBUGSTREAM, 'Data:', repr(line) self.__line = [] if self.__state == self.COMMAND: if not line: self.push('500 Error: bad syntax') return method = None i = line.find(' ') if i < 0: command = line.upper() arg = None else: command = line[:i].upper() arg = line[i+1:].strip() method = getattr(self, 'lmtp_' + command, None) if not method: self.push('502 Error: command "%s" not implemented' % command) return method(arg) return else: if self.__state != self.DATA: self.push('451 Internal confusion') return # copied from smtpd.py without understanding what it does data = [] for text in line.split('\r\n'): if text and text[0] == '.': data.append(text[1:]) else: data.append(text) self.__data = NEWLINE.join(data) # process each RCPT TO separately for rcptto in self.__rcpttos: status = self.__server.process_message(self.__peer, self.__mailfrom, rcptto, self.__data) if not status: self.push('250 Ok') else: self.push(status) self.__rcpttos = [] self.__mailfrom = None self.__state = self.COMMAND self.set_terminator('\r\n')
def found_terminator(self): line = EMPTYSTRING.join(self.__line) logger.debug('found_terminator(): data: {0}'.format(repr(line))) self.__line = [] if self.__state == self.COMMAND: if not line: self.push('500 Error: bad syntax') return method = None i = line.find(' ') if (self.login_uname_authenticating or self.login_pass_authenticating or self.plain_authenticating or self.cram_authenticating): # If we are in an authenticating state, call the # method smtp_AUTH. arg = line.strip() command = 'AUTH' elif i < 0: command = line.upper() arg = None else: command = line[:i].upper() arg = line[i + 1:].strip() # White list of operations that are allowed prior to AUTH. if not command in ['AUTH', 'EHLO', 'HELO', 'NOOP', 'RSET', 'QUIT']: if not self.authenticated: self.push('530 Authentication required') self.close_quit() return method = getattr(self, 'smtp_' + command, None) if not method: self.push('502 Error: command "%s" not implemented' % command) return method(arg) return else: if self.__state != self.DATA: self.push('451 Internal confusion') return # Remove extraneous carriage returns and de-transparency according # to RFC 821, Section 4.5.2. data = [] for text in line.split('\r\n'): if text and text[0] == '.': data.append(text[1:]) else: data.append(text) self.__data = NEWLINE.join(data) status = self.__server.process_message( self.__peer, self.__mailfrom, self.__rcpttos, self.__data ) self.__rcpttos = [] self.__mailfrom = None self.__state = self.COMMAND self.set_terminator('\r\n') if not status: self.push('250 Ok') else: self.push(status)
def found_terminator(self): line = EMPTYSTRING.join(self.__line) if self.debug: self.logger.info('found_terminator(): data: %s' % repr(line)) self.__line = [] if self.__state == self.COMMAND: if not line: self.push('500 Error: bad syntax') return method = None i = line.find(' ') if self.authenticating: # If we are in an authenticating state, call the # method smtp_AUTH. arg = line.strip() command = 'AUTH' elif i < 0: command = line.upper() arg = None else: command = line[:i].upper() arg = line[i+1:].strip() # White list of operations that are allowed prior to AUTH. if not command in ['AUTH', 'EHLO', 'HELO', 'NOOP', 'RSET', 'QUIT']: if self.require_authentication and not self.authenticated: self.push('530 Authentication required') return method = getattr(self, 'smtp_' + command, None) if not method: self.push('502 Error: command "%s" not implemented' % command) return method(arg) return else: if self.__state != self.DATA: self.push('451 Internal confusion') return # Remove extraneous carriage returns and de-transparency according # to RFC 821, Section 4.5.2. data = [] for text in line.split('\r\n'): if text and text[0] == '.': data.append(text[1:]) else: data.append(text) self.__data = NEWLINE.join(data) status = self.__server.process_message( self.__peer, self.__mailfrom, self.__rcpttos, self.__data ) self.__rcpttos = [] self.__mailfrom = None self.__state = self.COMMAND self.set_terminator(b'\r\n') if not status: self.push('250 Ok') else: self.push(status)