[Mimedefang] Greylisting Code on Wiki

Gordon Henderson gordon at drogon.net
Wed Dec 12 03:51:16 EST 2007

On Tue, 11 Dec 2007, David Eisner wrote:

> I'm thinking of implementing Greylisting with MIMEDefang. I noticed a
> few examples on the Wiki:
>  http://www.mimedefang.org/kwiki/index.cgi?Greylisting
>  http://www.mimedefang.org/kwiki/index.cgi?GreyListiningSQLite   [sic]
> Is anybody using the SQLite example?  I'm a little worried about this
> code, but I'm no expert, so perhaps people can allay my fears and
> explain why I'm wrong:

I took it as a base to develop my own.

> 1. As has been pointed out on the Wiki page, the first example, which
> uses Berkeley DB, doesn't lock the DB before using it.  This doesn't
> inspire confidence in either example.

I'm seeing other locking issues with sqLite too and am considering moving 
to mysql... I think when the system gets really busy, then there are 
situations when it's unable to write a new tripple into the database - I 
suspect that if I knew more about perl/DBI then I might be able to set a 
flag which says "wait a while/keep trying", but I don't. (any clues 

> 2.  Both versions (Berkeley DB and SQLite) use a "%Greylistpassed" hash
> to remember if a particular $MsgID has already passed so that, when this
> $MsgID is seen again (for another recipient, presumably) it isn't
> tempfailed again.  However, in the SQLite version, %Greylistpassed is
> never set, but only read.  This looks like an oversight, which makes me
> wonder whether the Berkeley DB version was translated to the SQLite
> version as an exercise, but not really tested.

I wasn't happy with it myself, so re-wrote bits of it to suit. I've since 
re-done it slightly. I store a triple of IPaddress/from/to

> 5. The SQLite version makes a DBI->connect() call every time
> filter_recipient() is called.  Isn't this something that would normally
> be done inside filter_initialze()?

I wish I knew more about how perl worked - I consider it a read mostly 
language ...

> If you do greylisting with MIMEDefang, and you're not using the Wiki
> code, what do you use (other than CanIt :-) ?  I am aware of this magnum
> opus: http://whatever.frukt.org/mimedefangfilter.text.shtml, which I'll
> slog through if I have to.  Any others?

My original efforts are at http://lion.drogon.net/greylisting/ and my Mk2 
which uses sqlite3 is at: http://lion.drogon.net/gl3

The glPurge script is run once a day, overnight and I stop 
sendmail/mimedefang (and make sure they're stopped!) before I run it 
otherwise it tends to see the same locking issues.



More information about the MIMEDefang mailing list