Commits

Zhang Huangbin  committed fa6492c

Use lower case of sender, recipient, sasl_username.

  • Participants
  • Parent commits ff8a66f

Comments (0)

Files changed (3)

File libs/ldaplib/modeler.py

                          'sender_domain': sender.split('@', 1)[-1],
                          'recipient': recipient,
                          'recipient_domain': recipient.split('@', 1)[-1],
+                         'sasl_username': smtp_session_data.get('sasl_username', '').lower(),
                          'sender_dn': None,
                          'sender_ldif': None,
                          'recipient_dn': None,

File libs/sql/modeler.py

         if not plugins:
             return 'DUNNO'
 
+        sender = smtp_session_data['sender'].lower()
+        recipient = smtp_session_data['recipient'].lower()
+
         plugin_kwargs = {'smtp_session_data': smtp_session_data,
                          'conn': self.cursor,
-                         'sender': smtp_session_data['sender'],
-                         'recipient': smtp_session_data['recipient'],
-                         'sender_domain': smtp_session_data['sender'].split('@')[-1],
-                         'recipient_domain': smtp_session_data['recipient'].split('@')[-1],
+                         'sender': sender,
+                         'recipient': recipient,
+                         'sender_domain': sender.split('@')[-1],
+                         'recipient_domain': recipient.split('@')[-1],
+                         'sasl_username': smtp_session_data.get('sasl_username', '').lower(),
                         }
 
         # TODO Get SQL record of mail user or mail alias before applying plugins

File plugins/reject_sender_login_mismatch.py

     ALLOWED_LOGIN_MISMATCH_SENDERS = []
 
 def restriction(**kwargs):
-    # The sender appears in 'From:' header.
     sender = kwargs['sender']
-
-    # Username used to perform SMTP auth
-    sasl_username = kwargs['smtp_session_data'].get('sasl_username', '').lower()
+    sasl_username = kwargs['sasl_username']
 
     logging.debug('Allowed SASL username: %s' % ', '.join(ALLOWED_LOGIN_MISMATCH_SENDERS))
     logging.debug('Sender: %s, SASL username: %s' % (sender, sasl_username))