1divert(-1) 2# 3# Copyright (c) 1983 Eric P. Allman 4# Copyright (c) 1988 The Regents of the University of California. 5# All rights reserved. 6# 7# %sccs.include.redist.sh% 8# 9divert(0) 10 11VERSIONID(@(#)proto.m4 2.14 (Berkeley) 10/05/91) 12 13MAILER(local)dnl 14 15################## 16# local info # 17################## 18 19ifdef(`_USE_CW_FILE_', 20`# file containing internet aliases in our primary domain 21Fw/etc/sendmail.cw', `dnl') 22 23ifdef(`UUCP_RELAY', 24`# UUCP relay host 25CONCAT(DY, UUCP_RELAY) 26')dnl 27ifdef(`BITNET_RELAY', 28`# BITNET relay host 29CONCAT(DB, BITNET_RELAY) 30')dnl 31ifdef(`CSNET_RELAY', 32`# CSNET relay host 33CONCAT(DC, CSNET_RELAY) 34')dnl 35# my official hostname ($w or $w.$D) 36CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 37 38# who I masquerade as (can be $j) 39CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 40 41# who I send unqualified names to (null means deliver locally) 42CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 43 44# names that should be delivered locally, even if we have a relay 45CLroot 46undivert(5)dnl 47 48ifdef(`UUCP_NAME', 49`# uucp hostnames 50UUCP_NAME 51UUCP_ALIASES 52 53# local UUCP connections 54include(UUCP_HOSTS_FILE)', 55`dnl') 56 57# operators that cannot be in local usernames (i.e., network indicators) 58CO @ % ! 59 60# a class with just dot (for identifying canonical names) 61C.. 62 63ifdef(`USERDB_FILE', 64`# location of user database file (null means no lookup) 65CONCAT(`OU', USERDB_FILE)', 66`dnl') 67 68ifdef(`_NO_WILDCARD_MX_', 69`# we can guarantee no wildcard MX records matching our domain 70Ow', 71`dnl') 72 73ifdef(`NEWSENDMAIL', 74`# level 2 config file format 75O=2', `dnl') 76 77include(`../m4/version.m4') 78 79ifdef(`INTERNET_RELAY', 80`include(../sitedep/nicregistered.m4)', 81`dnl') 82include(`../m4/boilerplate.m4') 83# 84###################################################################### 85###################################################################### 86##### 87##### REWRITING RULES 88##### 89###################################################################### 90###################################################################### 91 92 93########################################### 94### Rulset 3 -- Name Canonicalization ### 95########################################### 96S3 97 98# handle "from:<>" special case 99R$*<>$* $@@ turn into magic token 100 101# basic textual canonicalization -- note RFC733 heuristic here 102R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 103R$*<$*<$+>$*>$* $3 2-level <> nesting 104R$*<$+>$* $2 basic RFC821/822 parsing 105 106# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 107R@$+,$+ @$1:$2 change all "," to ":" 108 109# localize and dispose of route-based addresses 110R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 111 112# find focus for list syntax 113R$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 114R$+:$*; $@$1:$2; list syntax 115 116# find focus for @ syntax addresses 117R$+@$+ $:$1<@$2> focus on domain 118R$+<$+@$+> $1$2<@$3> move gaze right 119R$+<@$+> $@$>6$1<@$2> already canonical 120 121# convert old-style addresses to a domain-based address 122R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 123R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 124R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 125 126# if we have % signs, take the rightmost one 127R$*%$* $1@$2 First make them all @s. 128R$*@$*@$* $1%$2@$3 Undo all but the last. 129R$*@$* $@$>6$1<@$2> Insert < > and finish 130 131# else we must be a local name 132 133 134############################################### 135### Ruleset 6 -- bottom half of ruleset 3 ### 136############################################### 137 138# At this point, everything should be in a local_part@domain format. 139 140S6 141undivert(2)dnl 142 143# handle special cases for local names 144R$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 145R$* < @ $=w .UUCP> $* $: $1 < @ $j . > $3 .UUCP domain 146 147ifdef(`UUCP_RELAY', 148`# pass UUCP addresses straight through 149R$* < @ $+ . UUCP > $* $@ $1 < @ $2 .UUCP > $3', 150`# if really UUCP, handle it immediately 151ifdef(`_CLASS_U_', 152`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 153ifdef(`_CLASS_V_', 154`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 155ifdef(`_CLASS_W_', 156`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 157ifdef(`_CLASS_X_', 158`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 159ifdef(`_CLASS_Y_', 160`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3', `dnl') 161 162# try UUCP traffic as a local address 163R$* < @ $+ .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 164ifdef(`NEWSENDMAIL', 165`R$* < @ $+ . .UUCP > $* $@ $1 < @ $2 . > $3', 166`R$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4')') 167 168# pass to name server to make hostname canonical 169R$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 170 171# if this is the local hostname, make sure we treat is as canonical 172R$* < @ $j > $* $: $1 < @ $j . > $2 173 174 175################################################## 176### Ruleset 4 -- Final Output Post-rewriting ### 177################################################## 178S4 179 180R@ $@ handle <> error addr 181 182# resolve numeric addresses to name if possible 183R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 184 185# strip trailing dot off possibly canonical name 186R$* < @ $+ . > $* $1 < @ $2 > $3 187 188# externalize local domain info 189R$* < $+ > $* $1 $2 $3 defocus 190R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 191 192# UUCP must always be presented in old form 193R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 194 195# delete duplicate local names 196R$+ % $=w @ $=w $1 @ $j u%host@host => u@host 197 198 199 200############################################################# 201### Ruleset 7 -- recanonicalize and call ruleset zero ### 202### (used for recursive calls) ### 203############################################################# 204 205S7 206R$* $: $>3 $1 207R$* $@ $>0 $1 208 209 210###################################### 211### Ruleset 0 -- Parse Address ### 212###################################### 213 214S0 215 216# handle numeric address spec 217R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 218R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec 219 220#R@ $#error$:Invalid address handle <> form 221 222ifdef(`LOCAL_RELAY', 223`# now delete the local info -- note $=O to find characters that cause forwarding 224R< @ $j . > : $* $@ $>7 $1 @here:... -> ... 225R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 226 227# short circuit local delivery so forwarded email works 228ifdef(`NEWSENDMAIL', 229`R$+ < @ $j . > $#local $: : $1 local address', 230`R$+ < @ $j . > $#local $: $1 local address')', 231`# delete local info 232R$* < @ $j . > $* $@ $>7 $1 $2') 233 234undivert(3)dnl 235 236undivert(4)dnl 237 238# resolve remotely connected UUCP links 239ifdef(`_CLASS_V_', 240`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl') 241ifdef(`_CLASS_W_', 242`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl') 243ifdef(`_CLASS_X_', 244`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl') 245 246# resolve fake top level domains by forwarding to other hosts 247ifdef(`BITNET_RELAY', 248`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 249 `dnl') 250ifdef(`CSNET_RELAY', 251`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 252 `dnl') 253 254ifdef(`UUCP_RELAY', 255`# forward non-local UUCP traffic to our UUCP relay 256R$*<@$*.UUCP>$* $#smtp$@$Y$:$1<@$2.UUCP> uucp mail', 257`ifdef(`_UUCP_LINKED_', 258`# forward other UUCP traffic straight to UUCP 259R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 260R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 261 `dnl')') 262 263# deal with other remote names 264R$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 265 266ifdef(`NEWSENDMAIL', 267`# handle locally delivered names 268ifdef(`LOCAL_RELAY', 269`R$=L $# local $: : $1 special local names', 270 `dnl') 271R$+ $# local $: $1 regular local names 272', `ifdef(`LOCAL_RELAY', 273`# forward remaining names to local relay 274R$+ $# smtp $@ $R $: $1 @ $R', 275`# remaining names must be local 276R$+ $# local $: $1')') 277 278ifdef(`LOCAL_RELAY', `ifdef(`NEWSENDMAIL', 279`# 280# special rewriting after aliases have been expanded 281# 282 283S5 284 285R$+ $# smtp $@ $R $: $1 < @ $R > send to relay')') 286# 287###################################################################### 288###################################################################### 289##### 290##### MAILER DEFINITIONS 291##### 292###################################################################### 293###################################################################### 294 295undivert(7)dnl 296