151222Sericdivert(-1) 251222Seric# 351222Seric# Copyright (c) 1983 Eric P. Allman 451222Seric# Copyright (c) 1988 The Regents of the University of California. 551222Seric# All rights reserved. 651222Seric# 751222Seric# %sccs.include.redist.sh% 851222Seric# 951222Sericdivert(0) 1051222Seric 11*51889SericVERSIONID(@(#)proto.m4 2.17 (Berkeley) 12/12/91) 1251222Seric 1351322SericMAILER(local)dnl 1451222Seric 1551222Seric################## 1651222Seric# local info # 1751222Seric################## 1851222Seric 19*51889SericCwlocalhost 2051887Sericifdef(`USE_CW_FILE', 21*51889Seric`# file containing names of hosts for which we receive email 2251222SericFw/etc/sendmail.cw', `dnl') 2351222Seric 2451222Sericifdef(`UUCP_RELAY', 2551222Seric`# UUCP relay host 2651281SericCONCAT(DY, UUCP_RELAY) 2751222Seric')dnl 2851222Sericifdef(`BITNET_RELAY', 2951222Seric`# BITNET relay host 3051222SericCONCAT(DB, BITNET_RELAY) 3151222Seric')dnl 3251222Sericifdef(`CSNET_RELAY', 3351222Seric`# CSNET relay host 3451222SericCONCAT(DC, CSNET_RELAY) 3551222Seric')dnl 3651222Seric# my official hostname ($w or $w.$D) 3751291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 3851222Seric 3951222Seric# who I masquerade as (can be $j) 4051222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 4151222Seric 4251222Seric# who I send unqualified names to (null means deliver locally) 4351222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 4451222Seric 4551279Seric# names that should be delivered locally, even if we have a relay 4651279SericCLroot 4751279Sericundivert(5)dnl 48*51889Sericundivert(6)dnl 4951279Seric 5051222Sericifdef(`UUCP_NAME', 5151260Seric`# uucp hostnames 5251222SericUUCP_NAME 5351222SericUUCP_ALIASES 5451222Seric 5551222Seric# local UUCP connections 5651260Sericinclude(UUCP_HOSTS_FILE)', 5751244Seric`dnl') 5851222Seric 5951222Seric# operators that cannot be in local usernames (i.e., network indicators) 6051222SericCO @ % ! 6151222Seric 6251322Seric# a class with just dot (for identifying canonical names) 6351322SericC.. 6451322Seric 6551887Seric# list of locations of user database file (null means no lookup) 6651887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC') 6751222Seric 6851887Seric# set if we can guarantee no wildcard MX records matching our domain 6951887Sericifdef(`_NO_WILDCARD_MX_', `', `#')Ow 7051222Seric 7151322Sericifdef(`NEWSENDMAIL', 7251322Seric`# level 2 config file format 7351322SericO=2', `dnl') 7451322Seric 7551222Sericinclude(`../m4/version.m4') 7651222Seric 7751260Sericifdef(`INTERNET_RELAY', 7851260Seric`include(../sitedep/nicregistered.m4)', 7951260Seric`dnl') 8051222Sericinclude(`../m4/boilerplate.m4') 8151222Seric# 8251222Seric###################################################################### 8351222Seric###################################################################### 8451222Seric##### 8551222Seric##### REWRITING RULES 8651222Seric##### 8751222Seric###################################################################### 8851222Seric###################################################################### 8951222Seric 9051222Seric 9151222Seric########################################### 9251222Seric### Rulset 3 -- Name Canonicalization ### 9351222Seric########################################### 9451260SericS3 9551222Seric 9651222Seric# handle "from:<>" special case 9751222SericR$*<>$* $@@ turn into magic token 9851222Seric 9951222Seric# basic textual canonicalization -- note RFC733 heuristic here 10051222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 10151222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 10251222SericR$*<$+>$* $2 basic RFC821/822 parsing 10351222Seric 10451222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 10551222SericR@$+,$+ @$1:$2 change all "," to ":" 10651222Seric 10751222Seric# localize and dispose of route-based addresses 10851222SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 10951222Seric 11051222Seric# find focus for list syntax 11151222SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 11251222SericR$+:$*; $@$1:$2; list syntax 11351222Seric 11451222Seric# find focus for @ syntax addresses 11551222SericR$+@$+ $:$1<@$2> focus on domain 11651222SericR$+<$+@$+> $1$2<@$3> move gaze right 11751222SericR$+<@$+> $@$>6$1<@$2> already canonical 11851222Seric 11951222Seric# convert old-style addresses to a domain-based address 12051222SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 12151222SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 12251222SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 12351222Seric 12451222Seric# if we have % signs, take the rightmost one 12551222SericR$*%$* $1@$2 First make them all @s. 12651222SericR$*@$*@$* $1%$2@$3 Undo all but the last. 12751222SericR$*@$* $@$>6$1<@$2> Insert < > and finish 12851222Seric 12951222Seric# else we must be a local name 13051222Seric 13151222Seric 13251222Seric############################################### 13351222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 13451222Seric############################################### 13551222Seric 13651222Seric# At this point, everything should be in a local_part@domain format. 13751222Seric 13851222SericS6 13951222Seric 14051222Seric# handle special cases for local names 14151322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 14251322SericR$* < @ $=w .UUCP> $* $: $1 < @ $j . > $3 .UUCP domain 143*51889Sericundivert(2)dnl 14451222Seric 14551274Sericifdef(`UUCP_RELAY', 14651274Seric`# pass UUCP addresses straight through 14751274SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 .UUCP > $3', 14851274Seric`# if really UUCP, handle it immediately 14951322Sericifdef(`_CLASS_U_', 15051322Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 15151322Sericifdef(`_CLASS_V_', 15251322Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 15351322Sericifdef(`_CLASS_W_', 15451322Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 15551322Sericifdef(`_CLASS_X_', 15651322Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 15751322Sericifdef(`_CLASS_Y_', 15851322Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 15951267Seric 16051267Seric# try UUCP traffic as a local address 16151322SericR$* < @ $+ .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 16251322Sericifdef(`NEWSENDMAIL', 16351322Seric`R$* < @ $+ . .UUCP > $* $@ $1 < @ $2 . > $3', 16451322Seric`R$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4')') 16551267Seric 16651222Seric# pass to name server to make hostname canonical 16751322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 16851222Seric 169*51889Seric# handle possible alternate names 170*51889SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 171*51889SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 172*51889Sericundivert(8)dnl 173*51889Seric 17451322Seric# if this is the local hostname, make sure we treat is as canonical 17551322SericR$* < @ $j > $* $: $1 < @ $j . > $2 17651222Seric 17751322Seric 17851222Seric################################################## 17951222Seric### Ruleset 4 -- Final Output Post-rewriting ### 18051222Seric################################################## 18151222SericS4 18251222Seric 18351222SericR@ $@ handle <> error addr 18451222Seric 18551222Seric# resolve numeric addresses to name if possible 18651322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 18751222Seric 18851322Seric# strip trailing dot off possibly canonical name 18951322SericR$* < @ $+ . > $* $1 < @ $2 > $3 19051322Seric 19151222Seric# externalize local domain info 19251322SericR$* < $+ > $* $1 $2 $3 defocus 19351322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 19451222Seric 19551222Seric# UUCP must always be presented in old form 19651322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 19751222Seric 19851222Seric# delete duplicate local names 19951322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 20051222Seric 20151222Seric 20251222Seric 20351222Seric############################################################# 20451222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 20551222Seric### (used for recursive calls) ### 20651222Seric############################################################# 20751222Seric 20851222SericS7 20951222SericR$* $: $>3 $1 21051222SericR$* $@ $>0 $1 21151222Seric 21251222Seric 21351222Seric###################################### 21451222Seric### Ruleset 0 -- Parse Address ### 21551222Seric###################################### 21651222Seric 21751222SericS0 21851222Seric 21951222Seric# handle numeric address spec 22051322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 22151322SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec 22251222Seric 22351222Seric#R@ $#error$:Invalid address handle <> form 22451222Seric 22551887Seric# now delete the local info -- note $=O to find characters that cause forwarding 22651322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 22751322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 22851222Seric 22951222Seric# short circuit local delivery so forwarded email works 230*51889Sericifdef(`NEWSENDMAIL', 231*51889Seric`R$+ < @ $j . > $#local $: @ $1 local address', 232*51889Seric`R$+ < @ $j . > $#local $: $1 local address') 23351222Sericundivert(3)dnl 23451260Sericundivert(4)dnl 23551260Seric 23651260Seric# resolve remotely connected UUCP links 23751285Sericifdef(`_CLASS_V_', 23851285Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl') 23951285Sericifdef(`_CLASS_W_', 24051285Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl') 24151285Sericifdef(`_CLASS_X_', 24251285Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl') 24351260Seric 24451222Seric# resolve fake top level domains by forwarding to other hosts 24551222Sericifdef(`BITNET_RELAY', 24651222Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 24751222Seric `dnl') 24851222Sericifdef(`CSNET_RELAY', 24951222Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 25051222Seric `dnl') 25151222Seric 25251260Sericifdef(`UUCP_RELAY', 25351260Seric`# forward non-local UUCP traffic to our UUCP relay 25451281SericR$*<@$*.UUCP>$* $#smtp$@$Y$:$1<@$2.UUCP> uucp mail', 25551260Seric`ifdef(`_UUCP_LINKED_', 25651260Seric`# forward other UUCP traffic straight to UUCP 25751260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 25851322SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 25951260Seric `dnl')') 26051222Seric 26151260Seric# deal with other remote names 26251222SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 26351222Seric 26451322Sericifdef(`NEWSENDMAIL', 26551322Seric`# handle locally delivered names 266*51889SericR$=L $# local $: @ $1 special local names 26751322SericR$+ $# local $: $1 regular local names 26851887Seric', 26951887Seric`# forward remaining names to local relay, if any 27051887SericR$+ $: $1 < @ $R > 27151887SericR$+ < @ > $# local $: $1 27251887SericR$+ < @ $+ > $# smtp $@ $2 $: $1') 27351222Seric 27451887Sericifdef(`NEWSENDMAIL', 27551322Seric`# 27651322Seric# special rewriting after aliases have been expanded 27751322Seric# 27851222Seric 27951322SericS5 28051322Seric 28151887SericR$+ $: $1 < @ $R > 28251887SericR$+ < @ $+ > $# smtp $@ $2 $: $1 send to relay') 28351222Seric# 28451222Seric###################################################################### 28551222Seric###################################################################### 28651222Seric##### 28751222Seric##### MAILER DEFINITIONS 28851222Seric##### 28951222Seric###################################################################### 29051222Seric###################################################################### 29151222Sericundivert(7)dnl 292