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