# Copyright (c) 1983 Eric P. Allman
# Copyright (c) 1988 The Regents of the University of California.
# %sccs.include.redist.sh%
VERSIONID(@(#)proto.m4 2.17 (Berkeley) %G%)
`# file containing names of hosts for which we receive email
Fw/etc/sendmail.cw', `dnl')
# 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))
# who I send unqualified names to (null means deliver locally)
CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
# names that should be delivered locally, even if we have a relay
include(UUCP_HOSTS_FILE)',
# operators that cannot be in local usernames (i.e., network indicators)
# a class with just dot (for identifying canonical names)
# list of locations of user database file (null means no lookup)
OU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
# set if we can guarantee no wildcard MX records matching our domain
ifdef(`_NO_WILDCARD_MX_', `', `#')Ow
`# level 2 config file format
include(`../m4/version.m4')
`include(../sitedep/nicregistered.m4)',
include(`../m4/boilerplate.m4')
######################################################################
######################################################################
######################################################################
######################################################################
###########################################
### Rulset 3 -- Name Canonicalization ###
###########################################
# handle "from:<>" special case
R$*<>$* $@@ turn into magic token
# basic textual canonicalization -- note RFC733 heuristic here
R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting
R$*<$*<$+>$*>$* $3 2-level <> nesting
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
# 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 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',
`R$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4')')
# 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@ $@ handle <> error addr
# 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
# 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 ###
######################################
# handle numeric address spec
R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr
R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec
#R@ $#error$:Invalid address handle <> form
# now delete the local info -- note $=O to find characters that cause forwarding
R< @ $j . > : $* $@ $>7 $1 @here:... -> ...
R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ...
# short circuit local delivery so forwarded email works
`R$+ < @ $j . > $#local $: @ $1 local address',
`R$+ < @ $j . > $#local $: $1 local address')
# resolve remotely connected UUCP links
`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl')
`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl')
`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl')
# 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',
`# forward non-local UUCP traffic to our UUCP relay
R$*<@$*.UUCP>$* $#smtp$@$Y$:$1<@$2.UUCP> 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',
# deal with other remote names
R$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain
`# handle locally delivered names
R$=L $# local $: @ $1 special local names
R$+ $# local $: $1 regular local names
`# forward remaining names to local relay, if any
R$+ < @ $+ > $# smtp $@ $2 $: $1')
# special rewriting after aliases have been expanded
R$+ < @ $+ > $# smtp $@ $2 $: $1 send to relay')
######################################################################
######################################################################
######################################################################
######################################################################