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*56786SericVERSIONID(`@(#)proto.m4 2.31 (Berkeley) 11/14/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') 80*56786Sericundivert(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 10051222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 10151222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 10251222SericR$*<$+>$* $2 basic RFC821/822 parsing 10351222Seric 10451222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 10555416SericR@ $+ , $+ @ $1 : $2 change all "," to ":" 10651222Seric 10751222Seric# localize and dispose of route-based addresses 10855416SericR@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 10951222Seric 11051222Seric# find focus for list syntax 11155416SericR $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 11255416SericR $+ : $* ; $@ $1 : $2; list syntax 11351222Seric 11451222Seric# find focus for @ syntax addresses 11555416SericR$+ @ $+ $: $1 < @ $2 > focus on domain 11655416SericR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 11755416SericR$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 11851222Seric 11951222Seric# convert old-style addresses to a domain-based address 12055416SericR$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 12155416SericR$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 12255416SericR$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains 12351222Seric 12451222Seric# if we have % signs, take the rightmost one 12555416SericR$* % $* $1 @ $2 First make them all @s. 12655416SericR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 12755416SericR$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 12851222Seric 12951222Seric# else we must be a local name 13051222Seric 13151222Seric 13251222Seric############################################### 13351222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 13451222Seric############################################### 13551222Seric 13651222Seric# At this point, everything should be in a local_part@domain format. 13751222Seric 13851222SericS6 13951222Seric 14051222Seric# handle special cases for local names 14151322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 14255416SericR$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 14351889Sericundivert(2)dnl 14451222Seric 14551274Sericifdef(`UUCP_RELAY', 14651274Seric`# pass UUCP addresses straight through 14755416SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 14851274Seric`# if really UUCP, handle it immediately 14951322Sericifdef(`_CLASS_U_', 15055416Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15151322Sericifdef(`_CLASS_V_', 15255416Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15351322Sericifdef(`_CLASS_W_', 15455416Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15551322Sericifdef(`_CLASS_X_', 15655416Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15751322Sericifdef(`_CLASS_Y_', 15855416Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 15951267Seric 16051267Seric# try UUCP traffic as a local address 16155416SericR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 16251992Sericifdef(`_OLD_SENDMAIL_', 16355416Seric`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 16455416Seric`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 16551267Seric 16651222Seric# pass to name server to make hostname canonical 16751322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 16851222Seric 16951889Seric# handle possible alternate names 17051889SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 17151889SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 17251889Sericundivert(8)dnl 17351889Seric 17451322Seric# if this is the local hostname, make sure we treat is as canonical 17551322SericR$* < @ $j > $* $: $1 < @ $j . > $2 17651222Seric 17751322Seric 17851222Seric################################################## 17951222Seric### Ruleset 4 -- Final Output Post-rewriting ### 18051222Seric################################################## 18151222SericS4 18251222Seric 18351222SericR@ $@ handle <> error addr 18451222Seric 18551222Seric# resolve numeric addresses to name if possible 18651322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 18751222Seric 18851322Seric# strip trailing dot off possibly canonical name 18951322SericR$* < @ $+ . > $* $1 < @ $2 > $3 19051322Seric 19151222Seric# externalize local domain info 19251322SericR$* < $+ > $* $1 $2 $3 defocus 19351322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 19451997SericR@ $* $@ @ $1 ... and exit 19551222Seric 19651222Seric# UUCP must always be presented in old form 19751322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 19851222Seric 19951222Seric# delete duplicate local names 20051322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 20151222Seric 20251222Seric 20351222Seric 20451222Seric############################################################# 20551222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 20651222Seric### (used for recursive calls) ### 20751222Seric############################################################# 20851222Seric 20951222SericS7 21051222SericR$* $: $>3 $1 21151222SericR$* $@ $>0 $1 21251222Seric 21351222Seric 21451222Seric###################################### 21551222Seric### Ruleset 0 -- Parse Address ### 21651222Seric###################################### 21751222Seric 21851222SericS0 21951222Seric 22055416Sericifdef(`_MAILER_smtp_', 22155416Seric`# handle numeric address spec 22251322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 22355416SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 22456785Seric`dnl') 22551222Seric 22651887Seric# now delete the local info -- note $=O to find characters that cause forwarding 22751322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 22851322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 22951222Seric 23051222Seric# short circuit local delivery so forwarded email works 23151992Sericifdef(`_OLD_SENDMAIL_', 23251992Seric`R$+ < @ $j . > $#local $: $1 local address', 23351992Seric`R$+ < @ $j . > $#local $: @ $1 local address') 23451222Sericundivert(3)dnl 23551260Sericundivert(4)dnl 23651260Seric 23755416Seric# resolve remotely connected UUCP links (if any) 23851285Sericifdef(`_CLASS_V_', 23952044Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 24052044Seric `dnl') 24151285Sericifdef(`_CLASS_W_', 24252044Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 24352044Seric `dnl') 24451285Sericifdef(`_CLASS_X_', 24552044Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 24652044Seric `dnl') 24751260Seric 24851222Seric# resolve fake top level domains by forwarding to other hosts 24951222Sericifdef(`BITNET_RELAY', 25052044Seric`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 25151222Seric `dnl') 25251222Sericifdef(`CSNET_RELAY', 25352044Seric`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 25451222Seric `dnl') 25551222Seric 25651260Sericifdef(`UUCP_RELAY', 25751260Seric`# forward non-local UUCP traffic to our UUCP relay 25852044SericR$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 25955416Seric`ifdef(`_MAILER_uucp_', 26051260Seric`# forward other UUCP traffic straight to UUCP 26151260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 26251322SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 26351260Seric `dnl')') 26451222Seric 26555416Sericifdef(`_MAILER_smtp_', 26655416Seric`# deal with other remote names 26752041SericR$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 26855416Seric', `dnl') 26951222Seric 27051992Sericifdef(`_OLD_SENDMAIL_', 27151887Seric`# forward remaining names to local relay, if any 27252041SericR$=L $#local $: $1 special local names 27352041SericR$+ $: $1 < @ $R > append relay 27452041SericR$+ < @ > $#local $: $1 if no relay, local 27552044SericR$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay', 27651992Seric`# handle locally delivered names 27752041SericR$=L $#local $: @ $1 special local names 27852041SericR$+ $#local $: $1 regular local names 27951222Seric 28055416Seric########################################################################### 28155416Seric### Ruleset 5 -- special rewriting after aliases have been expanded ### 28255416Seric### (new sendmail only) ### 28355416Seric########################################################################### 28451222Seric 28551322SericS5 28651322Seric 28755416Sericifdef(`_MAILER_smtp_', 28855416Seric`R$+ $: $1 < @ $R > 28956768SericR$+ < @ $+ > $#smtp $@ $2 $: $1 < @ $2 > send to relay')') 29051222Seric# 29151222Seric###################################################################### 29251222Seric###################################################################### 29351222Seric##### 29456768Seric##### `MAILER DEFINITIONS' 29551222Seric##### 29651222Seric###################################################################### 29751222Seric###################################################################### 29851222Sericundivert(7)dnl 299