# Copyright (c) 1983 Eric P. Allman
# Copyright (c) 1988 The Regents of the University of California.
# %sccs.include.redist.sh%
VERSIONID(`@(#)proto.m4 6.20 (Berkeley) %G%')
ifdef(`_OLD_SENDMAIL_', `dnl',
`# level 4 config file format
`# file containing names of hosts for which we receive email
CONCAT(`Fw', confCW_FILE)', `dnl')
`# "Smart" UUCP relay host
# who I send unqualified names to (null means deliver locally)
CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
# who gets all local email traffic ($R has precedence for unqualified names)
CONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
# my official hostname ($w or $w.$D)
CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
# who I masquerade as (can be $j)
CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
# class L: names that should be delivered locally, even if we have a relay
# class E: names that should be exposed as from this host, even if we masquerade
# operators that cannot be in local usernames (i.e., network indicators)
CO @ % ifdef(`_NO_UUCP_', `', `!')
# a class with just dot (for identifying canonical names)
# SMTP initial login message
CONCAT(De, confSMTP_LOGIN_MSG)
# UNIX initial From header format
CONCAT(Dl, confFROM_LINE)
# my name for error messages
CONCAT(Dn, confMAILER_NAME)
# delimiter (operator) characters
CONCAT(Do, confOPERATORS)
CONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER,
ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.')))
include(`../m4/version.m4')
# preserve 8 bits on message body on input?
CONCAT(O8, confEIGHT_BIT_INPUT)
# wait (in minutes) for alias file rebuild
CONCAT(Oa, confALIAS_WAIT)
CONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases))
# minimum number of free blocks on filesystem
CONCAT(Ob, confMIN_FREE_BLOCKS)
# substitution for space (blank) characters
CONCAT(OB, confBLANK_SUB)
# connect to "expensive" mailers on initial submission?
CONCAT(Oc, confCON_EXPENSIVE)
# checkpoint queue runs after every N successful deliveries
CONCAT(OC, confCHECKPOINT_INTERVAL)
CONCAT(Od, confDELIVERY_MODE)
# automatically rebuild the alias database?
CONCAT(OD, confAUTO_REBUILD)
# error message header/file */
ifdef(`confERROR_MESSAGE',
concat(OE, confERROR_MESSAGE),
concat(Oe, confERROR_MODE),
# save Unix-style "From_" lines at top of header?
CONCAT(Of, confSAVE_FROM_LINES)
CONCAT(OF, confTEMP_FILE_MODE)
# match recipients against GECOS field?
CONCAT(OG, confMATCH_GECOS)
CONCAT(Og, confDEF_GROUP_ID)
CONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf))
# ignore dots as terminators in incoming messages?
CONCAT(Oi, confIGNORE_DOTS)
# Insist that the BIND name server be running to resolve names
CONCAT(OI, confBIND_OPTS),
# Forward file search path
ifdef(`confFORWARD_PATH',
CONCAT(OJ, confFORWARD_PATH),
#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
# open connection cache size
CONCAT(Ok, confMCI_CACHE_SIZE)
# open connection cache timeout
CONCAT(OK, confMCI_CACHE_TIMEOUT)
CONCAT(OL, confLOG_LEVEL)
# send to me too, even in an alias expansion?
# verify RHS in newaliases?
CONCAT(On, confCHECK_ALIASES)
# default messages to old style headers if no special punctuation?
CONCAT(Oo, confOLD_STYLE_HEADERS)
CONCAT(Op, confPRIVACY_FLAGS)
# who (if anyone) should get extra copies of error messages
ifdef(`confCOPY_ERRORS_TO',
CONCAT(OP, confCOPY_ERRORS_TO),
# slope of queue-only function
ifdef(`confQUEUE_FACTOR',
CONCAT(Oq, confQUEUE_FACTOR),
CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
# read timeout -- now OK per RFC 1123 section 5.3.2
ifdef(`confREAD_TIMEOUT',
CONCAT(Or, confREAD_TIMEOUT),
# queue up everything before forking?
CONCAT(Os, confSAFE_QUEUE)
CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
# default message timeout interval
CONCAT(OT, confMESSAGE_TIMEOUT)
# if undefined, use system default
# if defined but null, use TZ envariable passed in
# if defined and non-null, use that info
ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
confTIME_ZONE, `USE_TZ', `',
`CONCAT(Ot, confTIME_ZONE)')
CONCAT(Ou, confDEF_USER_ID)
# list of locations of user database file (null means no lookup)
CONCAT(OU, ifdef(`USERDB_SPEC', `USERDB_SPEC'))
# load average at which we just queue messages
# load average at which we refuse connections
CONCAT(OX, confREFUSE_LA)
ifdef(`confWORK_RECIPIENT_FACTOR',
CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
# deliver each queued job in a separate process?
CONCAT(OY, confSEPARATE_PROC)
ifdef(`confWORK_CLASS_FACTOR',
CONCAT(Oz, confWORK_CLASS_FACTOR),
ifdef(`confWORK_TIME_FACTOR',
CONCAT(OZ, confWORK_TIME_FACTOR),
###########################
###########################
#########################
#########################
H?P?Return-Path: <$?<$<$|$g$.>
HReceived: $?sfrom $s $.by $j ($v/$Z) id $i; $b
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>
######################################################################
######################################################################
######################################################################
######################################################################
###########################################
### Rulset 3 -- Name Canonicalization ###
###########################################
# handle null input and list syntax (translate to <@> special case)
# basic textual canonicalization -- note RFC733 heuristic here
R$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <>
R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting
R$*<>$* $@ <@> MAIL FROM:<> case
R$*<$+>$* $2 basic RFC821/822 parsing
# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
R@ $+ , $+ @ $1 : $2 change all "," to ":"
# localize and dispose of route-based addresses
R@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr>
# find focus for list syntax
R $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax
R $+ : $* ; $@ $1 : $2; list syntax
# find focus for @ syntax addresses
R$+ @ $+ $: $1 < @ $2 > focus on domain
R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right
R$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical
ifdef(`_NO_UUCP_', `dnl',
`# convert old-style addresses to a domain-based address
R$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names
R$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps
R$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains')
# if we have % signs, take the rightmost one
R$* % $* $1 @ $2 First make them all @s.
R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last.
R$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish
# else we must be a local name
###############################################
### Ruleset 6 -- bottom half of ruleset 3 ###
###############################################
# At this point, everything should be in a "local_part<@domain>extra" format.
# handle special cases for local names
R$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all
R$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain
`# pass UUCP addresses straight through
R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3',
`# if really UUCP, handle it immediately
`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
# try UUCP traffic as a local address
R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3
`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4',
`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')')
# pass to name server to make hostname canonical
R$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4
# handle possible alternate names
R$* < @ $=w . $m . > $* $: $1 < @ $j . > $3
R$* < @ $=w . $m > $* $: $1 < @ $j . > $3
# if this is the local hostname, make sure we treat is as canonical
R$* < @ $j > $* $: $1 < @ $j . > $2
##################################################
### Ruleset 4 -- Final Output Post-rewriting ###
##################################################
R$*<@> $@ $1 handle <> and list:;
# resolve numeric addresses to name if possible
R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr
# strip trailing dot off possibly canonical name
R$* < @ $+ . > $* $1 < @ $2 > $3
# externalize local domain info
R$* < $+ > $* $1 $2 $3 defocus
R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical
R@ $* $@ @ $1 ... and exit
ifdef(`_NO_UUCP_', `dnl',
`# UUCP must always be presented in old form
R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u')
# delete duplicate local names
R$+ % $=w @ $=w $1 @ $j u%host@host => u@host
#############################################################
### Ruleset 7 -- recanonicalize and call ruleset zero ###
### (used for recursive calls) ###
#############################################################
######################################
### Ruleset 0 -- Parse Address ###
######################################
R<@> $#local $: <> special case error msgs
`# handle numeric address spec
R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr
R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec',
# now delete the local info -- note $=O to find characters that cause forwarding
R$* < @ > $* $@ $>7 $1 user@ => user
R< @ $j . > : $* $@ $>7 $1 @here:... -> ...
R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ...
# short circuit local delivery so forwarded email works
ifdef(`_LOCAL_NOT_STICKY_',
`R$=L < @ $j . > $#local $: @ $1 special local names
R$+ < @ $j . > $#local $: $1 dispose directly',
`R$+ < @ $j . > $: $1 < @ $j @ $H > first try hub
`R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 < $2 > yep ....
R$+ < $+ @ $+ > $#smtp $@ $3 $: $1 < $2 > yep ....
R$+ < $+ @ > $#local $: $1 nope, local address',
`R$+ < $+ @ $+ > $#local $: $1 yep ....
R$+ < $+ @ > $#local $: @ $1 nope, local address')')
# resolve remotely connected UUCP links (if any)
`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
# resolve fake top level domains by forwarding to other hosts
`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET',
`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET',
`R$+ < @ $+ .FAX > $#fax $@ $2 $: $1 user@host.FAX',
`R$*<@$+.FAX>$* $#smtp $@ $F $: $1 <@$2.FAX> $3 user@host.FAX',
`# forward non-local UUCP traffic to our UUCP relay
R$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail',
`# forward other UUCP traffic straight to UUCP
R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:...
R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP',
`# figure out what should stay in our local mail system
`# deal with other remote names
R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain')')
# pass names that still have a host to a smarthost
R$* < @ $* > $* $: < $S > $1 < @ $2 > $3 glue on smarthost name
R<$-:$+> $* < @$* > $* $# $1 $@ $2 $: $3 < @ $4 > $5 if non-null, use it
R<$+> $* < @$* > $* $#suucp $@ $1 $: $2 < @ $3 > $4 if non-null, use it
R<> $* < @ $* > $* $1 < @ $2 > $3 else strip off gunk',
`ifdef(`_LOCAL_RULES_', `
# reject messages that have host names we do not understand
R$* < @ $* > $* $#error $@ NOHOST $: Unrecognized host name $2',
ifdef(`_MAILER_USENET_', `
# addresses sent to net.group.USENET will get forwarded to a newsgroup
R$+ . USENET $# usenet $: $1')
`# forward remaining names to local relay, if any
R$=L $#local $: $1 special local names
R$+ $: $1 < @ $R > append relay
R$+ < @ > $: $1 < @ $H > no relay, try hub
R$+ < @ > $#local $: $1 no relay or hub: local
R$+ < @ $j > $#local $: $1 we are relay/hub: local
R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 deliver to relay/hub
R$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay/hub',
`# handle locally delivered names
R$=L $#local $: @ $1 special local names
R$+ $#local $: $1 regular local names
###########################################################################
### Ruleset 5 -- special rewriting after aliases have been expanded ###
### (new sendmail only) ###
###########################################################################
R$+ < @ > $: $1 < @ $H > no relay, try hub
R$+ < @ $j > $@ $1 we are relay/hub: local
R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 send to relay or hub
R$+ < @ $+ > $#smtp $@ $2 $: $1 send to relay or hub')')
######################################################################
######################################################################
`##### MAILER DEFINITIONS'
######################################################################
######################################################################