xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 51222)
1*51222Sericdivert(-1)
2*51222Seric#
3*51222Seric# Copyright (c) 1983 Eric P. Allman
4*51222Seric# Copyright (c) 1988 The Regents of the University of California.
5*51222Seric# All rights reserved.
6*51222Seric#
7*51222Seric# %sccs.include.redist.sh%
8*51222Seric#
9*51222Sericdivert(0)
10*51222Seric
11*51222SericVERSIONID(@(#)proto.m4	2.1 (Berkeley) 10/02/91)
12*51222Seric
13*51222Seric
14*51222Seric
15*51222Seric##################
16*51222Seric#   local info   #
17*51222Seric##################
18*51222Seric
19*51222Sericifdef(`_USE_CW_FILE_',
20*51222Seric`# file containing internet aliases in our primary domain
21*51222SericFw/etc/sendmail.cw', `dnl')
22*51222Seric
23*51222Sericifdef(`UUCP_RELAY',
24*51222Seric`# UUCP relay host
25*51222SericCONCAT(DU, UUCP_RELAY)
26*51222Seric')dnl
27*51222Sericifdef(`BITNET_RELAY',
28*51222Seric`#  BITNET relay host
29*51222SericCONCAT(DB, BITNET_RELAY)
30*51222Seric')dnl
31*51222Sericifdef(`CSNET_RELAY',
32*51222Seric`# CSNET relay host
33*51222SericCONCAT(DC, CSNET_RELAY)
34*51222Seric')dnl
35*51222Seric# my official hostname ($w or $w.$D)
36*51222SericDj$w
37*51222Seric
38*51222Seric# who I masquerade as (can be $j)
39*51222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
40*51222Seric
41*51222Seric# who I send unqualified names to (null means deliver locally)
42*51222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
43*51222Seric
44*51222Seric
45*51222Sericifdef(`UUCP_NAME',
46*51222Seric# uucp hostnames
47*51222SericUUCP_NAME
48*51222SericUUCP_ALIASES
49*51222Seric
50*51222Seric# local UUCP connections
51*51222Seric`include(UUCP_HOSTS_FILE)')
52*51222Seric
53*51222Seric# operators that cannot be in local usernames (i.e., network indicators)
54*51222SericCO @ % !
55*51222Seric
56*51222Seric# location of user database file (null means no lookup)
57*51222Sericifdef(`USERDB_FILE', `CONCAT(`OU', USERDB_FILE)', `dnl')
58*51222Seric
59*51222Sericifdef(`_NO_WILDCARD_MX_',
60*51222Seric`# we can guarantee no wildcard MX records matching our domain
61*51222SericOw', `dnl')dnl
62*51222Seric
63*51222Sericinclude(`../m4/version.m4')
64*51222Seric
65*51222Seric#ifdef(`INTERNET_RELAY',
66*51222Seric#`include(../sitedep/nicregistered.m4)')
67*51222Sericinclude(`../m4/boilerplate.m4')
68*51222Seric
69*51222Seric#
70*51222Seric######################################################################
71*51222Seric######################################################################
72*51222Seric#####
73*51222Seric#####			REWRITING RULES
74*51222Seric#####
75*51222Seric######################################################################
76*51222Seric######################################################################
77*51222Seric
78*51222Seric
79*51222Seric###########################################
80*51222Seric###  Rulset 3 -- Name Canonicalization  ###
81*51222Seric###########################################
82*51222Seric`S3
83*51222Seric
84*51222Seric# handle "from:<>" special case
85*51222SericR$*<>$*			$@@				turn into magic token
86*51222Seric
87*51222Seric# basic textual canonicalization -- note RFC733 heuristic here
88*51222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
89*51222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
90*51222SericR$*<$+>$*		$2				basic RFC821/822 parsing
91*51222Seric
92*51222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
93*51222SericR@$+,$+			@$1:$2				change all "," to ":"
94*51222Seric
95*51222Seric# localize and dispose of route-based addresses
96*51222SericR@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
97*51222Seric
98*51222Seric# find focus for list syntax
99*51222SericR$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
100*51222SericR$+:$*;			$@$1:$2;			list syntax
101*51222Seric
102*51222Seric# find focus for @ syntax addresses
103*51222SericR$+@$+			$:$1<@$2>			focus on domain
104*51222SericR$+<$+@$+>		$1$2<@$3>			move gaze right
105*51222SericR$+<@$+>		$@$>6$1<@$2>			already canonical
106*51222Seric
107*51222Seric# convert old-style addresses to a domain-based address
108*51222SericR$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
109*51222SericR$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
110*51222SericR$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
111*51222Seric
112*51222Seric# if we have % signs, take the rightmost one
113*51222SericR$*%$*			$1@$2				First make them all @s.
114*51222SericR$*@$*@$*		$1%$2@$3			Undo all but the last.
115*51222SericR$*@$*			$@$>6$1<@$2>			Insert < > and finish
116*51222Seric
117*51222Seric# else we must be a local name
118*51222Seric
119*51222Seric
120*51222Seric###############################################
121*51222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
122*51222Seric###############################################
123*51222Seric
124*51222Seric#
125*51222Seric#  At this point, everything should be in a local_part@domain format.
126*51222Seric#  This ruleset is primarily responsible for
127*51222Seric
128*51222SericS6
129*51222Seric'
130*51222Sericundivert(2)dnl
131*51222Seric
132*51222Seric# handle special cases for local names
133*51222SericR$*<@$=w>$*		$:$1<@$w>$3			no domain at all
134*51222SericR$*<@$=w.UUCP>$*	$:$1<@$w>$3			.UUCP domain
135*51222SericR$*<@$=U.UUCP>$*	$:$1<@$w>$3			UUCP-specific names
136*51222Seric
137*51222Seric# pass to name server to make hostname canonical
138*51222SericR$* < @ $+ > $*		$: $1 < @ $[ $2 $] > $3		then do anything
139*51222Seric
140*51222Seric# hack to add local domain if nothing sofar has done so
141*51222SericR$* < @ $- > $*		$: $1 < @ $2 @ $w > $3		throw on local host
142*51222SericR$* < @ $- @ $- $* > $*	$: $1 < @ $2 $4 > $5		strip host part only
143*51222Seric
144*51222Seric
145*51222Seric##################################################
146*51222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
147*51222Seric##################################################
148*51222SericS4
149*51222Seric
150*51222SericR@			$@				handle <> error addr
151*51222Seric
152*51222Seric# resolve numeric addresses to name if possible
153*51222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		lookup numeric internet addr
154*51222Seric
155*51222Seric# externalize local domain info
156*51222SericR$*<$+>$*		$1$2$3				defocus
157*51222SericR@$+:@$+:$+		@$1,@$2:$3			<route-addr> canonical
158*51222Seric
159*51222Seric# UUCP must always be presented in old form
160*51222SericR$+@$-.UUCP		$2!$1				u@h.UUCP => h!u
161*51222Seric
162*51222Seric# delete duplicate local names
163*51222SericR$+%$=w@$=w		$1@$w				u%host@host => u@host
164*51222Seric#R$+%$=w@$=w.$D		$1@$w				u%host@host => u@host
165*51222Seric
166*51222Seric
167*51222Seric
168*51222Seric#############################################################
169*51222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
170*51222Seric###		   (used for recursive calls)		  ###
171*51222Seric#############################################################
172*51222Seric
173*51222SericS7
174*51222SericR$*			$: $>3 $1
175*51222SericR$*			$@ $>0 $1
176*51222Seric
177*51222Seric
178*51222Seric######################################
179*51222Seric###   Ruleset 0 -- Parse Address   ###
180*51222Seric######################################
181*51222Seric
182*51222SericS0
183*51222Seric
184*51222Seric# handle numeric address spec
185*51222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		numeric internet addr
186*51222SericR$*<@[$+]>$*		$#smtp$@[$2]$:$1@[$2]$3		numeric internet spec
187*51222Seric
188*51222Seric#R@			$#error$:Invalid address	handle <> form
189*51222Seric
190*51222Seric# now delete the local info -- note $=O to find characters that cause forwarding
191*51222SericR<@$w>:$*		$@$>7$1				@here:... -> ...
192*51222SericR$*$=O$*<@$w>		$@$>7$1$2$3			...@here -> ...
193*51222Seric
194*51222Seric# short circuit local delivery so forwarded email works
195*51222SericR$+<@$w>		$#local$:$1			local address
196*51222Seric
197*51222Sericundivert(3)dnl
198*51222Seric
199*51222Seric# resolve fake top level domains by forwarding to other hosts
200*51222Sericifdef(`BITNET_RELAY',
201*51222Seric`R$*<@$+.BITNET>$*	$#smtp$@$B$:$1<@$2.BITNET>$3		user@host.BITNET',
202*51222Seric	`dnl')
203*51222Sericifdef(`CSNET_RELAY',
204*51222Seric`R$*<@$+.CSNET>$*	$#smtp$@$C$:$1<@$2.CSNET>$3		user@host.CSNET',
205*51222Seric	`dnl')
206*51222Seric
207*51222Seric# forward non-local UUCP traffic to our UUCP relay
208*51222SericR$*<@$*.UUCP>$*		$#smtp$@$U$:$1<@$2.UUCP>		uucp mail
209*51222Seric
210*51222Seric# hide behind our internet relay when talking to people in the .ARPA domain
211*51222Seric#R$*<@$*.ARPA>$*	$#smtp-nic$@$2.ARPA$:$1<@$2.ARPA>$3	user@host.ARPA
212*51222Seric
213*51222Seric# but speak domains to them if they speak domains too
214*51222SericR$* < @ $* > $*		$# smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
215*51222Seric
216*51222Seric# see if we forward local names
217*51222SericR$=L			$# local $: $1			special local names
218*51222SericR$+			$: $1 @ $R
219*51222SericR$+ @			$: $1				no, we don't
220*51222SericR$+ @ $+		$# smtp $@ $2 $: $1		yes, we do
221*51222Seric
222*51222Seric# remaining names must be local
223*51222SericR$+			$#local$:$1			everything else
224*51222Seric
225*51222Seric#
226*51222Seric######################################################################
227*51222Seric######################################################################
228*51222Seric#####
229*51222Seric#####			MAILER DEFINITIONS
230*51222Seric#####
231*51222Seric######################################################################
232*51222Seric######################################################################
233*51222Seric
234*51222Sericundivert(7)dnl
235