Copyright (C) 2004-2007,2011 Peter Conrad <email@example.com>
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 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.16 is available in the file "whitelist_ip.txt").
Three more environment variables are available to (optionally) tweak certain timeout values used by this plugin:
Another two environment variables can be used to configure the amount of logging output:
The current implementation has been in productive use at several low-volume sites for more than two years now. This applies to the plain-text as well as the SQLite backends. So far, no unexpected problems have occurred. In any case you should be aware that you use this software 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 version 2. I've also improved support for EZMLM-style VERPs (i. e. per-message unique sender address on a mailing list, like securityfocus.com).
In version 0.3 I have added some improvements / optimizations regarding servers that implement "callback" checks for the envelope sender address. This requires version 0.40 (or later) of the qmail-spp patch!
Version 1.0 is identical to 0.3
Version 1.0.1 fixes a bug when GL_DEBUG and RELAYCLIENT are both set. Thanks to Jacek Trzcinski for the patch!
Version 1.1 adds an sqlite3 backend, and contains minor code cleanups.
This package should be available at http://www.unix-ag.uni-kl.de/~conrad/greylisting/greylisting-spp-1.1.tar.gz
The sources are managed using the GNU Arch revision control system. You can check out a copy using
tla register-archive firstname.lastname@example.org \ http://www.unix-ag.uni-kl.de/~conrad/Archivesemail@example.com tla grab http://www.unix-ag.uni-kl.de/~conrad/greylisting/releases--1.1
Here's my PGP-keys if you want to check the signatures.
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.
Hint: apparently you need "GNU make", which may be installed under a different name on your platform. Or not at all.
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
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.
GL_DATABASE=/var/qmail/greylisting/db-file 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/db-api.h". Please let me know if you're successful.