2.3 Creating a .cf file
program starts, it reads a configuration file called
, which is usually stored in the
file is a
In the "old days," before
files had to be written and
Fortunately, except for the most unusual of circumstances, this file no longer needs to be modified by hand. Doing so is almost invariably the wrong way to change
's behavior. Instead, it's better to create a file to act as a template for the creation of the
file in a simple macro language called M4. The
utility (it's a program as well as a language
In this book, all examples demonstrating how to implement and modify sendmail configurations are written using M4. Sometimes variables are mentioned that could be modified directly in the sendmail.cf file. Tempting as it might be, I urge the reader not to do this. Several sample M4 configuration template files are available to use as starting points or to learn from in the cf/cf directory of the sendmail distribution, where they are indicated by a .mc file extension. These files are referred to as .mc files. In creating a suitable sendmail configuration file, one typically chooses a template .mc file representative of the operating system in question and copies it to some appropriate name, such as solaris-gateway.mc . This file is edited and features appropriate to the given server are then added, deleted, or modified as necessary. Finally, the .cf file is created by running " make solaris-gateway.cf " in the same directory.
Several sample configuration files are available to copy from, although admittedly more examples would be useful. Generally, one should start with the " generic- ostype .mc " file appropriate to the operating system and modify it to taste. One file that's good to look through for ideas about good formats or what sorts of things to change is called knecht.mc . Eric Allman, the original author of sendmail , uses this configuration file on one of his own machines. Beyond these examples, all of the myriad options available for configuration within sendmail are documented in the cf/README file, with which every sendmail administrator should become intimately familiar.
This section isn't intended as a general tutorial on M4, but one trap into which people often fall is worth mentioning. Unlike many other scripting languages with which the reader might be familiar, M4 does not support the use of comments by beginning a line with the " # " character. Assume one puts entries like the following in an M4 file:
# Don't use the mailertable for now. # FEATURE('mailertable', 'hash /etc/mail/mailertable')
The first line beginning with a comment will be added to the sendmail.cf file (as a comment), the second " # " will be added to the file on a line by itself, and M4 will interpret the FEATURE() directive as adding mailertable support. Don't comment out features using " # " in .mc files.
Comments can be added to
files by prefacing lines with
, which means "discard
dnl Don't use the mailertable for now. dnl FEATURE('mailertable', 'hash /etc/mail/mailertable')