1*6f4c5567Sericdivert(-1) 2*6f4c5567Seric# 3*6f4c5567Seric# Copyright (c) 1983 Eric P. Allman 4*6f4c5567Seric# Copyright (c) 1988 The Regents of the University of California. 5*6f4c5567Seric# All rights reserved. 6*6f4c5567Seric# 7*6f4c5567Seric# %sccs.include.redist.sh% 8*6f4c5567Seric# 9*6f4c5567Sericdivert(0) 10*6f4c5567Seric 11*6f4c5567SericVERSIONID(@(#)proto.m4 2.1 (Berkeley) 10/02/91) 12*6f4c5567Seric 13*6f4c5567Seric 14*6f4c5567Seric 15*6f4c5567Seric################## 16*6f4c5567Seric# local info # 17*6f4c5567Seric################## 18*6f4c5567Seric 19*6f4c5567Sericifdef(`_USE_CW_FILE_', 20*6f4c5567Seric`# file containing internet aliases in our primary domain 21*6f4c5567SericFw/etc/sendmail.cw', `dnl') 22*6f4c5567Seric 23*6f4c5567Sericifdef(`UUCP_RELAY', 24*6f4c5567Seric`# UUCP relay host 25*6f4c5567SericCONCAT(DU, UUCP_RELAY) 26*6f4c5567Seric')dnl 27*6f4c5567Sericifdef(`BITNET_RELAY', 28*6f4c5567Seric`# BITNET relay host 29*6f4c5567SericCONCAT(DB, BITNET_RELAY) 30*6f4c5567Seric')dnl 31*6f4c5567Sericifdef(`CSNET_RELAY', 32*6f4c5567Seric`# CSNET relay host 33*6f4c5567SericCONCAT(DC, CSNET_RELAY) 34*6f4c5567Seric')dnl 35*6f4c5567Seric# my official hostname ($w or $w.$D) 36*6f4c5567SericDj$w 37*6f4c5567Seric 38*6f4c5567Seric# who I masquerade as (can be $j) 39*6f4c5567SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 40*6f4c5567Seric 41*6f4c5567Seric# who I send unqualified names to (null means deliver locally) 42*6f4c5567SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 43*6f4c5567Seric 44*6f4c5567Seric 45*6f4c5567Sericifdef(`UUCP_NAME', 46*6f4c5567Seric# uucp hostnames 47*6f4c5567SericUUCP_NAME 48*6f4c5567SericUUCP_ALIASES 49*6f4c5567Seric 50*6f4c5567Seric# local UUCP connections 51*6f4c5567Seric`include(UUCP_HOSTS_FILE)') 52*6f4c5567Seric 53*6f4c5567Seric# operators that cannot be in local usernames (i.e., network indicators) 54*6f4c5567SericCO @ % ! 55*6f4c5567Seric 56*6f4c5567Seric# location of user database file (null means no lookup) 57*6f4c5567Sericifdef(`USERDB_FILE', `CONCAT(`OU', USERDB_FILE)', `dnl') 58*6f4c5567Seric 59*6f4c5567Sericifdef(`_NO_WILDCARD_MX_', 60*6f4c5567Seric`# we can guarantee no wildcard MX records matching our domain 61*6f4c5567SericOw', `dnl')dnl 62*6f4c5567Seric 63*6f4c5567Sericinclude(`../m4/version.m4') 64*6f4c5567Seric 65*6f4c5567Seric#ifdef(`INTERNET_RELAY', 66*6f4c5567Seric#`include(../sitedep/nicregistered.m4)') 67*6f4c5567Sericinclude(`../m4/boilerplate.m4') 68*6f4c5567Seric 69*6f4c5567Seric# 70*6f4c5567Seric###################################################################### 71*6f4c5567Seric###################################################################### 72*6f4c5567Seric##### 73*6f4c5567Seric##### REWRITING RULES 74*6f4c5567Seric##### 75*6f4c5567Seric###################################################################### 76*6f4c5567Seric###################################################################### 77*6f4c5567Seric 78*6f4c5567Seric 79*6f4c5567Seric########################################### 80*6f4c5567Seric### Rulset 3 -- Name Canonicalization ### 81*6f4c5567Seric########################################### 82*6f4c5567Seric`S3 83*6f4c5567Seric 84*6f4c5567Seric# handle "from:<>" special case 85*6f4c5567SericR$*<>$* $@@ turn into magic token 86*6f4c5567Seric 87*6f4c5567Seric# basic textual canonicalization -- note RFC733 heuristic here 88*6f4c5567SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 89*6f4c5567SericR$*<$*<$+>$*>$* $3 2-level <> nesting 90*6f4c5567SericR$*<$+>$* $2 basic RFC821/822 parsing 91*6f4c5567Seric 92*6f4c5567Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 93*6f4c5567SericR@$+,$+ @$1:$2 change all "," to ":" 94*6f4c5567Seric 95*6f4c5567Seric# localize and dispose of route-based addresses 96*6f4c5567SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 97*6f4c5567Seric 98*6f4c5567Seric# find focus for list syntax 99*6f4c5567SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 100*6f4c5567SericR$+:$*; $@$1:$2; list syntax 101*6f4c5567Seric 102*6f4c5567Seric# find focus for @ syntax addresses 103*6f4c5567SericR$+@$+ $:$1<@$2> focus on domain 104*6f4c5567SericR$+<$+@$+> $1$2<@$3> move gaze right 105*6f4c5567SericR$+<@$+> $@$>6$1<@$2> already canonical 106*6f4c5567Seric 107*6f4c5567Seric# convert old-style addresses to a domain-based address 108*6f4c5567SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 109*6f4c5567SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 110*6f4c5567SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 111*6f4c5567Seric 112*6f4c5567Seric# if we have % signs, take the rightmost one 113*6f4c5567SericR$*%$* $1@$2 First make them all @s. 114*6f4c5567SericR$*@$*@$* $1%$2@$3 Undo all but the last. 115*6f4c5567SericR$*@$* $@$>6$1<@$2> Insert < > and finish 116*6f4c5567Seric 117*6f4c5567Seric# else we must be a local name 118*6f4c5567Seric 119*6f4c5567Seric 120*6f4c5567Seric############################################### 121*6f4c5567Seric### Ruleset 6 -- bottom half of ruleset 3 ### 122*6f4c5567Seric############################################### 123*6f4c5567Seric 124*6f4c5567Seric# 125*6f4c5567Seric# At this point, everything should be in a local_part@domain format. 126*6f4c5567Seric# This ruleset is primarily responsible for 127*6f4c5567Seric 128*6f4c5567SericS6 129*6f4c5567Seric' 130*6f4c5567Sericundivert(2)dnl 131*6f4c5567Seric 132*6f4c5567Seric# handle special cases for local names 133*6f4c5567SericR$*<@$=w>$* $:$1<@$w>$3 no domain at all 134*6f4c5567SericR$*<@$=w.UUCP>$* $:$1<@$w>$3 .UUCP domain 135*6f4c5567SericR$*<@$=U.UUCP>$* $:$1<@$w>$3 UUCP-specific names 136*6f4c5567Seric 137*6f4c5567Seric# pass to name server to make hostname canonical 138*6f4c5567SericR$* < @ $+ > $* $: $1 < @ $[ $2 $] > $3 then do anything 139*6f4c5567Seric 140*6f4c5567Seric# hack to add local domain if nothing sofar has done so 141*6f4c5567SericR$* < @ $- > $* $: $1 < @ $2 @ $w > $3 throw on local host 142*6f4c5567SericR$* < @ $- @ $- $* > $* $: $1 < @ $2 $4 > $5 strip host part only 143*6f4c5567Seric 144*6f4c5567Seric 145*6f4c5567Seric################################################## 146*6f4c5567Seric### Ruleset 4 -- Final Output Post-rewriting ### 147*6f4c5567Seric################################################## 148*6f4c5567SericS4 149*6f4c5567Seric 150*6f4c5567SericR@ $@ handle <> error addr 151*6f4c5567Seric 152*6f4c5567Seric# resolve numeric addresses to name if possible 153*6f4c5567SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr 154*6f4c5567Seric 155*6f4c5567Seric# externalize local domain info 156*6f4c5567SericR$*<$+>$* $1$2$3 defocus 157*6f4c5567SericR@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical 158*6f4c5567Seric 159*6f4c5567Seric# UUCP must always be presented in old form 160*6f4c5567SericR$+@$-.UUCP $2!$1 u@h.UUCP => h!u 161*6f4c5567Seric 162*6f4c5567Seric# delete duplicate local names 163*6f4c5567SericR$+%$=w@$=w $1@$w u%host@host => u@host 164*6f4c5567Seric#R$+%$=w@$=w.$D $1@$w u%host@host => u@host 165*6f4c5567Seric 166*6f4c5567Seric 167*6f4c5567Seric 168*6f4c5567Seric############################################################# 169*6f4c5567Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 170*6f4c5567Seric### (used for recursive calls) ### 171*6f4c5567Seric############################################################# 172*6f4c5567Seric 173*6f4c5567SericS7 174*6f4c5567SericR$* $: $>3 $1 175*6f4c5567SericR$* $@ $>0 $1 176*6f4c5567Seric 177*6f4c5567Seric 178*6f4c5567Seric###################################### 179*6f4c5567Seric### Ruleset 0 -- Parse Address ### 180*6f4c5567Seric###################################### 181*6f4c5567Seric 182*6f4c5567SericS0 183*6f4c5567Seric 184*6f4c5567Seric# handle numeric address spec 185*6f4c5567SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr 186*6f4c5567SericR$*<@[$+]>$* $#smtp$@[$2]$:$1@[$2]$3 numeric internet spec 187*6f4c5567Seric 188*6f4c5567Seric#R@ $#error$:Invalid address handle <> form 189*6f4c5567Seric 190*6f4c5567Seric# now delete the local info -- note $=O to find characters that cause forwarding 191*6f4c5567SericR<@$w>:$* $@$>7$1 @here:... -> ... 192*6f4c5567SericR$*$=O$*<@$w> $@$>7$1$2$3 ...@here -> ... 193*6f4c5567Seric 194*6f4c5567Seric# short circuit local delivery so forwarded email works 195*6f4c5567SericR$+<@$w> $#local$:$1 local address 196*6f4c5567Seric 197*6f4c5567Sericundivert(3)dnl 198*6f4c5567Seric 199*6f4c5567Seric# resolve fake top level domains by forwarding to other hosts 200*6f4c5567Sericifdef(`BITNET_RELAY', 201*6f4c5567Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 202*6f4c5567Seric `dnl') 203*6f4c5567Sericifdef(`CSNET_RELAY', 204*6f4c5567Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 205*6f4c5567Seric `dnl') 206*6f4c5567Seric 207*6f4c5567Seric# forward non-local UUCP traffic to our UUCP relay 208*6f4c5567SericR$*<@$*.UUCP>$* $#smtp$@$U$:$1<@$2.UUCP> uucp mail 209*6f4c5567Seric 210*6f4c5567Seric# hide behind our internet relay when talking to people in the .ARPA domain 211*6f4c5567Seric#R$*<@$*.ARPA>$* $#smtp-nic$@$2.ARPA$:$1<@$2.ARPA>$3 user@host.ARPA 212*6f4c5567Seric 213*6f4c5567Seric# but speak domains to them if they speak domains too 214*6f4c5567SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 215*6f4c5567Seric 216*6f4c5567Seric# see if we forward local names 217*6f4c5567SericR$=L $# local $: $1 special local names 218*6f4c5567SericR$+ $: $1 @ $R 219*6f4c5567SericR$+ @ $: $1 no, we don't 220*6f4c5567SericR$+ @ $+ $# smtp $@ $2 $: $1 yes, we do 221*6f4c5567Seric 222*6f4c5567Seric# remaining names must be local 223*6f4c5567SericR$+ $#local$:$1 everything else 224*6f4c5567Seric 225*6f4c5567Seric# 226*6f4c5567Seric###################################################################### 227*6f4c5567Seric###################################################################### 228*6f4c5567Seric##### 229*6f4c5567Seric##### MAILER DEFINITIONS 230*6f4c5567Seric##### 231*6f4c5567Seric###################################################################### 232*6f4c5567Seric###################################################################### 233*6f4c5567Seric 234*6f4c5567Sericundivert(7)dnl 235