[Spambayes-checkins] spambayes/scripts sb_imapfilter.py,1.55,1.56

Tony Meyer anadelonbrin at users.sourceforge.net
Tue Mar 29 09:18:33 CEST 2005


Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1393/scripts

Modified Files:
	sb_imapfilter.py 
Log Message:
Improve cram-md5 authentication.

Don't mangle from lines.

See also:

http://mail.python.org/pipermail/spambayes/2005-February/016327.html

Index: sb_imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_imapfilter.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** sb_imapfilter.py	29 Mar 2005 03:51:23 -0000	1.55
--- sb_imapfilter.py	29 Mar 2005 07:18:30 -0000	1.56
***************
*** 82,86 ****
  import time
  import sys
- import hmac
  import getopt
  import types
--- 82,85 ----
***************
*** 195,208 ****
          return "".join(buffer)
  
-     def authenticate_cram_md5(self, username, pwd):
-         """Authenticate (login) with CRAM-MD5.
- 
-         See RFC 2195 and SpamBayes patch #1169939
-         """
-         def cram_md5(response):
-             return " ".join([username,
-                              hmac.HMAC(pwd, response).hexdigest()])
-         self.authenticate('CRAM-MD5', cram_md5)
- 
      def login(self, username, pwd):
          """Log in to the IMAP server, catching invalid username/password."""
--- 194,197 ----
***************
*** 210,214 ****
          try:
              if 'AUTH=CRAM-MD5' in self.capabilities:
!                 self.authenticate_cram_md5(username, pwd)
              else:
                  BaseIMAP.login(self, username, pwd)  # superclass login
--- 199,203 ----
          try:
              if 'AUTH=CRAM-MD5' in self.capabilities:
!                 self.login_cram_md5(username, pwd)
              else:
                  BaseIMAP.login(self, username, pwd)  # superclass login
***************
*** 586,593 ****
          # the case where the data was unparsable, so we haven't done any
          # filtering, and we are not actually a proper email.Message object.
          if self.invalid:
              return self._force_CRLF(self.invalid_content)
          else:
!             return message.SBHeaderMessage.as_string(self, unixfrom)
  
      recent_re = re.compile(r"\\Recent ?| ?\\Recent")
--- 575,585 ----
          # the case where the data was unparsable, so we haven't done any
          # filtering, and we are not actually a proper email.Message object.
+         # We also don't mangle the from line; the server must take care of
+         # this.
          if self.invalid:
              return self._force_CRLF(self.invalid_content)
          else:
!             return message.SBHeaderMessage.as_string(self, unixfrom,
!                                                      mangle_from_=False)
  
      recent_re = re.compile(r"\\Recent ?| ?\\Recent")



More information about the Spambayes-checkins mailing list