DSPAM with multi-domain canned notices

Recently I setup DSPAM, a content-based spam filter designed for multi-user enterprise systems. It works very well but it is missing a small piece of functionality: the canned notices can not be used in a multi-domain environment.

The reason that the canned notices can not be used in a multi-domain environment is due to the usage of a single $u variable which gets replaced by DSPAM with the username. This is obviously not going to work in a hosted environment where DSPAM filters email from many different domains and where users use their email address as their username.

Let’s take a look at the header of firstrun.txt

How are you going to make the “To:” part work for John.Doe@example.org and Jane.Doe@foobar.org? With only $u to play with, there seems no way that you can make DSPAM use example.org for John Doe and at the same time make DSPAM use foobar.org for Jane Doe. Luckily there is a solution (at least it works for me, use at own risk).

After some digging in the DSPAM code I came up with the following patch:

Steps to make this work

Basically you need to do two runs: the first one is with the patch applied with the LOGDEBUG statements uncommented. If it works then you rebuild DSPAM with the patch applied with the LOGDEBUG statements commented. The reason is that the LOGDEBUG statements generate quite a lot of lines in the debug logfile and that’s probably not what you want.

Secondly you need to add ‘$d’ everywhere in the canned notices where you want a domain name to appear.

For example, you could change firstrun.txt from:

to this version:

In the case where John Doe’s username is John.Doe@example.org this results in the following email sent to John Doe:

Once you have installed DSPAM with the patch and the modified canned notices and you have made sure that notifications is enabled in dspam.conf, then you should see the following messages in dspam.debug when the LOGDEBUG statements are uncommented:

When you see similar messages, congratulations, it seems to work. Now comment the LOGDEBUG statements in the patch, apply again to a fresh copy of the DSPAM 3.10.2 source, make the changes to the canned notices, rebuild and reinstall.

You should now be able to use the canned notices in the multi-user and multi-domain environment. Enjoy!

OpenLDAP and the Refint Overlay

Recently the OpenLDAP project released version 2.4.34. It contains tons of bug fixes and improvements like the lightening fast LMDB backend (so you don’t need Oracle’s BerkeleyDB anymore).

One of the features of OpenLDAP is the Refint overlay: “The Referential Integrity overlay can be used with a backend database such as slapd-mdb(5) to maintain the cohesiveness of a schema which utilizes reference attributes”.

Basically it means that if you for example delete or rename a user and that user is referenced elsewhere, the Refint overlay makes sure that the reference is deleted or renamed too.

One thing to realize is that the Refint overlay only works on DNs. So you must use DNs as references or else it won’t work.