16f4c5567Sericdivert(-1) 26f4c5567Seric# 36f4c5567Seric# Copyright (c) 1983 Eric P. Allman 46f4c5567Seric# Copyright (c) 1988 The Regents of the University of California. 56f4c5567Seric# All rights reserved. 66f4c5567Seric# 76f4c5567Seric# %sccs.include.redist.sh% 86f4c5567Seric# 96f4c5567Sericdivert(0) 106f4c5567Seric 11*138c6544SericVERSIONID(@(#)proto.m4 2.10 (Berkeley) 10/03/91) 126f4c5567Seric 136f4c5567Seric 146f4c5567Seric################## 156f4c5567Seric# local info # 166f4c5567Seric################## 176f4c5567Seric 186f4c5567Sericifdef(`_USE_CW_FILE_', 196f4c5567Seric`# file containing internet aliases in our primary domain 206f4c5567SericFw/etc/sendmail.cw', `dnl') 216f4c5567Seric 226f4c5567Sericifdef(`UUCP_RELAY', 236f4c5567Seric`# UUCP relay host 2413c6b009SericCONCAT(DY, UUCP_RELAY) 256f4c5567Seric')dnl 266f4c5567Sericifdef(`BITNET_RELAY', 276f4c5567Seric`# BITNET relay host 286f4c5567SericCONCAT(DB, BITNET_RELAY) 296f4c5567Seric')dnl 306f4c5567Sericifdef(`CSNET_RELAY', 316f4c5567Seric`# CSNET relay host 326f4c5567SericCONCAT(DC, CSNET_RELAY) 336f4c5567Seric')dnl 346f4c5567Seric# my official hostname ($w or $w.$D) 356f4c5567SericDj$w 366f4c5567Seric 376f4c5567Seric# who I masquerade as (can be $j) 386f4c5567SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 396f4c5567Seric 406f4c5567Seric# who I send unqualified names to (null means deliver locally) 416f4c5567SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 426f4c5567Seric 4371dc253dSeric# names that should be delivered locally, even if we have a relay 4471dc253dSericCLroot 4571dc253dSericundivert(5)dnl 4671dc253dSeric 476f4c5567Sericifdef(`UUCP_NAME', 4871e1a4d1Seric`# uucp hostnames 496f4c5567SericUUCP_NAME 506f4c5567SericUUCP_ALIASES 516f4c5567Seric 526f4c5567Seric# local UUCP connections 5371e1a4d1Sericinclude(UUCP_HOSTS_FILE)', 540f4f4bbbSeric`dnl') 556f4c5567Seric 566f4c5567Seric# operators that cannot be in local usernames (i.e., network indicators) 576f4c5567SericCO @ % ! 586f4c5567Seric 590f4f4bbbSericifdef(`USERDB_FILE', 600f4f4bbbSeric`# location of user database file (null means no lookup) 6171e1a4d1SericCONCAT(`OU', USERDB_FILE)', 6271e1a4d1Seric`dnl') 636f4c5567Seric 646f4c5567Sericifdef(`_NO_WILDCARD_MX_', 656f4c5567Seric`# we can guarantee no wildcard MX records matching our domain 6671e1a4d1SericOw', 6771e1a4d1Seric`dnl') 686f4c5567Seric 696f4c5567Sericinclude(`../m4/version.m4') 706f4c5567Seric 7171e1a4d1Sericifdef(`INTERNET_RELAY', 7271e1a4d1Seric`include(../sitedep/nicregistered.m4)', 7371e1a4d1Seric`dnl') 746f4c5567Sericinclude(`../m4/boilerplate.m4') 756f4c5567Seric# 766f4c5567Seric###################################################################### 776f4c5567Seric###################################################################### 786f4c5567Seric##### 796f4c5567Seric##### REWRITING RULES 806f4c5567Seric##### 816f4c5567Seric###################################################################### 826f4c5567Seric###################################################################### 836f4c5567Seric 846f4c5567Seric 856f4c5567Seric########################################### 866f4c5567Seric### Rulset 3 -- Name Canonicalization ### 876f4c5567Seric########################################### 8871e1a4d1SericS3 896f4c5567Seric 906f4c5567Seric# handle "from:<>" special case 916f4c5567SericR$*<>$* $@@ turn into magic token 926f4c5567Seric 936f4c5567Seric# basic textual canonicalization -- note RFC733 heuristic here 946f4c5567SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 956f4c5567SericR$*<$*<$+>$*>$* $3 2-level <> nesting 966f4c5567SericR$*<$+>$* $2 basic RFC821/822 parsing 976f4c5567Seric 986f4c5567Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 996f4c5567SericR@$+,$+ @$1:$2 change all "," to ":" 1006f4c5567Seric 1016f4c5567Seric# localize and dispose of route-based addresses 1026f4c5567SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 1036f4c5567Seric 1046f4c5567Seric# find focus for list syntax 1056f4c5567SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 1066f4c5567SericR$+:$*; $@$1:$2; list syntax 1076f4c5567Seric 1086f4c5567Seric# find focus for @ syntax addresses 1096f4c5567SericR$+@$+ $:$1<@$2> focus on domain 1106f4c5567SericR$+<$+@$+> $1$2<@$3> move gaze right 1116f4c5567SericR$+<@$+> $@$>6$1<@$2> already canonical 1126f4c5567Seric 1136f4c5567Seric# convert old-style addresses to a domain-based address 1146f4c5567SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 1156f4c5567SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 1166f4c5567SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 1176f4c5567Seric 1186f4c5567Seric# if we have % signs, take the rightmost one 1196f4c5567SericR$*%$* $1@$2 First make them all @s. 1206f4c5567SericR$*@$*@$* $1%$2@$3 Undo all but the last. 1216f4c5567SericR$*@$* $@$>6$1<@$2> Insert < > and finish 1226f4c5567Seric 1236f4c5567Seric# else we must be a local name 1246f4c5567Seric 1256f4c5567Seric 1266f4c5567Seric############################################### 1276f4c5567Seric### Ruleset 6 -- bottom half of ruleset 3 ### 1286f4c5567Seric############################################### 1296f4c5567Seric 1306f4c5567Seric# At this point, everything should be in a local_part@domain format. 1316f4c5567Seric 1326f4c5567SericS6 1336f4c5567Sericundivert(2)dnl 1346f4c5567Seric 1356f4c5567Seric# handle special cases for local names 1366f4c5567SericR$* < @ $=w > $* $: $1 < @ $w > $3 no domain at all 1376f4c5567SericR$* < @ $=w .UUCP> $* $: $1 < @ $w > $3 .UUCP domain 1386f4c5567Seric 139788179f5Sericifdef(`UUCP_RELAY', 140788179f5Seric`# pass UUCP addresses straight through 141788179f5SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 .UUCP > $3', 142788179f5Seric`# if really UUCP, handle it immediately 143a027f997SericR$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3 144a027f997SericR$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3 145a027f997SericR$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3 146a027f997SericR$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3 147a027f997SericR$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3 148a027f997Seric 149a027f997Seric# try UUCP traffic as a local address 150a027f997SericR$* < @ $- .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 151788179f5SericR$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4') 152a027f997Seric 1536f4c5567Seric# pass to name server to make hostname canonical 1546f4c5567SericR$* < @ $+ > $* $: $1 < @ $[ $2 $] > $3 then do anything 1556f4c5567Seric 1566f4c5567Seric 1576f4c5567Seric################################################## 1586f4c5567Seric### Ruleset 4 -- Final Output Post-rewriting ### 1596f4c5567Seric################################################## 1606f4c5567SericS4 1616f4c5567Seric 1626f4c5567SericR@ $@ handle <> error addr 1636f4c5567Seric 1646f4c5567Seric# resolve numeric addresses to name if possible 1656f4c5567SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr 1666f4c5567Seric 1676f4c5567Seric# externalize local domain info 1686f4c5567SericR$*<$+>$* $1$2$3 defocus 1696f4c5567SericR@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical 1706f4c5567Seric 1716f4c5567Seric# UUCP must always be presented in old form 1726f4c5567SericR$+@$-.UUCP $2!$1 u@h.UUCP => h!u 1736f4c5567Seric 1746f4c5567Seric# delete duplicate local names 1756f4c5567SericR$+%$=w@$=w $1@$w u%host@host => u@host 1766f4c5567Seric 1776f4c5567Seric 1786f4c5567Seric 1796f4c5567Seric############################################################# 1806f4c5567Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 1816f4c5567Seric### (used for recursive calls) ### 1826f4c5567Seric############################################################# 1836f4c5567Seric 1846f4c5567SericS7 1856f4c5567SericR$* $: $>3 $1 1866f4c5567SericR$* $@ $>0 $1 1876f4c5567Seric 1886f4c5567Seric 1896f4c5567Seric###################################### 1906f4c5567Seric### Ruleset 0 -- Parse Address ### 1916f4c5567Seric###################################### 1926f4c5567Seric 1936f4c5567SericS0 1946f4c5567Seric 1956f4c5567Seric# handle numeric address spec 1966f4c5567SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr 1976f4c5567SericR$*<@[$+]>$* $#smtp$@[$2]$:$1@[$2]$3 numeric internet spec 1986f4c5567Seric 1996f4c5567Seric#R@ $#error$:Invalid address handle <> form 2006f4c5567Seric 2016f4c5567Seric# now delete the local info -- note $=O to find characters that cause forwarding 2026f4c5567SericR<@$w>:$* $@$>7$1 @here:... -> ... 2036f4c5567SericR$*$=O$*<@$w> $@$>7$1$2$3 ...@here -> ... 2046f4c5567Seric 2056f4c5567Seric# short circuit local delivery so forwarded email works 2066f4c5567SericR$+<@$w> $#local$:$1 local address 2076f4c5567Seric 2086f4c5567Sericundivert(3)dnl 2096f4c5567Seric 21071e1a4d1Sericundivert(4)dnl 21171e1a4d1Seric 21271e1a4d1Seric# resolve remotely connected UUCP links 213*138c6544Sericifdef(`_CLASS_V_', 214*138c6544Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl') 215*138c6544Sericifdef(`_CLASS_W_', 216*138c6544Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl') 217*138c6544Sericifdef(`_CLASS_X_', 218*138c6544Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl') 21971e1a4d1Seric 2206f4c5567Seric# resolve fake top level domains by forwarding to other hosts 2216f4c5567Sericifdef(`BITNET_RELAY', 2226f4c5567Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 2236f4c5567Seric `dnl') 2246f4c5567Sericifdef(`CSNET_RELAY', 2256f4c5567Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 2266f4c5567Seric `dnl') 2276f4c5567Seric 22871e1a4d1Sericifdef(`UUCP_RELAY', 22971e1a4d1Seric`# forward non-local UUCP traffic to our UUCP relay 23013c6b009SericR$*<@$*.UUCP>$* $#smtp$@$Y$:$1<@$2.UUCP> uucp mail', 23171e1a4d1Seric`ifdef(`_UUCP_LINKED_', 23271e1a4d1Seric`# forward other UUCP traffic straight to UUCP 23371e1a4d1SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 23471e1a4d1SericR$+ < @ $+ .UUCP> $#uucp $@ $2 $: $1 user@host.UUCP', 23571e1a4d1Seric `dnl')') 2366f4c5567Seric 23771e1a4d1Seric# deal with other remote names 2386f4c5567SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 2396f4c5567Seric 2406f4c5567Seric# see if we forward local names 2416f4c5567SericR$=L $# local $: $1 special local names 2426f4c5567SericR$+ $: $1 @ $R 2436f4c5567SericR$+ @ $: $1 no, we don't 2446f4c5567SericR$+ @ $+ $# smtp $@ $2 $: $1 yes, we do 2456f4c5567Seric 2466f4c5567Seric# remaining names must be local 2476f4c5567SericR$+ $#local$:$1 everything else 2486f4c5567Seric 2496f4c5567Seric# 2506f4c5567Seric###################################################################### 2516f4c5567Seric###################################################################### 2526f4c5567Seric##### 2536f4c5567Seric##### MAILER DEFINITIONS 2546f4c5567Seric##### 2556f4c5567Seric###################################################################### 2566f4c5567Seric###################################################################### 2576f4c5567Seric 2586f4c5567Sericundivert(7)dnl 259