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*57012SericVERSIONID(`@(#)proto.m4 2.33 (Berkeley) 12/07/92') 1251222Seric 1351322SericMAILER(local)dnl 1451222Seric 1552646Sericifdef(`_OLD_SENDMAIL_', `dnl', 1652646Seric`# level 3 config file format 1752646SericV3') 1852646Seric 1951222Seric################## 2051222Seric# local info # 2151222Seric################## 2251222Seric 2351889SericCwlocalhost 2451887Sericifdef(`USE_CW_FILE', 2551889Seric`# file containing names of hosts for which we receive email 2651222SericFw/etc/sendmail.cw', `dnl') 2751222Seric 2851222Sericifdef(`UUCP_RELAY', 2951222Seric`# UUCP relay host 3051281SericCONCAT(DY, UUCP_RELAY) 3151222Seric')dnl 3251222Sericifdef(`BITNET_RELAY', 3351222Seric`# BITNET relay host 3451222SericCONCAT(DB, BITNET_RELAY) 3551222Seric')dnl 3651222Sericifdef(`CSNET_RELAY', 3751222Seric`# CSNET relay host 3851222SericCONCAT(DC, CSNET_RELAY) 3951222Seric')dnl 4051222Seric# my official hostname ($w or $w.$D) 4151291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 4251222Seric 4351222Seric# who I masquerade as (can be $j) 4451222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 4551222Seric 4651222Seric# who I send unqualified names to (null means deliver locally) 4751222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 4851222Seric 4951279Seric# names that should be delivered locally, even if we have a relay 5051279SericCLroot 5151279Sericundivert(5)dnl 5251279Seric 5351222Sericifdef(`UUCP_NAME', 5451260Seric`# uucp hostnames 5551222SericUUCP_NAME 5651222SericUUCP_ALIASES 5751222Seric 5851222Seric# local UUCP connections 5951260Sericinclude(UUCP_HOSTS_FILE)', 6051244Seric`dnl') 6151222Seric 6251222Seric# operators that cannot be in local usernames (i.e., network indicators) 6351222SericCO @ % ! 6451222Seric 6551322Seric# a class with just dot (for identifying canonical names) 6651322SericC.. 6751322Seric 6851887Seric# list of locations of user database file (null means no lookup) 6951887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC') 7051222Seric 7151887Seric# set if we can guarantee no wildcard MX records matching our domain 7252108SericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False') 7351222Seric 7451222Sericinclude(`../m4/version.m4') 7551222Seric 7651260Sericifdef(`INTERNET_RELAY', 7751260Seric`include(../sitedep/nicregistered.m4)', 7851260Seric`dnl') 7951222Sericinclude(`../m4/boilerplate.m4') 8056786Sericundivert(6)dnl 8151222Seric# 8251222Seric###################################################################### 8351222Seric###################################################################### 8451222Seric##### 8551222Seric##### REWRITING RULES 8651222Seric##### 8751222Seric###################################################################### 8851222Seric###################################################################### 8951222Seric 9051222Seric 9151222Seric########################################### 9251222Seric### Rulset 3 -- Name Canonicalization ### 9351222Seric########################################### 9451260SericS3 9551222Seric 9651222Seric# handle "from:<>" special case 9755416SericR$* < > $* $@ @ turn into magic token 9851222Seric 9951222Seric# basic textual canonicalization -- note RFC733 heuristic here 100*57012SericR$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 10151222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 10251222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 10351222SericR$*<$+>$* $2 basic RFC821/822 parsing 10451222Seric 10551222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 10655416SericR@ $+ , $+ @ $1 : $2 change all "," to ":" 10751222Seric 10851222Seric# localize and dispose of route-based addresses 10955416SericR@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 11051222Seric 11151222Seric# find focus for list syntax 11255416SericR $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 11355416SericR $+ : $* ; $@ $1 : $2; list syntax 11451222Seric 11551222Seric# find focus for @ syntax addresses 11655416SericR$+ @ $+ $: $1 < @ $2 > focus on domain 11755416SericR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 11855416SericR$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 11951222Seric 12051222Seric# convert old-style addresses to a domain-based address 12155416SericR$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 12255416SericR$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 12355416SericR$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains 12451222Seric 12551222Seric# if we have % signs, take the rightmost one 12655416SericR$* % $* $1 @ $2 First make them all @s. 12755416SericR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 12855416SericR$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 12951222Seric 13051222Seric# else we must be a local name 13151222Seric 13251222Seric 13351222Seric############################################### 13451222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 13551222Seric############################################### 13651222Seric 13751222Seric# At this point, everything should be in a local_part@domain format. 13851222Seric 13951222SericS6 14051222Seric 14151222Seric# handle special cases for local names 14251322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 14355416SericR$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 14451889Sericundivert(2)dnl 14551222Seric 14651274Sericifdef(`UUCP_RELAY', 14751274Seric`# pass UUCP addresses straight through 14855416SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 14951274Seric`# if really UUCP, handle it immediately 15051322Sericifdef(`_CLASS_U_', 15155416Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15251322Sericifdef(`_CLASS_V_', 15355416Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15451322Sericifdef(`_CLASS_W_', 15555416Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15651322Sericifdef(`_CLASS_X_', 15755416Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15851322Sericifdef(`_CLASS_Y_', 15955416Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 16051267Seric 16151267Seric# try UUCP traffic as a local address 16255416SericR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 16351992Sericifdef(`_OLD_SENDMAIL_', 16455416Seric`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 16555416Seric`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 16651267Seric 16751222Seric# pass to name server to make hostname canonical 16851322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 16951222Seric 17051889Seric# handle possible alternate names 17151889SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 17251889SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 17351889Sericundivert(8)dnl 17451889Seric 17551322Seric# if this is the local hostname, make sure we treat is as canonical 17651322SericR$* < @ $j > $* $: $1 < @ $j . > $2 17751222Seric 17851322Seric 17951222Seric################################################## 18051222Seric### Ruleset 4 -- Final Output Post-rewriting ### 18151222Seric################################################## 18251222SericS4 18351222Seric 18451222SericR@ $@ handle <> error addr 18551222Seric 18651222Seric# resolve numeric addresses to name if possible 18751322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 18851222Seric 18951322Seric# strip trailing dot off possibly canonical name 19051322SericR$* < @ $+ . > $* $1 < @ $2 > $3 19151322Seric 19251222Seric# externalize local domain info 19351322SericR$* < $+ > $* $1 $2 $3 defocus 19451322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 19551997SericR@ $* $@ @ $1 ... and exit 19651222Seric 19751222Seric# UUCP must always be presented in old form 19851322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 19951222Seric 20051222Seric# delete duplicate local names 20151322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 20251222Seric 20351222Seric 20451222Seric 20551222Seric############################################################# 20651222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 20751222Seric### (used for recursive calls) ### 20851222Seric############################################################# 20951222Seric 21051222SericS7 21151222SericR$* $: $>3 $1 21251222SericR$* $@ $>0 $1 21351222Seric 21451222Seric 21551222Seric###################################### 21651222Seric### Ruleset 0 -- Parse Address ### 21751222Seric###################################### 21851222Seric 21951222SericS0 22051222Seric 22155416Sericifdef(`_MAILER_smtp_', 22255416Seric`# handle numeric address spec 22351322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 22455416SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 22556785Seric`dnl') 22651222Seric 22751887Seric# now delete the local info -- note $=O to find characters that cause forwarding 22851322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 22951322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 23051222Seric 23151222Seric# short circuit local delivery so forwarded email works 23251992Sericifdef(`_OLD_SENDMAIL_', 23351992Seric`R$+ < @ $j . > $#local $: $1 local address', 23451992Seric`R$+ < @ $j . > $#local $: @ $1 local address') 23551222Sericundivert(3)dnl 23651260Sericundivert(4)dnl 23751260Seric 23855416Seric# resolve remotely connected UUCP links (if any) 23951285Sericifdef(`_CLASS_V_', 24052044Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 24152044Seric `dnl') 24251285Sericifdef(`_CLASS_W_', 24352044Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 24452044Seric `dnl') 24551285Sericifdef(`_CLASS_X_', 24652044Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 24752044Seric `dnl') 24851260Seric 24951222Seric# resolve fake top level domains by forwarding to other hosts 25051222Sericifdef(`BITNET_RELAY', 25152044Seric`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 25251222Seric `dnl') 25351222Sericifdef(`CSNET_RELAY', 25452044Seric`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 25551222Seric `dnl') 25651222Seric 25751260Sericifdef(`UUCP_RELAY', 25851260Seric`# forward non-local UUCP traffic to our UUCP relay 25952044SericR$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 26055416Seric`ifdef(`_MAILER_uucp_', 26151260Seric`# forward other UUCP traffic straight to UUCP 26251260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 26351322SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 26451260Seric `dnl')') 26551222Seric 26655416Sericifdef(`_MAILER_smtp_', 26755416Seric`# deal with other remote names 26852041SericR$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 26955416Seric', `dnl') 27051222Seric 27151992Sericifdef(`_OLD_SENDMAIL_', 27251887Seric`# forward remaining names to local relay, if any 27352041SericR$=L $#local $: $1 special local names 27452041SericR$+ $: $1 < @ $R > append relay 27552041SericR$+ < @ > $#local $: $1 if no relay, local 27652044SericR$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay', 27751992Seric`# handle locally delivered names 27852041SericR$=L $#local $: @ $1 special local names 27952041SericR$+ $#local $: $1 regular local names 28051222Seric 28155416Seric########################################################################### 28255416Seric### Ruleset 5 -- special rewriting after aliases have been expanded ### 28355416Seric### (new sendmail only) ### 28455416Seric########################################################################### 28551222Seric 28651322SericS5 28751322Seric 28855416Sericifdef(`_MAILER_smtp_', 28955416Seric`R$+ $: $1 < @ $R > 29056768SericR$+ < @ $+ > $#smtp $@ $2 $: $1 < @ $2 > send to relay')') 29151222Seric# 29251222Seric###################################################################### 29351222Seric###################################################################### 29451222Seric##### 29556790Seric`##### MAILER DEFINITIONS' 29651222Seric##### 29751222Seric###################################################################### 29851222Seric###################################################################### 29951222Sericundivert(7)dnl 300