xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision 13ec26c3)
1divert(-1)
2#
3# Copyright (c) 1983 Eric P. Allman
4# Copyright (c) 1988 The Regents of the University of California.
5# All rights reserved.
6#
7# %sccs.include.redist.sh%
8#
9divert(0)
10
11VERSIONID(@(#)proto.m4	2.25 (Berkeley) 03/09/92)
12
13MAILER(local)dnl
14
15ifdef(`_OLD_SENDMAIL_', `dnl',
16`# level 3 config file format
17V3')
18
19##################
20#   local info   #
21##################
22
23Cwlocalhost
24ifdef(`USE_CW_FILE',
25`# file containing names of hosts for which we receive email
26Fw/etc/sendmail.cw', `dnl')
27
28ifdef(`UUCP_RELAY',
29`# UUCP relay host
30CONCAT(DY, UUCP_RELAY)
31')dnl
32ifdef(`BITNET_RELAY',
33`#  BITNET relay host
34CONCAT(DB, BITNET_RELAY)
35')dnl
36ifdef(`CSNET_RELAY',
37`# CSNET relay host
38CONCAT(DC, CSNET_RELAY)
39')dnl
40# my official hostname ($w or $w.$D)
41CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
42
43# who I masquerade as (can be $j)
44CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
45
46# who I send unqualified names to (null means deliver locally)
47CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
48
49# names that should be delivered locally, even if we have a relay
50CLroot
51undivert(5)dnl
52undivert(6)dnl
53
54ifdef(`UUCP_NAME',
55`# uucp hostnames
56UUCP_NAME
57UUCP_ALIASES
58
59# local UUCP connections
60include(UUCP_HOSTS_FILE)',
61`dnl')
62
63# operators that cannot be in local usernames (i.e., network indicators)
64CO @ % !
65
66# a class with just dot (for identifying canonical names)
67C..
68
69# list of locations of user database file (null means no lookup)
70OU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
71
72# set if we can guarantee no wildcard MX records matching our domain
73Ow`'ifdef(`_NO_WILDCARD_MX_', `True', `False')
74
75include(`../m4/version.m4')
76
77ifdef(`INTERNET_RELAY',
78`include(../sitedep/nicregistered.m4)',
79`dnl')
80include(`../m4/boilerplate.m4')
81#
82######################################################################
83######################################################################
84#####
85#####			REWRITING RULES
86#####
87######################################################################
88######################################################################
89
90
91###########################################
92###  Rulset 3 -- Name Canonicalization  ###
93###########################################
94S3
95
96# handle "from:<>" special case
97R$*<>$*			$@@				turn into magic token
98
99# basic textual canonicalization -- note RFC733 heuristic here
100R$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
101R$*<$*<$+>$*>$*		$3				2-level <> nesting
102R$*<$+>$*		$2				basic RFC821/822 parsing
103
104# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
105R@$+,$+			@$1:$2				change all "," to ":"
106
107# localize and dispose of route-based addresses
108R@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
109
110# find focus for list syntax
111R$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
112R$+:$*;			$@$1:$2;			list syntax
113
114# find focus for @ syntax addresses
115R$+@$+			$:$1<@$2>			focus on domain
116R$+<$+@$+>		$1$2<@$3>			move gaze right
117R$+<@$+>		$@$>6$1<@$2>			already canonical
118
119# convert old-style addresses to a domain-based address
120R$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
121R$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
122R$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
123
124# if we have % signs, take the rightmost one
125R$*%$*			$1@$2				First make them all @s.
126R$*@$*@$*		$1%$2@$3			Undo all but the last.
127R$*@$*			$@$>6$1<@$2>			Insert < > and finish
128
129# else we must be a local name
130
131
132###############################################
133###  Ruleset 6 -- bottom half of ruleset 3  ###
134###############################################
135
136#  At this point, everything should be in a local_part@domain format.
137
138S6
139
140# handle special cases for local names
141R$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
142R$* < @ $=w .UUCP> $*		$: $1 < @ $j . > $3		.UUCP domain
143undivert(2)dnl
144
145ifdef(`UUCP_RELAY',
146`# pass UUCP addresses straight through
147R$* < @ $+ . UUCP > $*		$@ $1 < @ $2 .UUCP > $3',
148`# if really UUCP, handle it immediately
149ifdef(`_CLASS_U_',
150`R$* < @ $=U . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
151ifdef(`_CLASS_V_',
152`R$* < @ $=V . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
153ifdef(`_CLASS_W_',
154`R$* < @ $=W . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
155ifdef(`_CLASS_X_',
156`R$* < @ $=X . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
157ifdef(`_CLASS_Y_',
158`R$* < @ $=Y . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
159
160# try UUCP traffic as a local address
161R$* < @ $+ .UUCP > $*			$: $1 < @ $[ $2 $] .UUCP > $3
162ifdef(`_OLD_SENDMAIL_',
163`R$* < @ $+ . $+ .UUCP > $*		$@ $1 < @ $2 . $3 > $4',
164`R$* < @ $+ . .UUCP > $*		$@ $1 < @ $2 . > $3')')
165
166# pass to name server to make hostname canonical
167R$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
168
169# handle possible alternate names
170R$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
171R$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
172undivert(8)dnl
173
174# if this is the local hostname, make sure we treat is as canonical
175R$* < @ $j > $*			$: $1 < @ $j . > $2
176
177
178##################################################
179###  Ruleset 4 -- Final Output Post-rewriting  ###
180##################################################
181S4
182
183R@			$@				handle <> error addr
184
185# resolve numeric addresses to name if possible
186R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
187
188# strip trailing dot off possibly canonical name
189R$* < @ $+ . > $*	$1 < @ $2 > $3
190
191# externalize local domain info
192R$* < $+ > $*		$1 $2 $3			defocus
193R@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
194R@ $*			$@ @ $1				... and exit
195
196# UUCP must always be presented in old form
197R$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u
198
199# delete duplicate local names
200R$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
201
202
203
204#############################################################
205###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
206###		   (used for recursive calls)		  ###
207#############################################################
208
209S7
210R$*			$: $>3 $1
211R$*			$@ $>0 $1
212
213
214######################################
215###   Ruleset 0 -- Parse Address   ###
216######################################
217
218S0
219
220# handle numeric address spec
221R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
222R$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec
223
224#R@			$#error$:Invalid address	handle <> form
225
226# now delete the local info -- note $=O to find characters that cause forwarding
227R< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
228R$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
229
230# short circuit local delivery so forwarded email works
231ifdef(`_OLD_SENDMAIL_',
232`R$+ < @ $j . >		$#local $: $1			local address',
233`R$+ < @ $j . >		$#local $: @ $1			local address')
234undivert(3)dnl
235undivert(4)dnl
236
237# resolve remotely connected UUCP links
238ifdef(`_CLASS_V_',
239`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
240	`dnl')
241ifdef(`_CLASS_W_',
242`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
243	`dnl')
244ifdef(`_CLASS_X_',
245`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
246	`dnl')
247
248# resolve fake top level domains by forwarding to other hosts
249ifdef(`BITNET_RELAY',
250`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
251	`dnl')
252ifdef(`CSNET_RELAY',
253`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
254	`dnl')
255
256ifdef(`UUCP_RELAY',
257`# forward non-local UUCP traffic to our UUCP relay
258R$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
259`ifdef(`_UUCP_LINKED_',
260`# forward other UUCP traffic straight to UUCP
261R< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
262R$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
263	`dnl')')
264
265# deal with other remote names
266R$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
267
268ifdef(`_OLD_SENDMAIL_',
269`# forward remaining names to local relay, if any
270R$=L			$#local $: $1			special local names
271R$+			$: $1 < @ $R >			append relay
272R$+ < @ >		$#local $: $1			if no relay, local
273R$+ < @ $+ >		$#smtp $@ $2 $: $1		deliver to relay',
274`# handle locally delivered names
275R$=L			$#local $: @ $1			special local names
276R$+			$#local $: $1			regular local names
277
278#
279# special rewriting after aliases have been expanded
280#
281
282S5
283
284R$+			$: $1 < @ $R >
285R$+ < @ $+ >		$#smtp $@ $2 $: $1 < @ $2 >	send to relay')
286#
287######################################################################
288######################################################################
289#####
290#####			MAILER DEFINITIONS
291#####
292######################################################################
293######################################################################
294undivert(7)dnl
295