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