1 (edited by vsolomatin 2016-02-06 06:24:21)

Topic: iRedAdmin-Pro v2.5.0 (LDAP) cleanup greylisting_whitelist_domains

==================== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.4
- Linux/BSD distribution name and version: CentOS Linux release 7.2.1511 (Core)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- Related log if you're reporting an issue:
====

1. Update iRedAPD from version 1.7.0 to 1.8.0
2. In iRedAdmin-Pro v2.5.0 (LDAP) go to domain or user greylisting settings
3. Click to "save changes"
4. No data in "iredapd.greylisting_whitelist_domains" table

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedAdmin-Pro v2.5.0 (LDAP) cleanup greylisting_whitelist_domains

Per-domain and per-user greylisting whitelists updates "iredapd.greylisting_whitelists", not "iredapd.greylisting_whitelist_domains".

3 (edited by vsolomatin 2016-02-11 01:45:50)

Re: iRedAdmin-Pro v2.5.0 (LDAP) cleanup greylisting_whitelist_domains

Per-domain and per-user greylisting whitelists updates should not delete data from "iredapd.greylisting_whitelist_domains", but it happens. (DELETE FROM greylisting_whitelist_domains WHERE 1=1)

MariaDB queries log:

160210 19:26:11       43 Connect    iredadmin@localhost as anonymous on iredadmin
           43 Query    SET NAMES utf8
           43 Query    set autocommit=0
           43 Query    SELECT * FROM sessions WHERE session_id='157f1687a9f238098c33b1de0f096f13c92e700c'
           43 Query    commit
           43 Query    SELECT * FROM sessions WHERE session_id='157f1687a9f238098c33b1de0f096f13c92e700c'
           43 Query    commit
           43 Query    UPDATE sessions SET atime = '2016-02-10 19:26:11' WHERE session_id='157f1687a9f238098c33b1de0f096f13c92e700c'
           43 Query    commit
           44 Connect    iredapd@localhost as anonymous on iredapd
           44 Query    SET NAMES utf8
           44 Query    set autocommit=0
           44 Query    DELETE FROM greylisting WHERE account = '@lexample.com' AND sender = '@.'
           44 Query    commit
           44 Query    INSERT INTO greylisting (priority, active, account, sender, sender_priority) VALUES (60, 0, '@lexample.com', '@.', 0)
           44 Query    SELECT last_insert_id()
           44 Query    commit
           44 Query    DELETE FROM greylisting_whitelist_domains WHERE 1=1
           44 Query    commit
           44 Query    DELETE FROM greylisting_whitelists WHERE account = '@lexample.com'
           44 Query    commit
           44 Quit    
           43 Query    SELECT * FROM sessions WHERE session_id='157f1687a9f238098c33b1de0f096f13c92e700c'
           43 Query    commit

libs/ldaplib/domain.py

    # Update domain profile.
    # data = web.input()
    def update(self, profile_type, domain, form):
.....
        elif profile_type == 'greylisting':
            if session.get('enable_iredapd'):
                qr = iredapd_greylist.update_greylist_settings_from_form(account='@' + self.domain, form=form)
                return qr

libs/ldaplib/user.py

    def update(self, profile_type, mail, form):
.....
        elif profile_type == 'greylisting':
            if session.get('enable_iredapd'):
                qr = iredapd_greylist.update_greylist_settings_from_form(account=mail, form=form)
                return qr

libs/iredapd/greylist.py

def update_greylist_settings_from_form(account, form):
.....
    qr = gl.update_greylist_whitelist_domains(domains=wl_domains)
    if not qr[0] is True:
        return qr

    return q

libs/iredapd/greylist.py

    def update_greylist_whitelist_domains(self, domains=None):
        """Update greylisting whitelist domains for specified account.

        domains -- must be a iterable object. e.g. list, tuple."""
        # Delete existing records first
        try:
            self.db.delete('greylisting_whitelist_domains', where='1=1')
        except Exception, e:
            return (False, str(e))

4

Re: iRedAdmin-Pro v2.5.0 (LDAP) cleanup greylisting_whitelist_domains

Bug. Here's patch to fix it:

diff -r 428bdc6e7e6f libs/iredapd/greylist.py
--- a/libs/iredapd/greylist.py    Fri Feb 05 20:11:57 2016 +0900
+++ b/libs/iredapd/greylist.py    Fri Feb 12 21:53:39 2016 +0800
@@ -44,15 +44,16 @@
         return qr
 
     # Update greylisting whitelist domains.
-    wl_domains = set()
-    lines = form.get('whitelist_domains', '').splitlines()
-    for line in lines:
-        if iredutils.is_domain(line):
-            wl_domains.add(str(line).lower())
+    if account == '@.':
+        wl_domains = set()
+        lines = form.get('whitelist_domains', '').splitlines()
+        for line in lines:
+            if iredutils.is_domain(line):
+                wl_domains.add(str(line).lower())
 
-    qr = gl.update_greylist_whitelist_domains(domains=wl_domains)
-    if not qr[0] is True:
-        return qr
+        qr = gl.update_greylist_whitelist_domains(domains=wl_domains)
+        if not qr[0] is True:
+            return qr
 
     # Update greylisting whitelists.
     whitelists = []

I will send you a patched version immediately.

5

Re: iRedAdmin-Pro v2.5.0 (LDAP) cleanup greylisting_whitelist_domains

Thank you.