1.4 Adding the regex Map Type to sendmail - Administration
If you want to build or customize a sendmail configuration, you need to know your way around the sendmail distribution. This article will help you find your way around the cf directory, which contains the configuration files. It was excerpted from chapter one of The Sendmail Cookbook, written by Craig Hunt (O'Reilly Media, 2004; ISBN: 0596004710).
Support for the regex map type must be compiled into sendmail if the error message “class regex not available” is displayed when sendmail is run.
To add support for the regular expression map type, add MAP_REGEX to the confMAPDEF compiler variable in the site.config.m4 file and then recompile sendmail. Here is an example:
# cd /usr/local/src/sendmail-8.12.9/devtools/Site # cat >> site.config.m4 APPENDDEF(`confMAPDEF', `-DMAP_REGEX') Ctrl-D # cd /usr/local/src/sendmail-8.12.9 # ./Build -c
After recompiling sendmail, reinstall it:
# ./Build install
Attempting to run a configuration that specifies a regex map type on a sendmail system without regex support compiled in produces an error, as this test shows:
#sendmail -bt sendmail.cf: line 115: readcf: map dottedquad: class regex not available ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >/quit
The first line after the sendmail -bt command is an error message. It tells us that line 115 in the sendmail.cf file contains a K command that defines a map using the regex map type, which results in an error because regex is not supported on this system.
The fix for this requires defining a local compiler variable in the site.config.m4 file in the devtools/Site directory. The APPENDDEF command used in the Solution section appends the -DMAP_REGEX command-line argument to any values that already exist in the confMAPDEF variable. The Build command that is used to recompile sendmail uses the -c flag to ensure that Build incorporates the new data from the site.config.m4 file.
After compiling sendmail, run it with the -bt and the -d0.1 command-line arguments to check the compiler options:
#sendmail -bt -d0.1 Version 8.12.9 Compiled with: DNSMAP LOG MAP_REGEX MATCHGECOS MIME7TO8 MIME8TO7 NEWDB NAMED_BIND NETINET NETUNIX PIPELINING SCANF USERDB XDEBUG ============ SYSTEM IDENTITY (after readcf) ============ (short domain name) $w = chef (canonical domain name) $j = chef.wrotethebook.com (subdomain name) $m = wrotethebook.com (node name) $k = chef ======================================================== ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >/quit
The “Compiled with:” line output by the -d0.1 argument displays the compiler options. This line should contain MAP_REGEX. If it does, configurations using the regex map type should now run successfully.
Recipes 1.2, 1.3, 1.5, 1.6, and 1.7 provide other examples of compiling sendmail. Recipe 6.10 uses the regex map type. The sendmail book covers compiling sendmail in section 2.2.