3.4 Patching Qmail

Dan's license for qmail forbids the distribution of modified versions of qmail, so many people offer add-ons and patches that you can apply to qmail yourself. Add-ons are distributed as installable packages that you download and install like any other package, but patches are distributed as text files of differences between the original and the patched version of qmail, as created by the diff utility. You don't need any patches to get qmail going (other than the errno patch for recent Linux versions), but because so many useful changes are distributed as patches, nearly everyone uses a few of them, so you should be prepared to use them.

The patch program, distributed with most Unix-like systems, reads the patch files and applies the changes. If your system doesn't have it, it's available for download from the Free Software Foundation at http://www.fsf.org/software/patch/patch.html. To apply a patch to a package, be sure the source code for the package is stored in a subdirectory of the current directory with the package's usual name (such as qmail-1.03), then feed the patch file to patch:

$ patch < some-patch.txt

patch produces a chatty report of its progress. Patch files invariably contain context diffs, so patch warns you if the file you're patching appears not to match the one on which the patch is based. You must look at the rejected patches in the source directory with filenames like filename.rej and figure out where the patches should go. Occasionally when you're applying multiple patches to the same set of files, the patches can collide, but for the most part, the useful patches to qmail apply without trouble. Once a patch is applied, rebuild and reinstall the package from the patched source code.

If you're installing the recommended netqmail package, you've already patched the source. Netqmail includes a patch file called netqmail-1.05.patch that is automatically applied by ./collate.sh.If you want to try patching qmail, a good patch to start with is the QMAILQUEUE patch, available at http://www.qmail.org/qmailqueue-patch. (Netqmail users needn't bother, because it's already applied.) It's quite small but very useful. Once you've applied the patch, any qmail component that calls qmail-queue to queue a mail message checks the QMAILQUEUE environment variable and if it's set, uses it as the name of a program to run instead. This makes it easy to insert filters of various sorts into qmail's processing without having to add special code to individual programs.

Now that you've built and installed qmail, daemontools, and perhaps other add-on packages, the next chapter tells you how to start it all up.

Building with Recent GLIBC and Fixing the errno Problem

If your system uses the GNU GLIBC Version 2.3.1 or newer, qmail won't compile without some small patches. This problem affects most recent versions of Linux. The qmail source code defines errno, the place where system calls put error codes, to be an int variable, but in these libraries it's not, it's a macro.

In the source file errno.h, replace the line that declares errno with this:

#include <errno.h>

In the source files dns.c and cdb_seek.c, find any lines that declare errno or h_errno and delete them so that the system errno is used instead. Then recompile.

The netqmail package available at http://www.qmail.org/netqmail includes the errno patch for qmail and, in its other-patches subdirectory, the errno patch for four other packages.




qmail
qmail
ISBN: 1565926285
EAN: 2147483647
Year: 2006
Pages: 152

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net