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