Setup greylite with qmail

In this setup, greylite is a module in the UCSPI chain that anticipates qmail-smtpd.

Nota bene: some users reported to have problems with the STARTTLS command when greylite wraps qmailrocks combined with the JMS patch. If you want to stick with both you're forced to use greylite in proxy mode, which is reported to solve the problem.

Fetch, compile, install

  1. Fetch the last greylite release.
  2. Extract the software:
    tar xjvf greylite-VERSION.tar.bz2
    cd greylite-VERSION
    
  3. compile and install:
    make all install

Notes for special compilation

Several arguments can be appended to the command line for enabling compilation of different components. The general form is:

make all install ARGUM1 ARGUM2 ARGUM3 ...

WITH_GEOIP=yes enables support for GeoIP in suspicion rules.

WITH_DNSBLENV=yes enables the compilation of the dnsblenv module.

WITH_UCSPI2SOCKET=yes enables the compilation of the ucspi2socket module.

In greylite ≥ 3.0 the backend for storing data can be chosen. By default, SQLite is used. The following can be specified for changing this:

On some systems the libraries and headers of these softwares are placed in non-standard paths. These paths can then be pointed with two further make arguments: x_INCLUDE_DIR=/path and x_LIB_DIR=/path. Replace x with the name of the backend (MYSQL, PGSQL).

Setup in the system

  1. Setup the database depending on the backend you want to use:
  2. insert greylite in the qmail chain (the standard run file from lifewithqmail.org is used as example). Edit /var/service/qmail-smtp/run and insert the red block:
    ...
    /usr/local/bin/tcpserver -v -R -l "$LOCAL" \
       -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
       -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
       /usr/local/bin/greylite /var/qmail/bin/qmail-smtpd 2>&1
    
    then restart the service:
    svc -t /var/service/qmail-smtp
    
  3. greylite is transparent as long as the GREYLIST environment variable is not set, that is, it passes the control to qmail-smtpd without doing anything. The GREYLIST variable can be set from the CDB file. Edit the /etc/tcp.smtp file and insert the red block:
    ...
    :allow,GREYLIST=""
    
    don't forget to regenerate the rules file:
    cat /etc/tcp.smtp | tcprules /etc/smtp.cdb /tmp/tmprulesfile.cdb
    
    (or use make, if the Makefile is available).
    You can append more environment variables for greylite control, all comma-separated and with values delimited by quotes.

Done.