Now that the m4 source files have been created for the operating system and the domain, create a new m4 configuration file to use them. All of the m4 macros related to rewriting the outbound addresses are in the foobirds.m4 file. The macros that are specific to the Linux distribution are in the linux.m4 file. We need to include those files in the configuration.
Begin by changing to the ../cf directory and copying the tcpproto.mc file to linux.mc. Then change the file permission for linux.mc to 644 to make sure that the file is writable by the owner.
Now, modify the file to reflect the new configuration. To do that, change "unknown" in the OSTYPE macro to "linux", and add a DOMAIN(foobirds) line to the linux.mc macro control file. For the sake of clarity, we also change the information on the VERSIONID line. The tail command in Listing 5.12 shows the macros in the edited file.
Listing 5.12: A Customized Macro Control File
# tail -7 linux.mc divert(0)dnl
The next step is to process the linux.mc file through m4:
The sample shows the m4 command format used to build a sendmail.cf file. The pathname ../m4/ cf.m4 is the path to the m4 source tree required to build a sendmail.cf file. The new macro control file is, of course, linux.mc. m4 reads the source files ../m4/cf.m4 and linux.mc, and it outputs the file linux.cf. The file output by the m4 command is in the correct format for a sendmail.cf file.
We used three files—ostype/linux.m4, domain/foobirds.m4, and cf/linux.mc—which together total less than 30 lines. These files create a sendmail.cf file that contains more than 1000 lines. The m4 macros are clearly the best way to build a custom sendmail configuration.
Was this article helpful?