Commits

Zhang Huangbin committed 7273b0e

Fix bypassing whitelisted sender issue in plugin: block_amavisd_blacklisted_senders. Thanks HoHo for his report.

Comments (0)

Files changed (4)

+iRedAPD-1.3.2:
+    * Fix bypassing whitelisted sender issue in plugin:
+      block_amavisd_blacklisted_senders. Thanks HoHo for his report.
+
 iRedAPD-1.3.1:
     * Fix defective sender address list in plugin:
       block_amavisd_blacklisted_senders.
 import logging
 import daemon
 
-__version__ = "1.3.1"
+__version__ = "1.3.2"
 
 sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/plugins-rr')
 
 import logging
 import daemon
 
-__version__ = "1.3.1"
+__version__ = "1.3.2"
 
 sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/plugins')
 

src/plugins/block_amavisd_blacklisted_senders.py

         list_senders += ['@.' + '.'.join(splited_sender_domain)]
         splited_sender_domain.pop(0)
 
-    # Get value of amavisBlacklistedSender.
+    # Get list of amavisBlacklistedSender.
     blSenders = [v.lower() for v in ldapRecipientLdif.get('amavisBlacklistSender', [])]
 
+    # Get list of amavisWhitelistSender.
+    wlSenders = [v.lower() for v in ldapRecipientLdif.get('amavisWhitelistSender', [])]
+
+    #
+    # Process whitelisted senders first.
+    #
+
+    # Bypass whitelisted senders.
+    if len(set(list_senders) & set(wlSenders)) > 0:
+        return 'DUNNO'
+
+    # Reject blacklisted senders.
     if len(set(list_senders) & set(blSenders)) > 0:
-        # Reject blacklisted senders.
         return 'REJECT Not Authorized'
-    else:
-        return 'DUNNO'
+
+    # Neither blacklisted nor whitelisted.
+    return 'DUNNO'