Copyright (C) 2004 Peter Conrad <conrad@tivano.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
qmail-spp (http://qmail-spp.sf.net/) is a patch for D. J. Bernstein's "qmail" MTA package. The patch enables "plugin" programs to be run at various stages during an SMTP protocol exchange.
"greylisting" (http://greylisting.org/, http://projects.puremagic.com/greylisting/) is the concept of temporarily rejecting an incoming email, unless delivery of the same email has been tried before. The idea of greylisting is that typical malware like spam senders or email worms / virii typically do not implement a proper mailqueue and will therefore not try delivery again if the first attempt failed. Thus, greylisting can stop SPAM and/or malware at the earliest possible time, i. e. before the actual content is being received by the target MTA.
Guess what - this package combines both by implementing a qmail-spp-style plugin providing greylisting functionality.
The operation of the plugin is (almost) completely driven by environment variables. It is invoked by qmail-smtpd after each "RCPT TO:" SMTP command. At that time, all three values required for the greylisting decision are set:
This plugin requires the environment variable GL_DATABASE to contain the full path to a readable and writeable (for qmail-smtpd) file that will be used as the greylisting database. Set this variable e. g. before invoking tcpserver for qmail-smtpd.
In addition, if one of the env variables RELAYCLIENT or GL_WHITELISTED is set, the plugin exits immediately (see the page on whitelisting at http://greylisting.org/whitelisting.shtml). If you run your qmail-smtpd via tcpserver, you can whitelist specific IP numbers using tcprules (1). A file containing a list of IP numbers that should be whitelisted can be found at http://cvs.puremagic.com/viewcvs/greylisting/schema/whitelist_ip.txt (a copy of revision 1.5 is available in the file "whitelist_ip.txt").
Three more environment variables are available to (optionally) tweak certain timeout values used by this plugin:
The current implementation is pretty much BETA quality. Use at your own risk!
Care has been taken to make the plugin fail in a safe way: in case of an error, an incoming email will most likely be accepted (although an error message may be logged by qmail-smtpd). So in case of a severe problem, SPAM would get through, but no important mail would be lost.
The (default) flat-file database format was chosen for its straightforward and lean implementation. It is anything but efficient, so don't use it for medium- or even high-volume sites.
In version 0.2 I have added two more database implementations based on Berkeley DB (v. 4.0) and SQLite (v. 2.x).
The whitepaper on greylisting (wow, a multicolor project! :-) mentions some improvements / optimizations regarding servers that implement "callback" checks for the envelope sender address. These are not implemented (yet).
This package should be available at http://www.unix-ag.uni-kl.de/~conrad/greylisting/
The sources are managed using the GNU Arch revision control system. you can check out a copy using
tla register-archive conrad@tivano.de--2004 \ http://www.unix-ag.uni-kl.de/~conrad/Archives/conrad@tivano.de--2004 tla grab http://www.unix-ag.uni-kl.de/~conrad/greylisting/releases--0.2
Simply unpack the sources and type "make" in the top-level directory of the distribution. This will create a subdirectory ",,build", in which the build will take place.
By default, the flat-file database implementation will be used. If you want to use one of the other implementations, specify the "DB_IMPL" parameter to the make command, i. e. "make DB_IMPL=bdb" for Berkeley DB or "make DB_IMPL=sqlite" for the SQLite interface. Needless to say, the respective libraries and header files must be present on your system. See
README.db-file,
README.db-bdb or
README.db-sqlite
for more info on these implementations.
In any case, the resulting executable will reside in ",,build/src/greylisting-spp".
A "make install" target is *not* provided, because the installation process requires some manual intervention as well as some decisions you'll have to make yourself. Basically, you'll have to perform the steps enumerated below. For RPM-based systems, a .spec file is provided (assuming a qmail installation under /var/qmail). The RPM-based installation requires some manual work as well.
Note: If you're upgrading your RPM-based installation with "rpm -U" you'll have to manually edit "control/smtpplugins" afterwards. For some reason rpm executes the "preun" script *after* the "post" script...
GL_DATABASE=/var/qmail/greylisting-db export GL_DATABASE tcpserver -R -v -x /etc/tcprules.smtpd.cdb -c 20 0 smtp qmail-smtpd 2>&1Don't forget to restart the service if required!
[auth] [helo] [mail] [rcpt] plugins/greylisting-spp
If you want to create your own database interface, take a look at README.dbapi and "src/dp-api.h". Please let me know if you're successful.