2.3 Creating a .cf file

2.3 Creating a .cf file

When the sendmail program starts, it reads a configuration file called send-mail.cf, which is usually stored in the /etc/mail directory. The sendmail.cf file is a strange beast filled with arcane rules and bizarre variables. Following the flow of the sendmail rulesets can prove difficult even for someone who really understands them. For someone without deep sendmail experience, this file can seem daunting, to say the least.

In the "old days," before sendmail version 8, sendmail.cf files had to be written and maintained by hand. Typically, the sysadmin found one that worked for a given configuration or at another site and modified it to suit another purpose. Tweaking a sendmail.cf file was generally considered to require deep magic and was a task not to be undertaken lightly.

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 sendmail's behavior. Instead, it's better to create a file to act as a template for the creation of the sendmail.cf file in a simple macro language called M4. The m4 utility (it's a program as well as a language name) exists on almost all UNIX systems. On some very old operating systems, such as SunOS 4.x or earlier, the default m4 utility may not be capable of doing everything sendmail requires. In such a case, one can obtain and install the version of M4 provided by the Free Software Foundation and available via anonymous FTP at ftp.gnu.org (or from one of its many mirrors) in the gnu/m4 directory. The fact that the GNU m4 source distribution hasn't been modified since 1994 indicates just how few contemporary systems will lack a sufficiently modern version of this utility.

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 .mc files by prefacing lines with dnl, which means "discard characters until the next newline." Thus the following accomplishes what the preceding example failed to do:

 dnl Don't use the mailertable for now.  dnl FEATURE('mailertable', 'hash /etc/mail/mailertable') 


sendmail Performance Tuning
sendmail Performance Tuning
ISBN: 0321115708
EAN: 2147483647
Year: 2005
Pages: 67

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