Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [338]

By Root 2930 0
even seasoned sysadmins.

Every version of sendmail uses a config file, but modern versions make the configuration process easier through the use of m4 macros, which disguise much of the underlying complexity. It might be said that the raw config file is at the level of assembly language, whereas m4 configuration is more at the level of Perl.19

When the m4 macros were first introduced, it was hoped that they would handle 80%–90% of cases. In fact, the coverage rate turned out to be much higher, probably closer to 98%. In this book, we cover only the m4-based “config lite.” You need delve into the low-level config file only if you are debugging a thorny problem or growing your mail site in bizarre ways.

Three key pieces of documentation are the O’Reilly book sendmail by Bryan Costales and Eric Allman, the paper Sendmail Installation and Operations Guide by Eric Allman (included in the doc/op directory of the distribution), and the README file (in the cf directory). We often refer to sendmail as a source for more information and refer to it as “the sendmail book.” Likewise, we refer to the installation paper as “the installation guide” and the README file as cf/README.

Using the m4 preprocessor


We first describe a few m4 features, then show how to build a configuration file from an m4 master file, and finally describe some of the important prepackaged m4 macros that come with the sendmail distribution.

We conclude this section with example configurations for three distinct sites:

• A computer science student’s home Linux box

• A medium-sized company that knows how to configure sendmail properly

• A site that does lots of web hosting

m4 was originally intended as a front end for programming languages that would let the user write more readable (or perhaps more cryptic) programs. m4 is powerful enough to be useful in many input transformation situations, and it works nicely for sendmail configuration files.

m4 macros have the form

name(arg1, arg2, ..., argn)

There should be no space between the name and the opening parenthesis. Left and right single quotes are used to quote strings as arguments. m4’s quoting conventions are different from those of other languages you may have used, since the left and right quotes are different characters.20

Quotes nest, too. With today’s compiler building tools, one wonders how m4 survived with such a rigid and exotic syntax.

m4 has some built-in macros, and users can also define their own. Table 19.8 lists the most common built-in macros used in sendmail configuration.

Table 19.8 m4 macros commonly used with sendmail

Some sites add a dnl macro to the end of every line to keep the translated .cf file tidy; without dnl, m4 adds extra blank lines to the configuration file. These blank lines don’t affect sendmail’s behavior, but they make the config file hard to read. We have omitted the dnls from our examples.

sendmail requires a version of m4 that is newer than the original UNIX version 7 code from Bell Labs. Most m4’s shipped today are OK; if in doubt, get GNU’s version.

m4 does not really honor comments in files. A comment such as:

# And then define the ...

would not do what you expect because define is an m4 keyword and would be expanded. Instead, use the m4 dnl keyword (for “delete to newline”). For example,

dnl # And then define the ...

would work. You must include a space between the dnl and the comment itself.

The sendmail configuration pieces


The sendmail distribution includes a cf subdirectory that contains all the pieces necessary for m4 configuration: a README file and several subdirectories, listed in Table 19.9.

Table 19.9 Configuration subdirectories

The cf/cf directory contains examples of .mc files. In fact, it contains so many examples that yours will get lost in the clutter. We recommend that you move the cf directory aside to cf.examples and create a new cf directory for your own local .mc files. If you do this, copy the Makefile and Build script over to your new directory so the instructions in the README

Return Main Page Previous Page Next Page

®Online Book Reader