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*51267SericVERSIONID(@(#)proto.m4 2.6 (Berkeley) 10/02/91) 1251222Seric 1351222Seric 1451222Seric################## 1551222Seric# local info # 1651222Seric################## 1751222Seric 1851222Sericifdef(`_USE_CW_FILE_', 1951222Seric`# file containing internet aliases in our primary domain 2051222SericFw/etc/sendmail.cw', `dnl') 2151222Seric 2251222Sericifdef(`UUCP_RELAY', 2351222Seric`# UUCP relay host 2451222SericCONCAT(DU, UUCP_RELAY) 2551222Seric')dnl 2651222Sericifdef(`BITNET_RELAY', 2751222Seric`# BITNET relay host 2851222SericCONCAT(DB, BITNET_RELAY) 2951222Seric')dnl 3051222Sericifdef(`CSNET_RELAY', 3151222Seric`# CSNET relay host 3251222SericCONCAT(DC, CSNET_RELAY) 3351222Seric')dnl 3451222Seric# my official hostname ($w or $w.$D) 3551222SericDj$w 3651222Seric 3751222Seric# who I masquerade as (can be $j) 3851222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 3951222Seric 4051222Seric# who I send unqualified names to (null means deliver locally) 4151222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 4251222Seric 4351222Sericifdef(`UUCP_NAME', 4451260Seric`# uucp hostnames 4551222SericUUCP_NAME 4651222SericUUCP_ALIASES 4751222Seric 4851222Seric# local UUCP connections 4951260Sericinclude(UUCP_HOSTS_FILE)', 5051244Seric`dnl') 5151222Seric 5251222Seric# operators that cannot be in local usernames (i.e., network indicators) 5351222SericCO @ % ! 5451222Seric 5551244Sericifdef(`USERDB_FILE', 5651244Seric`# location of user database file (null means no lookup) 5751260SericCONCAT(`OU', USERDB_FILE)', 5851260Seric`dnl') 5951222Seric 6051222Sericifdef(`_NO_WILDCARD_MX_', 6151222Seric`# we can guarantee no wildcard MX records matching our domain 6251260SericOw', 6351260Seric`dnl') 6451222Seric 6551222Sericinclude(`../m4/version.m4') 6651222Seric 6751260Sericifdef(`INTERNET_RELAY', 6851260Seric`include(../sitedep/nicregistered.m4)', 6951260Seric`dnl') 7051222Sericinclude(`../m4/boilerplate.m4') 7151222Seric# 7251222Seric###################################################################### 7351222Seric###################################################################### 7451222Seric##### 7551222Seric##### REWRITING RULES 7651222Seric##### 7751222Seric###################################################################### 7851222Seric###################################################################### 7951222Seric 8051222Seric 8151222Seric########################################### 8251222Seric### Rulset 3 -- Name Canonicalization ### 8351222Seric########################################### 8451260SericS3 8551222Seric 8651222Seric# handle "from:<>" special case 8751222SericR$*<>$* $@@ turn into magic token 8851222Seric 8951222Seric# basic textual canonicalization -- note RFC733 heuristic here 9051222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 9151222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 9251222SericR$*<$+>$* $2 basic RFC821/822 parsing 9351222Seric 9451222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 9551222SericR@$+,$+ @$1:$2 change all "," to ":" 9651222Seric 9751222Seric# localize and dispose of route-based addresses 9851222SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 9951222Seric 10051222Seric# find focus for list syntax 10151222SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 10251222SericR$+:$*; $@$1:$2; list syntax 10351222Seric 10451222Seric# find focus for @ syntax addresses 10551222SericR$+@$+ $:$1<@$2> focus on domain 10651222SericR$+<$+@$+> $1$2<@$3> move gaze right 10751222SericR$+<@$+> $@$>6$1<@$2> already canonical 10851222Seric 10951222Seric# convert old-style addresses to a domain-based address 11051222SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 11151222SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 11251222SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 11351222Seric 11451222Seric# if we have % signs, take the rightmost one 11551222SericR$*%$* $1@$2 First make them all @s. 11651222SericR$*@$*@$* $1%$2@$3 Undo all but the last. 11751222SericR$*@$* $@$>6$1<@$2> Insert < > and finish 11851222Seric 11951222Seric# else we must be a local name 12051222Seric 12151222Seric 12251222Seric############################################### 12351222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 12451222Seric############################################### 12551222Seric 12651222Seric# At this point, everything should be in a local_part@domain format. 12751222Seric 12851222SericS6 12951222Sericundivert(2)dnl 13051222Seric 13151222Seric# handle special cases for local names 132*51267SericR$* < @ $=w > $* $: $1 < @ $w > $3 no domain at all 133*51267SericR$* < @ $=w .UUCP> $* $: $1 < @ $w > $3 .UUCP domain 13451222Seric 135*51267Seric# if it's really UUCP, don't bother 136*51267SericR$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3 137*51267SericR$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3 138*51267SericR$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3 139*51267SericR$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3 140*51267SericR$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3 141*51267Seric 142*51267Seric# try UUCP traffic as a local address 143*51267SericR$* < @ $- .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 144*51267SericR$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4 145*51267Seric 14651222Seric# pass to name server to make hostname canonical 147*51267SericR$* < @ $+ > $* $: $1 < @ $[ $2 $] > $3 then do anything 14851222Seric 14951222Seric 15051222Seric################################################## 15151222Seric### Ruleset 4 -- Final Output Post-rewriting ### 15251222Seric################################################## 15351222SericS4 15451222Seric 15551222SericR@ $@ handle <> error addr 15651222Seric 15751222Seric# resolve numeric addresses to name if possible 15851222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr 15951222Seric 16051222Seric# externalize local domain info 16151222SericR$*<$+>$* $1$2$3 defocus 16251222SericR@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical 16351222Seric 16451222Seric# UUCP must always be presented in old form 16551222SericR$+@$-.UUCP $2!$1 u@h.UUCP => h!u 16651222Seric 16751222Seric# delete duplicate local names 16851222SericR$+%$=w@$=w $1@$w u%host@host => u@host 16951222Seric 17051222Seric 17151222Seric 17251222Seric############################################################# 17351222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 17451222Seric### (used for recursive calls) ### 17551222Seric############################################################# 17651222Seric 17751222SericS7 17851222SericR$* $: $>3 $1 17951222SericR$* $@ $>0 $1 18051222Seric 18151222Seric 18251222Seric###################################### 18351222Seric### Ruleset 0 -- Parse Address ### 18451222Seric###################################### 18551222Seric 18651222SericS0 18751222Seric 18851222Seric# handle numeric address spec 18951222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr 19051222SericR$*<@[$+]>$* $#smtp$@[$2]$:$1@[$2]$3 numeric internet spec 19151222Seric 19251222Seric#R@ $#error$:Invalid address handle <> form 19351222Seric 19451222Seric# now delete the local info -- note $=O to find characters that cause forwarding 19551222SericR<@$w>:$* $@$>7$1 @here:... -> ... 19651222SericR$*$=O$*<@$w> $@$>7$1$2$3 ...@here -> ... 19751222Seric 19851222Seric# short circuit local delivery so forwarded email works 19951222SericR$+<@$w> $#local$:$1 local address 20051222Seric 20151222Sericundivert(3)dnl 20251222Seric 20351260Sericundivert(4)dnl 20451260Seric 20551260Seric# resolve remotely connected UUCP links 20651260SericR$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3 20751260SericR$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3 20851260SericR$* < @ $=Y . UUCP > $* $#smtp $@ $Y $: $1<@$2.UUCP>$3 20951260Seric 21051222Seric# resolve fake top level domains by forwarding to other hosts 21151222Sericifdef(`BITNET_RELAY', 21251222Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 21351222Seric `dnl') 21451222Sericifdef(`CSNET_RELAY', 21551222Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 21651222Seric `dnl') 21751222Seric 21851260Sericifdef(`UUCP_RELAY', 21951260Seric`# forward non-local UUCP traffic to our UUCP relay 22051260SericR$*<@$*.UUCP>$* $#smtp$@$U$:$1<@$2.UUCP> uucp mail', 22151260Seric`ifdef(`_UUCP_LINKED_', 22251260Seric`# forward other UUCP traffic straight to UUCP 22351260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 22451260SericR$+ < @ $+ .UUCP> $#uucp $@ $2 $: $1 user@host.UUCP', 22551260Seric `dnl')') 22651222Seric 22751260Seric# deal with other remote names 22851222SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 22951222Seric 23051222Seric# see if we forward local names 23151222SericR$=L $# local $: $1 special local names 23251222SericR$+ $: $1 @ $R 23351222SericR$+ @ $: $1 no, we don't 23451222SericR$+ @ $+ $# smtp $@ $2 $: $1 yes, we do 23551222Seric 23651222Seric# remaining names must be local 23751222SericR$+ $#local$:$1 everything else 23851222Seric 23951222Seric# 24051222Seric###################################################################### 24151222Seric###################################################################### 24251222Seric##### 24351222Seric##### MAILER DEFINITIONS 24451222Seric##### 24551222Seric###################################################################### 24651222Seric###################################################################### 24751222Seric 24851222Sericundivert(7)dnl 249