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*57245SericVERSIONID(`@(#)proto.m4 2.34 (Berkeley) 12/20/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 49*57245Seric# class L: names that should be delivered locally, even if we have a relay 50*57245Seric# class E: names that should be exposed as from this host, even if we masquerade 5151279SericCLroot 52*57245SericCEroot 5351279Sericundivert(5)dnl 5451279Seric 5551222Seric# operators that cannot be in local usernames (i.e., network indicators) 5651222SericCO @ % ! 5751222Seric 5851322Seric# a class with just dot (for identifying canonical names) 5951322SericC.. 6051322Seric 6151887Seric# list of locations of user database file (null means no lookup) 6251887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC') 6351222Seric 6451887Seric# set if we can guarantee no wildcard MX records matching our domain 6552108SericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False') 6651222Seric 6751222Sericinclude(`../m4/version.m4') 6851222Sericinclude(`../m4/boilerplate.m4') 6956786Sericundivert(6)dnl 7051222Seric# 7151222Seric###################################################################### 7251222Seric###################################################################### 7351222Seric##### 7451222Seric##### REWRITING RULES 7551222Seric##### 7651222Seric###################################################################### 7751222Seric###################################################################### 7851222Seric 7951222Seric 8051222Seric########################################### 8151222Seric### Rulset 3 -- Name Canonicalization ### 8251222Seric########################################### 8351260SericS3 8451222Seric 8551222Seric# handle "from:<>" special case 8655416SericR$* < > $* $@ @ turn into magic token 8751222Seric 8851222Seric# basic textual canonicalization -- note RFC733 heuristic here 8957012SericR$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 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 9555416SericR@ $+ , $+ @ $1 : $2 change all "," to ":" 9651222Seric 9751222Seric# localize and dispose of route-based addresses 9855416SericR@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 9951222Seric 10051222Seric# find focus for list syntax 10155416SericR $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 10255416SericR $+ : $* ; $@ $1 : $2; list syntax 10351222Seric 10451222Seric# find focus for @ syntax addresses 10555416SericR$+ @ $+ $: $1 < @ $2 > focus on domain 10655416SericR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 10755416SericR$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 10851222Seric 10951222Seric# convert old-style addresses to a domain-based address 11055416SericR$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 11155416SericR$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 11255416SericR$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains 11351222Seric 11451222Seric# if we have % signs, take the rightmost one 11555416SericR$* % $* $1 @ $2 First make them all @s. 11655416SericR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 11755416SericR$* @ $* $@ $>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 126*57245Seric# At this point, everything should be in a "local_part<@domain>extra" format. 12751222SericS6 12851222Seric 12951222Seric# handle special cases for local names 13051322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 13155416SericR$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 13251889Sericundivert(2)dnl 13351222Seric 13451274Sericifdef(`UUCP_RELAY', 13551274Seric`# pass UUCP addresses straight through 13655416SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 13751274Seric`# if really UUCP, handle it immediately 13851322Sericifdef(`_CLASS_U_', 13955416Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 14051322Sericifdef(`_CLASS_V_', 14155416Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 14251322Sericifdef(`_CLASS_W_', 14355416Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 14451322Sericifdef(`_CLASS_X_', 14555416Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 14651322Sericifdef(`_CLASS_Y_', 14755416Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 14851267Seric 14951267Seric# try UUCP traffic as a local address 15055416SericR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 15151992Sericifdef(`_OLD_SENDMAIL_', 15255416Seric`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 15355416Seric`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 15451267Seric 15551222Seric# pass to name server to make hostname canonical 15651322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 15751222Seric 15851889Seric# handle possible alternate names 15951889SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 16051889SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 16151889Sericundivert(8)dnl 16251889Seric 16351322Seric# if this is the local hostname, make sure we treat is as canonical 16451322SericR$* < @ $j > $* $: $1 < @ $j . > $2 16551222Seric 16651322Seric 16751222Seric################################################## 16851222Seric### Ruleset 4 -- Final Output Post-rewriting ### 16951222Seric################################################## 17051222SericS4 17151222Seric 17251222SericR@ $@ handle <> error addr 17351222Seric 17451222Seric# resolve numeric addresses to name if possible 17551322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 17651222Seric 17751322Seric# strip trailing dot off possibly canonical name 17851322SericR$* < @ $+ . > $* $1 < @ $2 > $3 17951322Seric 18051222Seric# externalize local domain info 18151322SericR$* < $+ > $* $1 $2 $3 defocus 18251322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 18351997SericR@ $* $@ @ $1 ... and exit 18451222Seric 18551222Seric# UUCP must always be presented in old form 18651322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 18751222Seric 18851222Seric# delete duplicate local names 18951322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 19051222Seric 19151222Seric 19251222Seric 19351222Seric############################################################# 19451222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 19551222Seric### (used for recursive calls) ### 19651222Seric############################################################# 19751222Seric 19851222SericS7 19951222SericR$* $: $>3 $1 20051222SericR$* $@ $>0 $1 20151222Seric 20251222Seric 20351222Seric###################################### 20451222Seric### Ruleset 0 -- Parse Address ### 20551222Seric###################################### 20651222Seric 20751222SericS0 20851222Seric 20955416Sericifdef(`_MAILER_smtp_', 21055416Seric`# handle numeric address spec 21151322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 21255416SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 21356785Seric`dnl') 21451222Seric 21551887Seric# now delete the local info -- note $=O to find characters that cause forwarding 21651322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 21751322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 21851222Seric 21951222Seric# short circuit local delivery so forwarded email works 22051992Sericifdef(`_OLD_SENDMAIL_', 22151992Seric`R$+ < @ $j . > $#local $: $1 local address', 22251992Seric`R$+ < @ $j . > $#local $: @ $1 local address') 22351222Sericundivert(3)dnl 22451260Sericundivert(4)dnl 22551260Seric 22655416Seric# resolve remotely connected UUCP links (if any) 22751285Sericifdef(`_CLASS_V_', 22852044Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 22952044Seric `dnl') 23051285Sericifdef(`_CLASS_W_', 23152044Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 23252044Seric `dnl') 23351285Sericifdef(`_CLASS_X_', 23452044Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 23552044Seric `dnl') 23651260Seric 23751222Seric# resolve fake top level domains by forwarding to other hosts 23851222Sericifdef(`BITNET_RELAY', 23952044Seric`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 24051222Seric `dnl') 24151222Sericifdef(`CSNET_RELAY', 24252044Seric`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 24351222Seric `dnl') 24451222Seric 24551260Sericifdef(`UUCP_RELAY', 24651260Seric`# forward non-local UUCP traffic to our UUCP relay 24752044SericR$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 24855416Seric`ifdef(`_MAILER_uucp_', 24951260Seric`# forward other UUCP traffic straight to UUCP 25051260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 25151322SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 25251260Seric `dnl')') 25351222Seric 25455416Sericifdef(`_MAILER_smtp_', 25555416Seric`# deal with other remote names 25652041SericR$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 25755416Seric', `dnl') 25851222Seric 25951992Sericifdef(`_OLD_SENDMAIL_', 26051887Seric`# forward remaining names to local relay, if any 26152041SericR$=L $#local $: $1 special local names 26252041SericR$+ $: $1 < @ $R > append relay 26352041SericR$+ < @ > $#local $: $1 if no relay, local 26452044SericR$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay', 26551992Seric`# handle locally delivered names 26652041SericR$=L $#local $: @ $1 special local names 26752041SericR$+ $#local $: $1 regular local names 26851222Seric 26955416Seric########################################################################### 27055416Seric### Ruleset 5 -- special rewriting after aliases have been expanded ### 27155416Seric### (new sendmail only) ### 27255416Seric########################################################################### 27351222Seric 27451322SericS5 27551322Seric 27655416Sericifdef(`_MAILER_smtp_', 27755416Seric`R$+ $: $1 < @ $R > 27856768SericR$+ < @ $+ > $#smtp $@ $2 $: $1 < @ $2 > send to relay')') 27951222Seric# 28051222Seric###################################################################### 28151222Seric###################################################################### 28251222Seric##### 28356790Seric`##### MAILER DEFINITIONS' 28451222Seric##### 28551222Seric###################################################################### 28651222Seric###################################################################### 28751222Sericundivert(7)dnl 288