Bruce's qmail Patches


This page contains links to several of the patches I have made to qmail.


qmail-1.03-fastremote-3.patch

While sending individual messages with qmail consumes very little CPU, sending multiple large messages in parallel can effectively DoS a sender due to inefficiencies in qmail-remote's "blast" function. In its original form, this function scans the message one byte at a time to escape leading periods and newlines, as required by SMTP.

This patch modifies blast to scan the message in larger chunks. I have benchmarked before and after, and the change reduced the CPU time consumed by qmail-remote by a factor of 10.

The original version of this patch had two bugs that would corrupt data for any message larger than 4kB.

qmail-1.03-qmtpc-mailroutes-2.0.patch

This patch modifies qmail-remote to try to send messages using QMTP when it determines it is possible, based on either DNS records (via MXPS) or the contents of /var/qmail/control/mailroutes.

It is based on this patch released on 2001-01-17 by Johan Almqvist. Unfortunately, neither his web page nor the original patch is no longer online. I modified the patch to correct problems with sending using QMTP from or to addresses that required quoting in SMTP. Johan's patch was based in turn on this patch by Russell Nelson

qmail-1.03-autouidgid.patch

This patch modifies qmail to make it determine its UID/GID number configuration from the ownership of set of files in /var/qmail/owners. As originally written, qmail hard-codes the UID/GID numbers as constants at compile time.

qmail-1.03-queuevar.patch

This patch causes any qmail program that would run qmail-queue to look for an environment variable $QMAILQUEUE. If it is present, it is used in place of the string "bin/qmail-queue" when running qmail-queue. This could be used, for example, to add a program into the qmail-smtpd->qmail-queue pipeline that could do filtering, rewrite broken headers, etc.

qmail-1.03-syncdir.patch
syncdir.c

These two files (a trivial configuration patch and a C source) together modify the behavior of qmail to cause all directory operations (such as creating and deleting files) to effectively become synchronous. It acts as a wrapper for the Linux system calls that executes a fsync(2) on the directory being modified after the actual system call completes successfully.