Zhang Huangbin avatar Zhang Huangbin committed d1b5e11

Use None as default value instead of empty dict.

Comments (0)

Files changed (5)

libs/ldaplib/modeler.py

                          'recipient': recipient,
                          'recipient_domain': recipient.split('@', 1)[-1],
                          'sender_dn': None,
-                         'sender_ldif': {},
+                         'sender_ldif': None,
                          'recipient_dn': None,
-                         'recipient_ldif': {}}
+                         'recipient_ldif': None}
 
         # TODO Perform addition plugins which don't require sender/recipient info
         # e.g.

plugins/ldap_amavisd_block_blacklisted_senders.py

     smtp_session_data = kwargs['smtp_session_data']
     recipient_ldif = kwargs['recipient_ldif']
 
+    # Return if recipient doesn't have objectClass=amavisdAccount.
+    if not recipient_ldif:
+        return 'DUNNO (No recipient LDIF data)'
+
     if not 'amavisAccount' in recipient_ldif.get('objectClass', []):
         return 'DUNNO (Not a amavisdAccount object)'
 

plugins/ldap_expired_password.py

 # Force mail user to change password in how many days. Default is 90.
 EXPIRED_DAYS = 90
 
-
 def restriction(**kwargs):
     sender_ldif = kwargs['sender_ldif']
 
-    if not 'mailUser' in sender_ldif['objectClass']:
-        return 'DUNNO Not a mail user'
+    if not sender_ldif:
+        return 'DUNNO (No sender LDIF data)'
+
+    if not 'mailUser' in sender_ldif.get('objectClass', []):
+        return 'DUNNO (Not a local mail user)'
 
     # Check password last change days
     last_changed_day = int(sender_ldif.get('shadowLastChange', [0])[0])

plugins/ldap_maillist_access_policy.py

     recipient_ldif = kwargs['recipient_ldif']
 
     # Return if recipient is not a mail list object.
+    if not recipient_ldif:
+        return 'DUNNO (No recipient LDIF data)'
+
     if not 'mailList' in recipient_ldif.get('objectClass', []):
-        return 'DUNNO (Not mail list)'
+        return 'DUNNO (Not a mail list account)'
 
     conn = kwargs['conn']
     base_dn = kwargs['base_dn']

plugins/ldap_recipient_restrictions.py

 def restriction(**kwargs):
     sender_ldif = kwargs['sender_ldif']
     if not sender_ldif:
-        return 'DUNNO (Sender is Not a local mail user.)'
+        return 'DUNNO (No sender LDIF data)'
 
     # Get recipient address.
     smtp_session_data = kwargs['smtp_session_data']
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.