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*51274SericVERSIONID(@(#)proto.m4 2.7 (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 13251267SericR$* < @ $=w > $* $: $1 < @ $w > $3 no domain at all 13351267SericR$* < @ $=w .UUCP> $* $: $1 < @ $w > $3 .UUCP domain 13451222Seric 135*51274Sericifdef(`UUCP_RELAY', 136*51274Seric`# pass UUCP addresses straight through 137*51274SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 .UUCP > $3', 138*51274Seric`# if really UUCP, handle it immediately 13951267SericR$* < @ $=U . UUCP > $* $@ $1 < @ $2 .UUCP > $3 14051267SericR$* < @ $=V . UUCP > $* $@ $1 < @ $2 .UUCP > $3 14151267SericR$* < @ $=W . UUCP > $* $@ $1 < @ $2 .UUCP > $3 14251267SericR$* < @ $=X . UUCP > $* $@ $1 < @ $2 .UUCP > $3 14351267SericR$* < @ $=Y . UUCP > $* $@ $1 < @ $2 .UUCP > $3 14451267Seric 14551267Seric# try UUCP traffic as a local address 14651267SericR$* < @ $- .UUCP > $* $: $1 < @ $[ $2 $] .UUCP > $3 147*51274SericR$* < @ $+ . $+ .UUCP > $* $@ $1 < @ $2 . $3 > $4') 14851267Seric 14951222Seric# pass to name server to make hostname canonical 15051267SericR$* < @ $+ > $* $: $1 < @ $[ $2 $] > $3 then do anything 15151222Seric 15251222Seric 15351222Seric################################################## 15451222Seric### Ruleset 4 -- Final Output Post-rewriting ### 15551222Seric################################################## 15651222SericS4 15751222Seric 15851222SericR@ $@ handle <> error addr 15951222Seric 16051222Seric# resolve numeric addresses to name if possible 16151222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr 16251222Seric 16351222Seric# externalize local domain info 16451222SericR$*<$+>$* $1$2$3 defocus 16551222SericR@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical 16651222Seric 16751222Seric# UUCP must always be presented in old form 16851222SericR$+@$-.UUCP $2!$1 u@h.UUCP => h!u 16951222Seric 17051222Seric# delete duplicate local names 17151222SericR$+%$=w@$=w $1@$w u%host@host => u@host 17251222Seric 17351222Seric 17451222Seric 17551222Seric############################################################# 17651222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 17751222Seric### (used for recursive calls) ### 17851222Seric############################################################# 17951222Seric 18051222SericS7 18151222SericR$* $: $>3 $1 18251222SericR$* $@ $>0 $1 18351222Seric 18451222Seric 18551222Seric###################################### 18651222Seric### Ruleset 0 -- Parse Address ### 18751222Seric###################################### 18851222Seric 18951222SericS0 19051222Seric 19151222Seric# handle numeric address spec 19251222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr 19351222SericR$*<@[$+]>$* $#smtp$@[$2]$:$1@[$2]$3 numeric internet spec 19451222Seric 19551222Seric#R@ $#error$:Invalid address handle <> form 19651222Seric 19751222Seric# now delete the local info -- note $=O to find characters that cause forwarding 19851222SericR<@$w>:$* $@$>7$1 @here:... -> ... 19951222SericR$*$=O$*<@$w> $@$>7$1$2$3 ...@here -> ... 20051222Seric 20151222Seric# short circuit local delivery so forwarded email works 20251222SericR$+<@$w> $#local$:$1 local address 20351222Seric 20451222Sericundivert(3)dnl 20551222Seric 20651260Sericundivert(4)dnl 20751260Seric 20851260Seric# resolve remotely connected UUCP links 20951260SericR$* < @ $=W . UUCP > $* $#smtp $@ $W $: $1<@$2.UUCP>$3 21051260SericR$* < @ $=X . UUCP > $* $#smtp $@ $X $: $1<@$2.UUCP>$3 21151260SericR$* < @ $=Y . UUCP > $* $#smtp $@ $Y $: $1<@$2.UUCP>$3 21251260Seric 21351222Seric# resolve fake top level domains by forwarding to other hosts 21451222Sericifdef(`BITNET_RELAY', 21551222Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 21651222Seric `dnl') 21751222Sericifdef(`CSNET_RELAY', 21851222Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 21951222Seric `dnl') 22051222Seric 22151260Sericifdef(`UUCP_RELAY', 22251260Seric`# forward non-local UUCP traffic to our UUCP relay 22351260SericR$*<@$*.UUCP>$* $#smtp$@$U$:$1<@$2.UUCP> uucp mail', 22451260Seric`ifdef(`_UUCP_LINKED_', 22551260Seric`# forward other UUCP traffic straight to UUCP 22651260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 22751260SericR$+ < @ $+ .UUCP> $#uucp $@ $2 $: $1 user@host.UUCP', 22851260Seric `dnl')') 22951222Seric 23051260Seric# deal with other remote names 23151222SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 23251222Seric 23351222Seric# see if we forward local names 23451222SericR$=L $# local $: $1 special local names 23551222SericR$+ $: $1 @ $R 23651222SericR$+ @ $: $1 no, we don't 23751222SericR$+ @ $+ $# smtp $@ $2 $: $1 yes, we do 23851222Seric 23951222Seric# remaining names must be local 24051222SericR$+ $#local$:$1 everything else 24151222Seric 24251222Seric# 24351222Seric###################################################################### 24451222Seric###################################################################### 24551222Seric##### 24651222Seric##### MAILER DEFINITIONS 24751222Seric##### 24851222Seric###################################################################### 24951222Seric###################################################################### 25051222Seric 25151222Sericundivert(7)dnl 252