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*7b2c0d8dSericVERSIONID(`@(#)proto.m4 2.33 (Berkeley) 12/07/92') 126f4c5567Seric 1363eeb308SericMAILER(local)dnl 146f4c5567Seric 15472f2a37Sericifdef(`_OLD_SENDMAIL_', `dnl', 16472f2a37Seric`# level 3 config file format 17472f2a37SericV3') 18472f2a37Seric 196f4c5567Seric################## 206f4c5567Seric# local info # 216f4c5567Seric################## 226f4c5567Seric 2331695942SericCwlocalhost 24b1286b66Sericifdef(`USE_CW_FILE', 2531695942Seric`# file containing names of hosts for which we receive email 266f4c5567SericFw/etc/sendmail.cw', `dnl') 276f4c5567Seric 286f4c5567Sericifdef(`UUCP_RELAY', 296f4c5567Seric`# UUCP relay host 3013c6b009SericCONCAT(DY, UUCP_RELAY) 316f4c5567Seric')dnl 326f4c5567Sericifdef(`BITNET_RELAY', 336f4c5567Seric`# BITNET relay host 346f4c5567SericCONCAT(DB, BITNET_RELAY) 356f4c5567Seric')dnl 366f4c5567Sericifdef(`CSNET_RELAY', 376f4c5567Seric`# CSNET relay host 386f4c5567SericCONCAT(DC, CSNET_RELAY) 396f4c5567Seric')dnl 406f4c5567Seric# my official hostname ($w or $w.$D) 41b47d0647SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 426f4c5567Seric 436f4c5567Seric# who I masquerade as (can be $j) 446f4c5567SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 456f4c5567Seric 466f4c5567Seric# who I send unqualified names to (null means deliver locally) 476f4c5567SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 486f4c5567Seric 4971dc253dSeric# names that should be delivered locally, even if we have a relay 5071dc253dSericCLroot 5171dc253dSericundivert(5)dnl 5271dc253dSeric 536f4c5567Sericifdef(`UUCP_NAME', 5471e1a4d1Seric`# uucp hostnames 556f4c5567SericUUCP_NAME 566f4c5567SericUUCP_ALIASES 576f4c5567Seric 586f4c5567Seric# local UUCP connections 5971e1a4d1Sericinclude(UUCP_HOSTS_FILE)', 600f4f4bbbSeric`dnl') 616f4c5567Seric 626f4c5567Seric# operators that cannot be in local usernames (i.e., network indicators) 636f4c5567SericCO @ % ! 646f4c5567Seric 6563eeb308Seric# a class with just dot (for identifying canonical names) 6663eeb308SericC.. 6763eeb308Seric 68b1286b66Seric# list of locations of user database file (null means no lookup) 69b1286b66SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC') 706f4c5567Seric 71b1286b66Seric# set if we can guarantee no wildcard MX records matching our domain 720a276cdfSericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False') 736f4c5567Seric 746f4c5567Sericinclude(`../m4/version.m4') 756f4c5567Seric 7671e1a4d1Sericifdef(`INTERNET_RELAY', 7771e1a4d1Seric`include(../sitedep/nicregistered.m4)', 7871e1a4d1Seric`dnl') 796f4c5567Sericinclude(`../m4/boilerplate.m4') 80c97ed732Sericundivert(6)dnl 816f4c5567Seric# 826f4c5567Seric###################################################################### 836f4c5567Seric###################################################################### 846f4c5567Seric##### 856f4c5567Seric##### REWRITING RULES 866f4c5567Seric##### 876f4c5567Seric###################################################################### 886f4c5567Seric###################################################################### 896f4c5567Seric 906f4c5567Seric 916f4c5567Seric########################################### 926f4c5567Seric### Rulset 3 -- Name Canonicalization ### 936f4c5567Seric########################################### 9471e1a4d1SericS3 956f4c5567Seric 966f4c5567Seric# handle "from:<>" special case 976f4c5567SericR$* < > $* $@ @ turn into magic token 986f4c5567Seric 996f4c5567Seric# basic textual canonicalization -- note RFC733 heuristic here 100*7b2c0d8dSericR$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 1016f4c5567SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 1026f4c5567SericR$*<$*<$+>$*>$* $3 2-level <> nesting 1036f4c5567SericR$*<$+>$* $2 basic RFC821/822 parsing 1046f4c5567Seric 1056f4c5567Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 1066f4c5567SericR@ $+ , $+ @ $1 : $2 change all "," to ":" 1076f4c5567Seric 1086f4c5567Seric# localize and dispose of route-based addresses 1096f4c5567SericR@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 1106f4c5567Seric 1116f4c5567Seric# find focus for list syntax 1126f4c5567SericR $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 1136f4c5567SericR $+ : $* ; $@ $1 : $2; list syntax 1146f4c5567Seric 1156f4c5567Seric# find focus for @ syntax addresses 1166f4c5567SericR$+ @ $+ $: $1 < @ $2 > focus on domain 1176f4c5567SericR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 1186f4c5567SericR$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 1196f4c5567Seric 1206f4c5567Seric# convert old-style addresses to a domain-based address 1216f4c5567SericR$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 1226f4c5567SericR$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 1236f4c5567SericR$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains 1246f4c5567Seric 1256f4c5567Seric# if we have % signs, take the rightmost one 1266f4c5567SericR$* % $* $1 @ $2 First make them all @s. 1276f4c5567SericR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 1286f4c5567SericR$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 1296f4c5567Seric 1306f4c5567Seric# else we must be a local name 1316f4c5567Seric 1326f4c5567Seric 1336f4c5567Seric############################################### 1346f4c5567Seric### Ruleset 6 -- bottom half of ruleset 3 ### 1356f4c5567Seric############################################### 1366f4c5567Seric 1376f4c5567Seric# At this point, everything should be in a local_part@domain format. 1386f4c5567Seric 1396f4c5567SericS6 1406f4c5567Seric 1416f4c5567Seric# handle special cases for local names 14263eeb308SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 14363eeb308SericR$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 14431695942Sericundivert(2)dnl 1456f4c5567Seric 146788179f5Sericifdef(`UUCP_RELAY', 147788179f5Seric`# pass UUCP addresses straight through 148788179f5SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 149788179f5Seric`# if really UUCP, handle it immediately 15063eeb308Sericifdef(`_CLASS_U_', 15163eeb308Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15263eeb308Sericifdef(`_CLASS_V_', 15363eeb308Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15463eeb308Sericifdef(`_CLASS_W_', 15563eeb308Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15663eeb308Sericifdef(`_CLASS_X_', 15763eeb308Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15863eeb308Sericifdef(`_CLASS_Y_', 15963eeb308Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 160a027f997Seric 161a027f997Seric# try UUCP traffic as a local address 16263eeb308SericR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 1634588ece0Sericifdef(`_OLD_SENDMAIL_', 1644cad3747Seric`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 16597777037Seric`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 166a027f997Seric 1676f4c5567Seric# pass to name server to make hostname canonical 16863eeb308SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 16963eeb308Seric 17031695942Seric# handle possible alternate names 17131695942SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 17231695942SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 17331695942Sericundivert(8)dnl 17431695942Seric 17563eeb308Seric# if this is the local hostname, make sure we treat is as canonical 17663eeb308SericR$* < @ $j > $* $: $1 < @ $j . > $2 1776f4c5567Seric 1786f4c5567Seric 1796f4c5567Seric################################################## 1806f4c5567Seric### Ruleset 4 -- Final Output Post-rewriting ### 1816f4c5567Seric################################################## 1826f4c5567SericS4 1836f4c5567Seric 1846f4c5567SericR@ $@ handle <> error addr 1856f4c5567Seric 1866f4c5567Seric# resolve numeric addresses to name if possible 1876f4c5567SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 1886f4c5567Seric 18963eeb308Seric# strip trailing dot off possibly canonical name 19063eeb308SericR$* < @ $+ . > $* $1 < @ $2 > $3 19163eeb308Seric 1926f4c5567Seric# externalize local domain info 1936f4c5567SericR$* < $+ > $* $1 $2 $3 defocus 1946f4c5567SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 1951f23b499SericR@ $* $@ @ $1 ... and exit 1966f4c5567Seric 1976f4c5567Seric# UUCP must always be presented in old form 1986f4c5567SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 1996f4c5567Seric 2006f4c5567Seric# delete duplicate local names 201b47d0647SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 2026f4c5567Seric 2036f4c5567Seric 2046f4c5567Seric 2056f4c5567Seric############################################################# 2066f4c5567Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 2076f4c5567Seric### (used for recursive calls) ### 2086f4c5567Seric############################################################# 2096f4c5567Seric 2106f4c5567SericS7 2116f4c5567SericR$* $: $>3 $1 2126f4c5567SericR$* $@ $>0 $1 2136f4c5567Seric 2146f4c5567Seric 2156f4c5567Seric###################################### 2166f4c5567Seric### Ruleset 0 -- Parse Address ### 2176f4c5567Seric###################################### 2186f4c5567Seric 2196f4c5567SericS0 2206f4c5567Seric 2214cad3747Sericifdef(`_MAILER_smtp_', 2224cad3747Seric`# handle numeric address spec 2236f4c5567SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 2244cad3747SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 2253c5c069fSeric`dnl') 2266f4c5567Seric 227b1286b66Seric# now delete the local info -- note $=O to find characters that cause forwarding 22863eeb308SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 22963eeb308SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 2306f4c5567Seric 2316f4c5567Seric# short circuit local delivery so forwarded email works 2324588ece0Sericifdef(`_OLD_SENDMAIL_', 2334588ece0Seric`R$+ < @ $j . > $#local $: $1 local address', 2344588ece0Seric`R$+ < @ $j . > $#local $: @ $1 local address') 2356f4c5567Sericundivert(3)dnl 23671e1a4d1Sericundivert(4)dnl 23771e1a4d1Seric 2384cad3747Seric# resolve remotely connected UUCP links (if any) 239138c6544Sericifdef(`_CLASS_V_', 2406dafc3b0Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 2416dafc3b0Seric `dnl') 242138c6544Sericifdef(`_CLASS_W_', 2436dafc3b0Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 2446dafc3b0Seric `dnl') 245138c6544Sericifdef(`_CLASS_X_', 2466dafc3b0Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 2476dafc3b0Seric `dnl') 24871e1a4d1Seric 2496f4c5567Seric# resolve fake top level domains by forwarding to other hosts 2506f4c5567Sericifdef(`BITNET_RELAY', 2516f4c5567Seric`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 2526f4c5567Seric `dnl') 2536f4c5567Sericifdef(`CSNET_RELAY', 2546f4c5567Seric`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 2556f4c5567Seric `dnl') 2566f4c5567Seric 25771e1a4d1Sericifdef(`UUCP_RELAY', 25871e1a4d1Seric`# forward non-local UUCP traffic to our UUCP relay 2596dafc3b0SericR$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 2604cad3747Seric`ifdef(`_MAILER_uucp_', 26171e1a4d1Seric`# forward other UUCP traffic straight to UUCP 26271e1a4d1SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 26371e1a4d1SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 26471e1a4d1Seric `dnl')') 2656f4c5567Seric 2664cad3747Sericifdef(`_MAILER_smtp_', 2674cad3747Seric`# deal with other remote names 2686f4c5567SericR$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 2694cad3747Seric', `dnl') 2706f4c5567Seric 2714588ece0Sericifdef(`_OLD_SENDMAIL_', 272b1286b66Seric`# forward remaining names to local relay, if any 273adca7ddbSericR$=L $#local $: $1 special local names 274adca7ddbSericR$+ $: $1 < @ $R > append relay 275adca7ddbSericR$+ < @ > $#local $: $1 if no relay, local 2766dafc3b0SericR$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay', 2774588ece0Seric`# handle locally delivered names 2784588ece0SericR$=L $#local $: @ $1 special local names 279adca7ddbSericR$+ $#local $: $1 regular local names 2806f4c5567Seric 2814cad3747Seric########################################################################### 2824cad3747Seric### Ruleset 5 -- special rewriting after aliases have been expanded ### 2834cad3747Seric### (new sendmail only) ### 2844cad3747Seric########################################################################### 2856f4c5567Seric 28663eeb308SericS5 28763eeb308Seric 2884cad3747Sericifdef(`_MAILER_smtp_', 2894cad3747Seric`R$+ $: $1 < @ $R > 2906cace491SericR$+ < @ $+ > $#smtp $@ $2 $: $1 < @ $2 > send to relay')') 2916f4c5567Seric# 2926f4c5567Seric###################################################################### 2936f4c5567Seric###################################################################### 2946f4c5567Seric##### 2951297e20cSeric`##### MAILER DEFINITIONS' 2966f4c5567Seric##### 2976f4c5567Seric###################################################################### 2986f4c5567Seric###################################################################### 2996f4c5567Sericundivert(7)dnl 300