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*51244SericVERSIONID(@(#)proto.m4 2.3 (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', 4451222Seric# uucp hostnames 4551222SericUUCP_NAME 4651222SericUUCP_ALIASES 4751222Seric 4851222Seric# local UUCP connections 49*51244Seric`include(UUCP_HOSTS_FILE)', 50*51244Seric`dnl') 5151222Seric 5251222Seric# operators that cannot be in local usernames (i.e., network indicators) 5351222SericCO @ % ! 5451222Seric 55*51244Sericifdef(`USERDB_FILE', 56*51244Seric`# location of user database file (null means no lookup) 57*51244SericCONCAT(`OU', USERDB_FILE)', `dnl') 5851222Seric 5951222Sericifdef(`_NO_WILDCARD_MX_', 6051222Seric`# we can guarantee no wildcard MX records matching our domain 61*51244SericOw', `dnl') 6251222Seric 6351222Sericinclude(`../m4/version.m4') 6451222Seric 6551222Seric#ifdef(`INTERNET_RELAY', 6651222Seric#`include(../sitedep/nicregistered.m4)') 6751222Sericinclude(`../m4/boilerplate.m4') 6851222Seric 6951222Seric# 7051222Seric###################################################################### 7151222Seric###################################################################### 7251222Seric##### 7351222Seric##### REWRITING RULES 7451222Seric##### 7551222Seric###################################################################### 7651222Seric###################################################################### 7751222Seric 7851222Seric 7951222Seric########################################### 8051222Seric### Rulset 3 -- Name Canonicalization ### 8151222Seric########################################### 8251222Seric`S3 8351222Seric 8451222Seric# handle "from:<>" special case 8551222SericR$*<>$* $@@ turn into magic token 8651222Seric 8751222Seric# basic textual canonicalization -- note RFC733 heuristic here 8851222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 8951222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 9051222SericR$*<$+>$* $2 basic RFC821/822 parsing 9151222Seric 9251222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 9351222SericR@$+,$+ @$1:$2 change all "," to ":" 9451222Seric 9551222Seric# localize and dispose of route-based addresses 9651222SericR@$+:$+ $@$>6<@$1>:$2 handle <route-addr> 9751222Seric 9851222Seric# find focus for list syntax 9951222SericR$+:$*;@$+ $@$>6$1:$2;<@$3> list syntax 10051222SericR$+:$*; $@$1:$2; list syntax 10151222Seric 10251222Seric# find focus for @ syntax addresses 10351222SericR$+@$+ $:$1<@$2> focus on domain 10451222SericR$+<$+@$+> $1$2<@$3> move gaze right 10551222SericR$+<@$+> $@$>6$1<@$2> already canonical 10651222Seric 10751222Seric# convert old-style addresses to a domain-based address 10851222SericR$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names 10951222SericR$+.$-!$+ $@$>6$3<@$1.$2> domain uucps 11051222SericR$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains 11151222Seric 11251222Seric# if we have % signs, take the rightmost one 11351222SericR$*%$* $1@$2 First make them all @s. 11451222SericR$*@$*@$* $1%$2@$3 Undo all but the last. 11551222SericR$*@$* $@$>6$1<@$2> Insert < > and finish 11651222Seric 11751222Seric# else we must be a local name 11851222Seric 11951222Seric 12051222Seric############################################### 12151222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 12251222Seric############################################### 12351222Seric 12451222Seric# 12551222Seric# At this point, everything should be in a local_part@domain format. 12651222Seric# This ruleset is primarily responsible for 12751222Seric 12851222SericS6 12951222Seric' 13051222Sericundivert(2)dnl 13151222Seric 13251222Seric# handle special cases for local names 13351222SericR$*<@$=w>$* $:$1<@$w>$3 no domain at all 13451222SericR$*<@$=w.UUCP>$* $:$1<@$w>$3 .UUCP domain 13551222SericR$*<@$=U.UUCP>$* $:$1<@$w>$3 UUCP-specific names 13651222Seric 13751222Seric# pass to name server to make hostname canonical 13851222SericR$* < @ $+ > $* $: $1 < @ $[ $2 $] > $3 then do anything 13951222Seric 14051222Seric# hack to add local domain if nothing sofar has done so 14151222SericR$* < @ $- > $* $: $1 < @ $2 @ $w > $3 throw on local host 14251222SericR$* < @ $- @ $- $* > $* $: $1 < @ $2 $4 > $5 strip host part only 14351222Seric 14451222Seric 14551222Seric################################################## 14651222Seric### Ruleset 4 -- Final Output Post-rewriting ### 14751222Seric################################################## 14851222SericS4 14951222Seric 15051222SericR@ $@ handle <> error addr 15151222Seric 15251222Seric# resolve numeric addresses to name if possible 15351222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr 15451222Seric 15551222Seric# externalize local domain info 15651222SericR$*<$+>$* $1$2$3 defocus 15751222SericR@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical 15851222Seric 15951222Seric# UUCP must always be presented in old form 16051222SericR$+@$-.UUCP $2!$1 u@h.UUCP => h!u 16151222Seric 16251222Seric# delete duplicate local names 16351222SericR$+%$=w@$=w $1@$w u%host@host => u@host 16451222Seric#R$+%$=w@$=w.$D $1@$w u%host@host => u@host 16551222Seric 16651222Seric 16751222Seric 16851222Seric############################################################# 16951222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 17051222Seric### (used for recursive calls) ### 17151222Seric############################################################# 17251222Seric 17351222SericS7 17451222SericR$* $: $>3 $1 17551222SericR$* $@ $>0 $1 17651222Seric 17751222Seric 17851222Seric###################################### 17951222Seric### Ruleset 0 -- Parse Address ### 18051222Seric###################################### 18151222Seric 18251222SericS0 18351222Seric 18451222Seric# handle numeric address spec 18551222SericR$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr 18651222SericR$*<@[$+]>$* $#smtp$@[$2]$:$1@[$2]$3 numeric internet spec 18751222Seric 18851222Seric#R@ $#error$:Invalid address handle <> form 18951222Seric 19051222Seric# now delete the local info -- note $=O to find characters that cause forwarding 19151222SericR<@$w>:$* $@$>7$1 @here:... -> ... 19251222SericR$*$=O$*<@$w> $@$>7$1$2$3 ...@here -> ... 19351222Seric 19451222Seric# short circuit local delivery so forwarded email works 19551222SericR$+<@$w> $#local$:$1 local address 19651222Seric 19751222Sericundivert(3)dnl 19851222Seric 19951222Seric# resolve fake top level domains by forwarding to other hosts 20051222Sericifdef(`BITNET_RELAY', 20151222Seric`R$*<@$+.BITNET>$* $#smtp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET', 20251222Seric `dnl') 20351222Sericifdef(`CSNET_RELAY', 20451222Seric`R$*<@$+.CSNET>$* $#smtp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET', 20551222Seric `dnl') 20651222Seric 20751222Seric# forward non-local UUCP traffic to our UUCP relay 20851222SericR$*<@$*.UUCP>$* $#smtp$@$U$:$1<@$2.UUCP> uucp mail 20951222Seric 21051222Seric# hide behind our internet relay when talking to people in the .ARPA domain 21151222Seric#R$*<@$*.ARPA>$* $#smtp-nic$@$2.ARPA$:$1<@$2.ARPA>$3 user@host.ARPA 21251222Seric 21351222Seric# but speak domains to them if they speak domains too 21451222SericR$* < @ $* > $* $# smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 21551222Seric 21651222Seric# see if we forward local names 21751222SericR$=L $# local $: $1 special local names 21851222SericR$+ $: $1 @ $R 21951222SericR$+ @ $: $1 no, we don't 22051222SericR$+ @ $+ $# smtp $@ $2 $: $1 yes, we do 22151222Seric 22251222Seric# remaining names must be local 22351222SericR$+ $#local$:$1 everything else 22451222Seric 22551222Seric# 22651222Seric###################################################################### 22751222Seric###################################################################### 22851222Seric##### 22951222Seric##### MAILER DEFINITIONS 23051222Seric##### 23151222Seric###################################################################### 23251222Seric###################################################################### 23351222Seric 23451222Sericundivert(7)dnl 235