In Chapter 10 we develop a sendmail configuration. The configuration has these characteristics:
It runs on a Linux system.
The hostname of the sending system is rewritten to the domain name on all out-bound mail. The hostname is rewritten in the message headers and the envelope headers.
The sender's username on all outgoing mail is rewritten to the user's first name and last name.
We use two approaches to produce this configuration. First, we use the sample m4 source files that come with sendmail to create a custom macro configuration file. Next, we created the same configuration by directly modifying the sample sendmail.cf file that comes with Slackware 96 Linux. In this section we recap both sample configurations.
To many system administrators, the simpliest way to create the configuration is to use the m4 macro source files. The macro source files are very short, and many people feel they are easier to read than the sendmail.cf file. If you download and compile sendmail, it is a good idea to use the macro files because the features in those files will match the downloaded sendmail release.
We name the macro file we create in Chapter 10 linux.mc . The file contains these macros:
VERSIONID('@(#)tcpproto.mc 8.5 (Berkeley) 3/23/96') OSTYPE(linux) DOMAIN(nuts.com) FEATURE(nouucp) MAILER(local) MAILER(smtp)
It is identical to the
tcpproto.mc
file delivered with sendmail, with two modifications. First, we change the OSTYPE macro to define Linux as the operating system. Next we add a
DOMAIN(nuts.com)
line to invoke a "domain-specific" macro file we create and name
nuts.com.m4
. The
nuts.com.m4
file contains the following lines:
MASQUERADE_AS(nuts.com) FEATURE(masquerade_envelope) FEATURE(genericstable)
These three lines peform all of the functions we required of our configuration. The
MASQUERADE_AS
statement rewrites the hostname to the domain name. The
FEATURE(masquerade_envelope)
statement ensures that the hostname is rewritten in the envelope headers as well as the message headers. The
FEATURE(generictable)
statement causes the username to be processed through the
genericstable
, which is the database we use to convert it to the user's first and last name.
All of the functions we require of our configuration are accomplished in five lines. Modifying the sendmail.cf file directly requires much more effort. However, the the m4 source files can only be used if they match the version of sendmail. For this reason, m4 is most often used by administrators who download and install sendmail themselves. Most administrators who use the sendmail that comes with their system also use the sendmail.cf file that comes with the system. In Chapter 10 , we use the linux.smtp.cf file that comes with the Slackware 96 version of Linux 2.0. The detailed modifications of the file are explained in Chapter 10 . Excerpts from the modified file are listed in this appendix and are heavily commented to make the modifications more understandable. A full listing of the sendmail.cf file would consume 15 pages. Compare that to the listing of the m4 files shown above.
The linux.smtp.cf file is not identical to the configuration file produced by m4 , even when you follow the example in the "Building a sendmail.cf with m4 Macros" section of Chapter 10 . The configurations are similar but not identical. Use this text as a general guide to the structure and function of configuration file. Don't expect the details to match your file exactly.
This excerpt shows the entire local information section because it is discussed extensively in Chapter 10 :
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # The V command defines the configuration syntax version level. # Level 6 was supported by sendmail-8.7.5, which was the release # of sendmail that came with Slackware 96 Linux 2.0. The vendor # name Berkeley means that the standard syntax of the Berkeley # distribution is supported. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # level 6 config file format V6/Berkeley #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Like most sendmail configuration files, the first sections of the file #contain the data that is most likely to require custom configuration. #In this file, the section is titled "Local info". Note that we moved #things around in this section to bring related items together. They #don't really occur in this sequence in the linux.smtp.cf file. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ################## # local info # ################## #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #If your host is known by more than one hostname, the multiple host #names are defined in class "w", which contains all of the names for #which your host will accept mail. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cwlocalhost #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The j macro is correctly define by the system. No need to set it here. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # my official domain name # ... define this only if sendmail cannot automatically determine # your domain #Dj$w.Foo.COM #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Class P is used to store pseudo domains. It is only used in this #file to store a dot (.) used to identify canonical names. The dot #(.) class, which is supposed to be used to identify canonical names, #is not referenced anywhere else in the file. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CP. # a class with just dot (for identifying canonical names) C.. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Several different mail relay servers can be defined. We don't use any #in this sample configuration. The L macro and the L class are only #significant if relay servers are defined for handling "local" mail. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # "Smart" relay host (may be null) DS # who I send unqualified names to (null means deliver locally) DR # who gets all local email traffic ($R has precedence for unqualified names) DH # place to which unknown users should be forwarded #Kuser user -m -a<> #DLname_of_luser_relay # class L: names that should be delivered locally, even if we have a relay #CL root #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Sample K commands are included in the linux.smtp.cf file. Of these, #only the dequote database is active. The others are commented out by #default. The purpose of each of these databases is explained earlier #in this appendix. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Mailer table (overriding domains) #Kmailertable dbm /etc/mailertable # Domain table (adding domains) #Kdomaintable dbm /etc/domaintable # dequoting map Kdequote dequote #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Several lines relate to address "masquerading". Macro M defines the #hostname that should be used in place of the system's real hostname #on outgoing mail. The M class defines other hostnames that should be #converted to the macro M hostname. Class E defines usernames for which #the hostname should not be converted to $M. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # class E: names that should be exposed as from this host, even if # we masquerade CE root # class M: domains that should be converted to $M #CM # who I masquerade as (null for no masquerading) (see also $=M) DMnuts.com #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #We added this K command to define a database that we created that converts #username to the user's real first and last names. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # define a database to map login names to firstname.lastname Krealnames dbm /tmp/realnames # operators that cannot be in local usernames (i.e., network indicators) CO @ % # my name for error messages DnMAILER-DAEMON #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #Macro Z contains the configuration file's version number. Modify it #every time the file is updated. Keep a record of your modifications. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # R1.0 - modified for peanut by Craig # - cleaned up the comments in the local info section # R1.1 - modified macro M to use nuts.com instead of the # hostname in outgoing mail # R2.0 - added rule a to S11 & S31 to rewrite to first.last format DZ8.7.3R2.0
In Chapter 10 we modified ruleset 94 to enable masquerading for envelope addresses.
################################################################### ### Ruleset 94 -- convert envelope names to masqueraded form ### ################################################################### #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #To enable "envelop" address masquerading we "uncommented" the first line #in this ruleset so that it now calls ruleset 93. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ S94 R$+ $@ $>93 $1 R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2
The mailers do not usually require modification. However, in Chapter 10 , we made some changes to the S rulesets of the "smtp" mailer. We made changes to both ruleset 11 and ruleset 31.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #In Chapter 10 we added a single rule to the end of this ruleset to lookup #the username in the "realnames" database we created and return the #user's real first and last names. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # envelope sender rewriting # S11 R$+ $: $>51 $1 sender/recipient common R$* :; <@> $@ list:; special case R$* $: $>61 $1 qualify unqual'ed names R$+ $: $>94 $1 do masquerading # when masquerading convert login name to firstname.lastname R$- < @ $M . > $* $: $(realnames $1 $) < @ $M . > $2 user=>first.last # # envelope recipient rewriting -- # also header recipient if not masquerading recipients # S21 R$+ $: $>51 $1 sender/recipient common R$+ $: $>61 $1 qualify unqual'ed names #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #In Chapter 10 we added a single rule to the end of this ruleset to look up #the username name in the "realnames" database we created and return the #user's real first and last names. This is the same modification made #above. Often more than one ruleset is modified to add a single new #feature. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # header sender and masquerading header recipient rewriting # S31 R$+ $: $>51 $1 sender/recipient common R:; <@> $@ list:; special case # do special header rewriting R$* <@> $* $@ $1 <@> $2 pass null host through R< @ $* > $* $@ < @ $1 > $2 pass route-addr through R$* $: $>61 $1 qualify unqual'ed names R$+ $: $>93 $1 do masquerading # when masquerading convert login name to firstname.lastname R$- < @ $M . > $* $: $(realnames $1 $) < @ $M . > $2 user=>first.last