quote versionid to avoid # problems
[unix-history] / usr / src / usr.sbin / sendmail / cf / m4 / proto.m4
CommitLineData
f25ecb3d
EA
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
2746f73d 11VERSIONID(`@(#)proto.m4 2.29 (Berkeley) %G%')
f25ecb3d 12
6f403f33 13MAILER(local)dnl
f25ecb3d 14
242270da
EA
15ifdef(`_OLD_SENDMAIL_', `dnl',
16`# level 3 config file format
17V3')
18
f25ecb3d
EA
19##################
20# local info #
21##################
22
dacf3c9f 23Cwlocalhost
5461a68b 24ifdef(`USE_CW_FILE',
dacf3c9f 25`# file containing names of hosts for which we receive email
f25ecb3d
EA
26Fw/etc/sendmail.cw', `dnl')
27
28ifdef(`UUCP_RELAY',
29`# UUCP relay host
8038f5d5 30CONCAT(DY, UUCP_RELAY)
f25ecb3d
EA
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)
5d07d498 41CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
f25ecb3d
EA
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
3eb5f759
EA
49# names that should be delivered locally, even if we have a relay
50CLroot
51undivert(5)dnl
dacf3c9f 52undivert(6)dnl
3eb5f759 53
f25ecb3d 54ifdef(`UUCP_NAME',
755e2424 55`# uucp hostnames
f25ecb3d
EA
56UUCP_NAME
57UUCP_ALIASES
58
59# local UUCP connections
755e2424 60include(UUCP_HOSTS_FILE)',
bb4df025 61`dnl')
f25ecb3d
EA
62
63# operators that cannot be in local usernames (i.e., network indicators)
64CO @ % !
65
6f403f33
EA
66# a class with just dot (for identifying canonical names)
67C..
68
5461a68b
EA
69# list of locations of user database file (null means no lookup)
70OU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
f25ecb3d 71
5461a68b 72# set if we can guarantee no wildcard MX records matching our domain
178054e8 73Ow`'ifdef(`_NO_WILDCARD_MX_', `True', `False')
f25ecb3d
EA
74
75include(`../m4/version.m4')
76
755e2424
EA
77ifdef(`INTERNET_RELAY',
78`include(../sitedep/nicregistered.m4)',
79`dnl')
f25ecb3d 80include(`../m4/boilerplate.m4')
f25ecb3d
EA
81#\f
82######################################################################
83######################################################################
84#####
85##### REWRITING RULES
86#####
87######################################################################
88######################################################################
89
90
91###########################################
92### Rulset 3 -- Name Canonicalization ###
93###########################################
755e2424 94S3
f25ecb3d
EA
95
96# handle "from:<>" special case
56ec6f89 97R$* < > $* $@ @ turn into magic token
f25ecb3d
EA
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
56ec6f89 105R@ $+ , $+ @ $1 : $2 change all "," to ":"
f25ecb3d
EA
106
107# localize and dispose of route-based addresses
56ec6f89 108R@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr>
f25ecb3d
EA
109
110# find focus for list syntax
56ec6f89
EA
111R $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax
112R $+ : $* ; $@ $1 : $2; list syntax
f25ecb3d
EA
113
114# find focus for @ syntax addresses
56ec6f89
EA
115R$+ @ $+ $: $1 < @ $2 > focus on domain
116R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right
117R$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical
f25ecb3d
EA
118
119# convert old-style addresses to a domain-based address
56ec6f89
EA
120R$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names
121R$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps
122R$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains
f25ecb3d
EA
123
124# if we have % signs, take the rightmost one
56ec6f89
EA
125R$* % $* $1 @ $2 First make them all @s.
126R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last.
127R$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish
f25ecb3d
EA
128
129# else we must be a local name
130
131
132###############################################
133### Ruleset 6 -- bottom half of ruleset 3 ###
134###############################################
135
f25ecb3d 136# At this point, everything should be in a local_part@domain format.
f25ecb3d
EA
137
138S6
f25ecb3d
EA
139
140# handle special cases for local names
6f403f33 141R$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all
56ec6f89 142R$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain
dacf3c9f 143undivert(2)dnl
80961747 144
1ab66980
EA
145ifdef(`UUCP_RELAY',
146`# pass UUCP addresses straight through
56ec6f89 147R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3',
1ab66980 148`# if really UUCP, handle it immediately
6f403f33 149ifdef(`_CLASS_U_',
56ec6f89 150`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
6f403f33 151ifdef(`_CLASS_V_',
56ec6f89 152`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
6f403f33 153ifdef(`_CLASS_W_',
56ec6f89 154`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
6f403f33 155ifdef(`_CLASS_X_',
56ec6f89 156`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
6f403f33 157ifdef(`_CLASS_Y_',
56ec6f89 158`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl')
80961747
EA
159
160# try UUCP traffic as a local address
56ec6f89 161R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3
82960e03 162ifdef(`_OLD_SENDMAIL_',
56ec6f89
EA
163`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4',
164`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')')
f25ecb3d
EA
165
166# pass to name server to make hostname canonical
6f403f33
EA
167R$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4
168
dacf3c9f
EA
169# handle possible alternate names
170R$* < @ $=w . $m . > $* $: $1 < @ $j . > $3
171R$* < @ $=w . $m > $* $: $1 < @ $j . > $3
172undivert(8)dnl
173
6f403f33
EA
174# if this is the local hostname, make sure we treat is as canonical
175R$* < @ $j > $* $: $1 < @ $j . > $2
f25ecb3d 176
f25ecb3d
EA
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
6f403f33
EA
186R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr
187
188# strip trailing dot off possibly canonical name
189R$* < @ $+ . > $* $1 < @ $2 > $3
f25ecb3d
EA
190
191# externalize local domain info
6f403f33
EA
192R$* < $+ > $* $1 $2 $3 defocus
193R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical
9d6b5c00 194R@ $* $@ @ $1 ... and exit
f25ecb3d
EA
195
196# UUCP must always be presented in old form
6f403f33 197R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u
f25ecb3d
EA
198
199# delete duplicate local names
6f403f33 200R$+ % $=w @ $=w $1 @ $j u%host@host => u@host
f25ecb3d
EA
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
56ec6f89
EA
220ifdef(`_MAILER_smtp_',
221`# handle numeric address spec
6f403f33 222R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr
56ec6f89
EA
223R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec',
224`dnl')dnl
f25ecb3d 225
5461a68b 226# now delete the local info -- note $=O to find characters that cause forwarding
6f403f33
EA
227R< @ $j . > : $* $@ $>7 $1 @here:... -> ...
228R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ...
f25ecb3d
EA
229
230# short circuit local delivery so forwarded email works
82960e03
EA
231ifdef(`_OLD_SENDMAIL_',
232`R$+ < @ $j . > $#local $: $1 local address',
233`R$+ < @ $j . > $#local $: @ $1 local address')
f25ecb3d 234undivert(3)dnl
755e2424
EA
235undivert(4)dnl
236
56ec6f89 237# resolve remotely connected UUCP links (if any)
708a514b 238ifdef(`_CLASS_V_',
47523c33
EA
239`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
240 `dnl')
708a514b 241ifdef(`_CLASS_W_',
47523c33
EA
242`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
243 `dnl')
708a514b 244ifdef(`_CLASS_X_',
47523c33
EA
245`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
246 `dnl')
755e2424 247
f25ecb3d
EA
248# resolve fake top level domains by forwarding to other hosts
249ifdef(`BITNET_RELAY',
47523c33 250`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET',
f25ecb3d
EA
251 `dnl')
252ifdef(`CSNET_RELAY',
47523c33 253`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET',
f25ecb3d
EA
254 `dnl')
255
755e2424
EA
256ifdef(`UUCP_RELAY',
257`# forward non-local UUCP traffic to our UUCP relay
47523c33 258R$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail',
56ec6f89 259`ifdef(`_MAILER_uucp_',
755e2424
EA
260`# forward other UUCP traffic straight to UUCP
261R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:...
6f403f33 262R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP',
755e2424
EA
263 `dnl')')
264
56ec6f89
EA
265ifdef(`_MAILER_smtp_',
266`# deal with other remote names
37e8750f 267R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain
56ec6f89 268', `dnl')
f25ecb3d 269
82960e03 270ifdef(`_OLD_SENDMAIL_',
5461a68b 271`# forward remaining names to local relay, if any
37e8750f
EA
272R$=L $#local $: $1 special local names
273R$+ $: $1 < @ $R > append relay
274R$+ < @ > $#local $: $1 if no relay, local
47523c33 275R$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay',
82960e03 276`# handle locally delivered names
37e8750f
EA
277R$=L $#local $: @ $1 special local names
278R$+ $#local $: $1 regular local names
6f403f33 279
56ec6f89
EA
280###########################################################################
281### Ruleset 5 -- special rewriting after aliases have been expanded ###
282### (new sendmail only) ###
283###########################################################################
f25ecb3d 284
6f403f33 285S5
f25ecb3d 286
56ec6f89
EA
287ifdef(`_MAILER_smtp_',
288`R$+ $: $1 < @ $R >
b89c26b0 289R$+ < @ $+ > $#smtp $@ $2 $: $1 < @ $2 > send to relay')')
f25ecb3d
EA
290#\f
291######################################################################
292######################################################################
293#####
b89c26b0 294##### `MAILER DEFINITIONS'
f25ecb3d
EA
295#####
296######################################################################
297######################################################################
f25ecb3d 298undivert(7)dnl