1 (edited by peterva 2010-10-01 21:26:34)

Topic: Whitelisting/Blacklisting

I've managed to setup iRedAdmin-Pro today, and everything seems to work fine except for the whitelisting and blacklisting menu-options. When I open either one of them, I get an 'internal server error'. If necessary, I'll provide whatever logs/configs needed smile

Anyone know what I'm missing?

----

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

2

Re: Whitelisting/Blacklisting

Can you post related log in Apache error_log?

3

Re: Whitelisting/Blacklisting

Well, that was probably the only log I didn't check, but it contained my error smile
Seems my database hasn't got the proper grants. I'll try to fix this during the weekend and I'll post back if it worked.

===

[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0] Traceback (most recent call last):
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/application.py", line 242, in process
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return self.handle()
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/application.py", line 233, in handle
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return self._delegate(fn, self.fvars, args)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/application.py", line 415, in _delegate
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return handle_class(cls)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/application.py", line 390, in handle_class
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return tocall(*args)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/share/apache2/iredadmin/controllers/base.py", line 53, in proxyfunc
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return func(self, *args, **kw)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/share/apache2/iredadmin/controllers/policyd/blacklist.py", line 39, in GET
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     total, entries = blacklistLib.list(listcategory=self.listcategory, cur_page=self.cur_page)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/share/apache2/iredadmin/libs/policyd/blacklist.py", line 46, in list
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     self.count = self.db.query("""SELECT COUNT(*) as total FROM %s""" % (dbtable) )
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/db.py", line 610, in query
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     db_cursor = self._db_cursor()
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/db.py", line 541, in _db_cursor
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return self.ctx.db.cursor()
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/db.py", line 482, in _getctx
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     self._load_context(self._ctx)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/db.py", line 493, in _load_context
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     ctx.db = self._connect(self.keywords)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/local/lib/python2.6/dist-packages/web.py-0.34-py2.6.egg/web/db.py", line 521, in _connect
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return self.db_module.connect(**keywords)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in Connect
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     return Connection(*args, **kwargs)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0]     super(Connection, self).__init__(*args, **kwargs2)
[Fri Oct 01 19:38:27 2010] [error] [client 2001:7b8:1508:0:a1d1:3abc:b450:48a0] OperationalError: (1045, "Access denied for user 'policyd'@'localhost' (using password: YES)")

4

Re: Whitelisting/Blacklisting

I'm currently having a problem using an external MySQL server.

[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx] Traceback (most recent call last):
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/application.py", line 242, in process
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return self.handle()
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/application.py", line 233, in handle
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return self._delegate(fn, self.fvars, args)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/application.py", line 415, in _delegate
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return handle_class(cls)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/application.py", line 390, in handle_class
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return tocall(*args)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/share/apache2/iredadmin/controllers/base.py", line 34, in proxyfunc
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return func(self, *args, **kw)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/share/apache2/iredadmin/controllers/policyd/whitelist.py", line 19, in GET
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     total, entries = whitelistLib.list(listcategory=self.listcategory, cur_page=self.cur_page,)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/share/apache2/iredadmin/libs/policyd/whitelist.py", line 30, in list
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     self.count = self.db.query("""SELECT COUNT(*) as total FROM %s""" % (mapCategoryToTable[listcategory]) )
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/db.py", line 610, in query
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     db_cursor = self._db_cursor()
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/db.py", line 541, in _db_cursor
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return self.ctx.db.cursor()
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/db.py", line 482, in _getctx
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     self._load_context(self._ctx)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/db.py", line 493, in _load_context
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     ctx.db = self._connect(self.keywords)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/web/db.py", line 521, in _connect
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return self.db_module.connect(**keywords)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in Connect
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     return Connection(*args, **kwargs)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]     super(Connection, self).__init__(*args, **kwargs2)
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx] OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
[Tue Apr 05 15:28:53 2011] [error] [client xxx.xx.xxx.xx]

For whatever reason it tried to connect to localhost using a socket even though I have the appropriated section on the settings.ini file:


[policyd]

# Enable policyd integration: True, False.
enabled = True

host = mysql01
port = 3306
db = postfixpolicyd
user = postfix-policyd
passwd = mypass


I've double checked my user has permissions.

Cheers.

5

Re: Whitelisting/Blacklisting

atros wrote:

host = mysql01

Log says iRedAdmin can't connect to server via unix socket, can you try to use IP address of hostname here?

6 (edited by atros 2011-04-05 11:51:40)

Re: Whitelisting/Blacklisting

ZhangHuangbin wrote:
atros wrote:

host = mysql01

Log says iRedAdmin can't connect to server via unix socket, can you try to use IP address of hostname here?

I actually found a bug with 2 files and fixed them. It was trying to connect to localhost because that's the default value when it creates the object.

/usr/share/apache2/iredadmin/libs/policyd/core.py

            self.db = web.database(
                dbn='mysql',
                 db=cfg.policyd.get('db', 'policyd'),
                user=cfg.policyd.get('user', 'policyd'),
                passwd=cfg.policyd.get('passwd'),
                charset='utf8',
            )

I added host=cfg.policyd.get('host','policyd'), so that it actually reads the information from settings.ini and now it's working.

            self.db = web.database(
                dbn='mysql',
                host=cfg.policyd.get('host','policyd'),
                db=cfg.policyd.get('db', 'policyd'),
                user=cfg.policyd.get('user', 'policyd'),
                passwd=cfg.policyd.get('passwd'),
                charset='utf8',
            )

Same applied to: /usr/share/apache2/iredadmin/libs/amavisd/core.py I've also added the corresponding line there:

            self.db = web.database(
                dbn='mysql',
                host=cfg.amavisd.get('host', 'policyd'),
                db=cfg.amavisd.get('db', 'policyd'),
                user=cfg.amavisd.get('user', 'policyd'),
                passwd=cfg.amavisd.get('passwd'),
                charset='utf8',
            )

That also fixes the statistics display on the main page. After I made the change to the amavis part the top senders and recipients started working.

Cheers.

7

Re: Whitelisting/Blacklisting

Thanks very much for your sharing.
What a stupid mistake i made.

8

Re: Whitelisting/Blacklisting

Will you update this too in 0.7.1 ?:D

9

Re: Whitelisting/Blacklisting

Jochie wrote:

Will you update this too in 0.7.1 ?:D

This is iRedAdmin-Pro issue, not a iRedMail issue.