Zhang Huangbin avatar Zhang Huangbin committed 2cfe01e

Code cleanup.

Comments (0)

Files changed (3)

     def handle_accept(self):
         conn, remote_addr = self.accept()
         logging.debug("Connect from %s, port %s." % remote_addr)
-        channel = PolicyChannel(conn,
-                                plugins=self.loaded_plugins,
-                                plugins_for_sender=self.plugins_for_sender,
-                                plugins_for_recipient=self.plugins_for_recipient,
-                                plugins_for_misc=self.plugins_for_misc,
-                                sender_search_attrlist=self.sender_search_attrlist,
-                                recipient_search_attrlist=self.recipient_search_attrlist,
-                               )
+        channel = PolicyChannel(
+            conn,
+            plugins=self.loaded_plugins,
+            plugins_for_sender=self.plugins_for_sender,
+            plugins_for_recipient=self.plugins_for_recipient,
+            plugins_for_misc=self.plugins_for_misc,
+            sender_search_attrlist=self.sender_search_attrlist,
+            recipient_search_attrlist=self.recipient_search_attrlist,
+        )
 
 
 def main():

libs/ldaplib/modeler.py

         except Exception, e:
             logging.debug('Error while closing connection: %s' % str(e))
 
-    def handle_data(self, smtp_session_data,
+    def handle_data(self,
+                    smtp_session_data,
                     plugins=[],
                     plugins_for_sender=[],
                     plugins_for_recipient=[],
                          'sender_ldif': None,
                          'recipient_dn': None,
                          'recipient_ldif': None,
-                         }
+                        }
 
         if get_sender_ldif:
             senderDn, senderLdif = conn_utils.get_account_ldif(
             plugin_kwargs['sender_dn'] = senderDn
             plugin_kwargs['sender_ldif'] = senderLdif
 
-            for plugin in plugins_for_sender:
-                action = conn_utils.apply_plugin(plugin, **plugin_kwargs)
-                if not action.startswith('DUNNO'):
-                    return action
-
         if get_recipient_ldif:
             recipientDn, recipientLdif = conn_utils.get_account_ldif(
                 conn=self.conn,
             plugin_kwargs['recipient_dn'] = recipientDn
             plugin_kwargs['recipient_ldif'] = recipientLdif
 
-            for plugin in plugins_for_recipient:
-                action = conn_utils.apply_plugin(plugin, **plugin_kwargs)
-                if not action.startswith('DUNNO'):
-                    return action
-
-        for plugin in plugins_for_misc:
+        for plugin in plugins:
             action = conn_utils.apply_plugin(plugin, **plugin_kwargs)
             if not action.startswith('DUNNO'):
                 return action

plugins/ldap_maillist_access_policy.py

                 base_dn,
                 1, # 1 == ldap.SCOPE_ONELEVEL
                 "(&(objectClass=mailDomain)(|(domainName=%s)(domainAliasName=%s)))" % (recipient_domain, recipient_domain),
-                ['domainName', 'domainAliasName', ]
+                ['domainName', 'domainAliasName', ],
             )
             if qr:
                 dn, entries = qr[0]
         # Bypass all users under the same domain and sub domains.
         returned = False
         for d in recipient_alias_domains:
-            if sender.endswith(d) or sender.endswith('.' + d):
+            if sender.endswith('@' + d) or sender.endswith('.' + d):
                 return 'DUNNO (Access policy: subdomain (%s))' % (d)
 
         if returned is False:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.