Commits

Zhang Huangbin  committed f2a304e

Use the same format of sender/recipient as LDAP backend.

  • Participants
  • Parent commits 8a60712

Comments (0)

Files changed (1)

File plugins/sql_user_restrictions.py

 #
 # Valid sender/recipient addresses:
 #
-#   - .*:           all addresses (user, domain, sub-domain)
-#   - domain.com:   single domain
-#   - .domain.com:  single domain and its all sub-domains
+#   - @.:           all addresses (user, domain, sub-domain)
+#   - @domain.com:   single domain
+#   - @.domain.com:  single domain and its all sub-domains
 #   - user@domain.com:  single email address
 
 import logging
             if all_allowed_recipients:
                 if recipient in all_allowed_recipients \
                    or recipient_domain in all_allowed_recipients \
-                   or '.' + recipient_domain in all_allowed_recipients \
-                   or '*' in all_allowed_recipients:
+                   or '@.' + recipient_domain in all_allowed_recipients \
+                   or '@.' in all_allowed_recipients:
                     return SMTP_ACTIONS['accept']
 
             all_rejected_recipients = [s.lower().strip() for s in rejected_recipients.split(',')]
             if all_rejected_recipients:
                 if recipient in all_rejected_recipients \
                    or recipient_domain in all_rejected_recipients \
-                   or '.' + recipient_domain in all_rejected_recipients \
-                   or '*' in all_rejected_recipients:
+                   or '@.' + recipient_domain in all_rejected_recipients \
+                   or '@.' in all_rejected_recipients:
                     return SMTP_ACTIONS['reject']
 
     # Get restriction rules for recipient
             if all_allowed_senders:
                 if sender in all_allowed_senders \
                    or sender_domain in all_allowed_senders \
-                   or '.' + sender_domain in all_allowed_senders \
-                   or '.*' in all_allowed_senders:
+                   or '@.' + sender_domain in all_allowed_senders \
+                   or '@.' in all_allowed_senders:
                     return SMTP_ACTIONS['accept']
 
             all_rejected_senders = [s.lower().strip() for s in rejected_senders.split(',')]
             if all_rejected_senders:
                 if sender in all_rejected_senders \
                    or sender_domain in all_rejected_senders \
-                   or '.' + sender_domain in all_rejected_senders \
-                   or '*' in all_rejected_senders:
+                   or '@.' + sender_domain in all_rejected_senders \
+                   or '@.' in all_rejected_senders:
                     return SMTP_ACTIONS['reject']
 
     return SMTP_ACTIONS['default']