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*51322SericVERSIONID(@(#)proto.m4 2.13 (Berkeley) 10/05/91) 1251222Seric 13*51322SericMAILER(local)dnl 1451222Seric 1551222Seric################## 1651222Seric# local info # 1751222Seric################## 1851222Seric 1951222Sericifdef(`_USE_CW_FILE_', 2051222Seric`# file containing internet aliases in our primary domain 2151222SericFw/etc/sendmail.cw', `dnl') 2251222Seric 2351222Sericifdef(`UUCP_RELAY', 2451222Seric`# UUCP relay host 2551281SericCONCAT(DY, UUCP_RELAY) 2651222Seric')dnl 2751222Sericifdef(`BITNET_RELAY', 2851222Seric`# BITNET relay host 2951222SericCONCAT(DB, BITNET_RELAY) 3051222Seric')dnl 3151222Sericifdef(`CSNET_RELAY', 3251222Seric`# CSNET relay host 3351222SericCONCAT(DC, CSNET_RELAY) 3451222Seric')dnl 3551222Seric# my official hostname ($w or $w.$D) 3651291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 3751222Seric 3851222Seric# who I masquerade as (can be $j) 3951222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 4051222Seric 4151222Seric# who I send unqualified names to (null means deliver locally) 4251222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 4351222Seric 4451279Seric# names that should be delivered locally, even if we have a relay 4551279SericCLroot 4651279Sericundivert(5)dnl 4751279Seric 4851222Sericifdef(`UUCP_NAME', 4951260Seric`# uucp hostnames 5051222SericUUCP_NAME 5151222SericUUCP_ALIASES 5251222Seric 5351222Seric# local UUCP connections 5451260Sericinclude(UUCP_HOSTS_FILE)', 5551244Seric`dnl') 5651222Seric 5751222Seric# operators that cannot be in local usernames (i.e., network indicators) 5851222SericCO @ % ! 5951222Seric 60*51322Seric# a class with just dot (for identifying canonical names) 61*51322SericC.. 62*51322Seric 6351244Sericifdef(`USERDB_FILE', 6451244Seric`# location of user database file (null means no lookup) 6551260SericCONCAT(`OU', USERDB_FILE)', 6651260Seric`dnl') 6751222Seric 6851222Sericifdef(`_NO_WILDCARD_MX_', 6951222Seric`# we can guarantee no wildcard MX records matching our domain 7051260SericOw', 7151260Seric`dnl') 7251222Seric 73*51322Sericifdef(`NEWSENDMAIL', 74*51322Seric`# level 2 config file format 75*51322SericO=2', `dnl') 76*51322Seric 7751222Sericinclude(`../m4/version.m4') 7851222Seric 7951260Sericifdef(`INTERNET_RELAY', 8051260Seric`include(../sitedep/nicregistered.m4)', 8151260Seric`dnl') 8251222Sericinclude(`../m4/boilerplate.m4') 8351222Seric# 8451222Seric###################################################################### 8551222Seric###################################################################### 8651222Seric##### 8751222Seric##### REWRITING RULES 8851222Seric##### 8951222Seric###################################################################### 9051222Seric###################################################################### 9151222Seric 9251222Seric 9351222Seric########################################### 9451222Seric### Rulset 3 -- Name Canonicalization ### 9551222Seric########################################### 9651260SericS3 9751222Seric 9851222Seric# handle "from:<>" special case 9951222SericR$*<>$* $@@ turn into magic token 10051222Seric 10151222Seric# basic textual canonicalization -- note RFC733 heuristic here 10251222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 10351222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 10451222SericR$*<$+>$* $2 basic RFC821/822 parsing 10551222Seric 10651222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 10751222SericR@$+,$+ @$1:$2 change all "," to ":" 10851222Seric 10951222Seric# localize and dispose of route-based addresses 11051222SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 11151222Seric 11251222Seric# find focus for list syntax 11351222SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 11451222SericR$+:$*; $@$1:$2; list syntax 11551222Seric 11651222Seric# find focus for @ syntax addresses 11751222SericR$+@$+ $:$1<@$2> focus on domain 11851222SericR$+<$+@$+> $1$2<@$3> move gaze right 11951222SericR$+<@$+> $@$>6$1<@$2> already canonical 12051222Seric 12151222Seric# convert old-style addresses to a domain-based address 12251222SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 12351222SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 12451222SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 12551222Seric 12651222Seric# if we have % signs, take the rightmost one 12751222SericR$*%$* $1@$2 First make them all @s. 12851222SericR$*@$*@$* $1%$2@$3 Undo all but the last. 12951222SericR$*@$* $@$>6$1<@$2> Insert < > and finish 13051222Seric 13151222Seric# else we must be a local name 13251222Seric 13351222Seric 13451222Seric############################################### 13551222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 13651222Seric############################################### 13751222Seric 13851222Seric# At this point, everything should be in a local_part@domain format. 13951222Seric 14051222SericS6 14151222Sericundivert(2)dnl 14251222Seric 14351222Seric# handle special cases for local names 144*51322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 145*51322SericR$* < @ $=w .UUCP> $* $: $1 < @ $j . > $3 .UUCP domain 14651222Seric 14751274Sericifdef(`UUCP_RELAY', 14851274Seric`# pass UUCP addresses straight through 14951274SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 .UUCP > $3', 15051274Seric`# if really UUCP, handle it immediately 151*51322Sericifdef(`_CLASS_U_', 152*51322Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 153*51322Sericifdef(`_CLASS_V_', 154*51322Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 155*51322Sericifdef(`_CLASS_W_', 156*51322Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 157*51322Sericifdef(`_CLASS_X_', 158*51322Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 159*51322Sericifdef(`_CLASS_Y_', 160*51322Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 16151267Seric 16251267Seric# try UUCP traffic as a local address 163*51322SericR$* < @ $+ .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 164*51322Sericifdef(`NEWSENDMAIL', 165*51322Seric`R$* < @ $+ . .UUCP > $* $@ $1 < @ $2 . > $3', 166*51322Seric`R$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4')') 16751267Seric 16851222Seric# pass to name server to make hostname canonical 169*51322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 17051222Seric 171*51322Seric# if this is the local hostname, make sure we treat is as canonical 172*51322SericR$* < @ $j > $* $: $1 < @ $j . > $2 17351222Seric 174*51322Seric 17551222Seric################################################## 17651222Seric### Ruleset 4 -- Final Output Post-rewriting ### 17751222Seric################################################## 17851222SericS4 17951222Seric 18051222SericR@ $@ handle <> error addr 18151222Seric 18251222Seric# resolve numeric addresses to name if possible 183*51322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 18451222Seric 185*51322Seric# strip trailing dot off possibly canonical name 186*51322SericR$* < @ $+ . > $* $1 < @ $2 > $3 187*51322Seric 18851222Seric# externalize local domain info 189*51322SericR$* < $+ > $* $1 $2 $3 defocus 190*51322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 19151222Seric 19251222Seric# UUCP must always be presented in old form 193*51322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 19451222Seric 19551222Seric# delete duplicate local names 196*51322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 19751222Seric 19851222Seric 19951222Seric 20051222Seric############################################################# 20151222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 20251222Seric### (used for recursive calls) ### 20351222Seric############################################################# 20451222Seric 20551222SericS7 20651222SericR$* $: $>3 $1 20751222SericR$* $@ $>0 $1 20851222Seric 20951222Seric 21051222Seric###################################### 21151222Seric### Ruleset 0 -- Parse Address ### 21251222Seric###################################### 21351222Seric 21451222SericS0 21551222Seric 21651222Seric# handle numeric address spec 217*51322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 218*51322SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec 21951222Seric 22051222Seric#R@ $#error$:Invalid address handle <> form 22151222Seric 222*51322Sericifdef(`NEWSENDMAIL', 223*51322Seric`# now delete the local info -- note $=O to find characters that cause forwarding 224*51322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 225*51322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 22651222Seric 22751222Seric# short circuit local delivery so forwarded email works 228*51322SericR$+ < @ $j . > $#local $: : $1 local address', 229*51322Seric`# delete local info 230*51322SericR$* < @ $j . > $* $@ $>7 $1 $2') 23151222Seric 23251222Sericundivert(3)dnl 23351222Seric 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:... 258*51322SericR$+ < @ $+ .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 264*51322Sericifdef(`NEWSENDMAIL', 265*51322Seric`# handle locally delivered names 266*51322Sericifdef(`LOCAL_RELAY', 267*51322Seric`R$=L $# local $: : $1 special local names', 268*51322Seric `dnl') 269*51322SericR$+ $# local $: $1 regular local names 270*51322Seric', `ifdef(`LOCAL_RELAY', 271*51322Seric`# forward remaining names to local relay 272*51322SericR$+ $# smtp $@ $R $: $1 @ $R', 273*51322Seric`# remaining names must be local 274*51322SericR$+ $# local $: $1')') 27551222Seric 276*51322Sericifdef(`LOCAL_RELAY', `ifdef(`NEWSENDMAIL', 277*51322Seric`# 278*51322Seric# special rewriting after aliases have been expanded 279*51322Seric# 28051222Seric 281*51322SericS5 282*51322Seric 283*51322SericR$+ $# smtp $@ $R $: $1 < @ $R > send to relay')') 28451222Seric# 28551222Seric###################################################################### 28651222Seric###################################################################### 28751222Seric##### 28851222Seric##### MAILER DEFINITIONS 28951222Seric##### 29051222Seric###################################################################### 29151222Seric###################################################################### 29251222Seric 29351222Sericundivert(7)dnl 294