need to make ColonOkInAddr do something real
[unix-history] / usr / src / usr.sbin / sendmail / cf / m4 / proto.m4
CommitLineData
f25ecb3d
EA
1divert(-1)
2#
3# Copyright (c) 1983 Eric P. Allman
cb1a7064
KB
4# Copyright (c) 1988, 1993
5# The Regents of the University of California. All rights reserved.
f25ecb3d
EA
6#
7# %sccs.include.redist.sh%
8#
9divert(0)
10
8b065e59 11VERSIONID(`@(#)proto.m4 8.66 (Berkeley) %G%')
f25ecb3d 12
6f403f33 13MAILER(local)dnl
f25ecb3d 14
d4e68feb 15# level 6 config file format
7ec5e19b
EA
16V6/Berkeley
17divert(-1)
18
19# pick our default mailers
20ifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')
21ifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')
feae130e
EA
22ifdef(`confRELAY_MAILER',,
23 `define(`confRELAY_MAILER',
24 `ifdef(`_MAILER_smtp_', `relay',
7ec5e19b 25 `ifdef(`_MAILER_uucp', `suucp', `unknown')')')')
2c840221
EA
26define(`_SMTP_', `confSMTP_MAILER')dnl for readability only
27define(`_LOCAL_', `confLOCAL_MAILER')dnl for readability only
feae130e 28define(`_RELAY_', `confRELAY_MAILER')dnl for readability only
242270da 29
7ec5e19b
EA
30# back compatibility with old config files
31ifdef(`confDEF_GROUP_ID',
32 `errprint(`*** confDEF_GROUP_ID is obsolete.')
33 errprint(` Use confDEF_USER_ID with a colon in the value instead.')')
34ifdef(`confREAD_TIMEOUT',
35 `errprint(`*** confREAD_TIMEOUT is obsolete.')
36 errprint(` Use individual confTO_<timeout> parameters instead.')')
37ifdef(`confMESSAGE_TIMEOUT',
38 `define(`_ARG_', index(confMESSAGE_TIMEOUT, /))
39 ifelse(_ARG_, -1,
40 `define(`confTO_QUEUERETURN', confMESSAGE_TIMEOUT)',
41 `define(`confTO_QUEUERETURN',
42 substr(confMESSAGE_TIMEOUT, 0, _ARG_))
43 define(`confTO_QUEUEWARN',
44 substr(confMESSAGE_TIMEOUT, eval(_ARG_+1)))')')
45ifdef(`confMIN_FREE_BLOCKS', `ifelse(index(confMIN_FREE_BLOCKS, /), -1,,
46 `errprint(`*** compound confMIN_FREE_BLOCKS is obsolete.')
47 errprint(` Use confMAX_MESSAGE_SIZE for the second part of the value.')')')
48
49# clean option definitions below....
50define(`_OPTION', `ifdef(`$2', `O $1=$2', `#O $1`'ifelse($3, `',, `=$3')')')dnl
51
52divert(0)dnl
53
f25ecb3d
EA
54##################
55# local info #
56##################
57
dacf3c9f 58Cwlocalhost
5461a68b 59ifdef(`USE_CW_FILE',
dacf3c9f 60`# file containing names of hosts for which we receive email
1bdba97e
EA
61Fw`'confCW_FILE',
62 `dnl')
7ec5e19b 63
64100696 64# my official domain name
7ec5e19b
EA
65# ... define this only if sendmail cannot automatically determine your domain
66ifdef(`confDOMAIN_NAME', `Dj`'confDOMAIN_NAME', `#Dj$w.Foo.COM')
64100696 67
7ec5e19b 68ifdef(`_NULL_CLIENT_ONLY_', `divert(-1)')dnl
64100696
EA
69
70CP.
f25ecb3d
EA
71
72ifdef(`UUCP_RELAY',
73`# UUCP relay host
1bdba97e 74DY`'UUCP_RELAY
7df175c3 75CPUUCP
a151c868 76
f25ecb3d
EA
77')dnl
78ifdef(`BITNET_RELAY',
79`# BITNET relay host
1bdba97e 80DB`'BITNET_RELAY
7df175c3 81CPBITNET
a151c868 82
d2e7dfa9
EA
83')dnl
84ifdef(`FAX_RELAY',
85`# FAX relay host
1bdba97e 86DF`'FAX_RELAY
7df175c3 87CPFAX
d2e7dfa9 88
f25ecb3d 89')dnl
64100696
EA
90# "Smart" relay host (may be null)
91DS`'ifdef(`SMART_HOST', SMART_HOST)
f25ecb3d 92
efd6da82
EA
93ifdef(`LUSER_RELAY',
94`# place to which unknown users should be forwarded
95Kuser user -m -a<>
96DL`'LUSER_RELAY
97', `dnl')
98
7ec5e19b
EA
99# operators that cannot be in local usernames (i.e., network indicators)
100CO @ % ifdef(`_NO_UUCP_', `', `!')
101
102# a class with just dot (for identifying canonical names)
103C..
104
8d95d628
EA
105ifdef(`MAILER_TABLE',
106`# Mailer table (overriding domains)
107Kmailertable MAILER_TABLE
108
e653dde7
EA
109')dnl
110ifdef(`DOMAIN_TABLE',
111`# Domain table (adding domains)
112Kdomaintable DOMAIN_TABLE
113
97dcbde7 114')dnl
f25ecb3d 115# who I send unqualified names to (null means deliver locally)
1bdba97e 116DR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
f25ecb3d 117
22bc0471 118# who gets all local email traffic ($R has precedence for unqualified names)
1bdba97e 119DH`'ifdef(`MAIL_HUB', MAIL_HUB)
22bc0471 120
45eb1b8f
EA
121# class L: names that should be delivered locally, even if we have a relay
122# class E: names that should be exposed as from this host, even if we masquerade
f4d9c9f9
EA
123# class D: dotted names, e.g., root.machinename
124#CL root
125CE root
3eb5f759 126undivert(5)dnl
f4d9c9f9
EA
127ifdef(`__DOTTED_USER_LIST__',
128 `__DOTTED_USER_LIST__',
129 `#CD postmaster')
3eb5f759 130
f22970ed
EA
131# dequoting map
132Kdequote dequote
f25ecb3d 133
7ec5e19b
EA
134divert(0)dnl
135# who I masquerade as (null for no masquerading)
136DM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME)
137
9863b6e1
EA
138undivert(6)dnl
139
a151c868
EA
140######################
141# Special macros #
142######################
143
144# SMTP initial login message
1bdba97e 145De`'confSMTP_LOGIN_MSG
a151c868
EA
146
147# UNIX initial From header format
1bdba97e 148Dl`'confFROM_LINE
a151c868
EA
149
150# my name for error messages
1bdba97e 151Dn`'confMAILER_NAME
a151c868
EA
152
153# delimiter (operator) characters
1bdba97e 154Do`'confOPERATORS
f25ecb3d 155
a151c868 156# format of a total name
f4d9c9f9 157Dq`'ifdef(`confFROM_HEADER', confFROM_HEADER, `$?x$x <$g>$|$g$.')
f25ecb3d 158include(`../m4/version.m4')
a151c868
EA
159
160###############
161# Options #
162###############
163
0b8c3ec1 164# strip message body to 7 bits on input?
7ec5e19b 165_OPTION(SevenBitInput, `confSEVEN_BIT_INPUT')
a151c868 166
3ffefc8a 167# 8-bit data handling
7ec5e19b 168_OPTION(EightBitMode, `confEIGHT_BIT_HANDLING', adaptive)
3ffefc8a 169
7ec5e19b
EA
170# wait for alias file rebuild (default units: minutes)
171_OPTION(AliasWait, `confALIAS_WAIT', 5m)
a151c868
EA
172
173# location of alias file
7ec5e19b 174O AliasFile=ifdef(`ALIAS_FILE', `ALIAS_FILE', /etc/aliases)
a151c868 175
63381843 176# minimum number of free blocks on filesystem
7ec5e19b
EA
177_OPTION(MinFreeBlocks, `confMIN_FREE_BLOCKS', 100)
178
179# maximum message size
180_OPTION(MaxMessageSize, `confMAX_MESSAGE_SIZE', 1000000)
63381843 181
a151c868 182# substitution for space (blank) characters
7ec5e19b 183_OPTION(BlankSub, `confBLANK_SUB', _)
a151c868 184
82561627 185# avoid connecting to "expensive" mailers on initial submission?
7ec5e19b 186_OPTION(HoldExpensive, `confCON_EXPENSIVE')
a151c868
EA
187
188# checkpoint queue runs after every N successful deliveries
7ec5e19b 189_OPTION(CheckpointInterval, `confCHECKPOINT_INTERVAL', 10)
a151c868
EA
190
191# default delivery mode
7ec5e19b 192_OPTION(DeliveryMode, `confDELIVERY_MODE', background)
a151c868
EA
193
194# automatically rebuild the alias database?
7ec5e19b 195_OPTION(AutoRebuildAliases, `confAUTO_REBUILD')
a151c868 196
1bdba97e 197# error message header/file
7ec5e19b 198_OPTION(ErrorHeader, `confERROR_MESSAGE', /etc/sendmail.oE)
a151c868
EA
199
200# error mode
7ec5e19b 201_OPTION(ErrorMode, `confERROR_MODE', print)
a151c868
EA
202
203# save Unix-style "From_" lines at top of header?
7ec5e19b 204_OPTION(SaveFromLine, `confSAVE_FROM_LINES')
a151c868
EA
205
206# temporary file mode
7ec5e19b 207_OPTION(TempFileMode, `confTEMP_FILE_MODE', 0600)
a151c868
EA
208
209# match recipients against GECOS field?
7ec5e19b 210_OPTION(MatchGECOS, `confMATCH_GECOS')
a151c868
EA
211
212# maximum hop count
7ec5e19b 213_OPTION(MaxHopCount, `confMAX_HOP', 17)
a151c868
EA
214
215# location of help file
7ec5e19b 216O HelpFile=ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)
a151c868
EA
217
218# ignore dots as terminators in incoming messages?
7ec5e19b 219_OPTION(IgnoreDots, `confIGNORE_DOTS')
a151c868 220
7ec5e19b
EA
221# name resolver options
222_OPTION(ResolverOptions, `confBIND_OPTS', +AAONLY)
a151c868 223
0b8c3ec1 224# deliver MIME-encapsulated error messages?
7ec5e19b 225_OPTION(SendMimeErrors, `confMIME_FORMAT_ERRORS')
0b8c3ec1 226
a151c868 227# Forward file search path
7ec5e19b 228_OPTION(ForwardPath, `confFORWARD_PATH', /var/forward/$u:$z/.forward.$w:$z/.forward)
a151c868
EA
229
230# open connection cache size
7ec5e19b 231_OPTION(ConnectionCacheSize, `confMCI_CACHE_SIZE', 2)
a151c868
EA
232
233# open connection cache timeout
7ec5e19b 234_OPTION(ConnectionCacheTimeout, `confMCI_CACHE_TIMEOUT', 5m)
a151c868 235
b28237e4 236# use Errors-To: header?
7ec5e19b 237_OPTION(UseErrorsTo, `confUSE_ERRORS_TO')
b28237e4 238
a151c868 239# log level
7ec5e19b 240_OPTION(LogLevel, `confLOG_LEVEL', 10)
a151c868
EA
241
242# send to me too, even in an alias expansion?
7ec5e19b 243_OPTION(MeToo, `confME_TOO')
a151c868
EA
244
245# verify RHS in newaliases?
7ec5e19b 246_OPTION(CheckAliases, `confCHECK_ALIASES')
a151c868
EA
247
248# default messages to old style headers if no special punctuation?
7ec5e19b 249_OPTION(OldStyleHeaders, `confOLD_STYLE_HEADERS')
a151c868 250
4c230f32 251# SMTP daemon options
7ec5e19b 252_OPTION(DaemonPortOptions, `confDAEMON_OPTIONS', Port=esmtp)
4c230f32 253
63381843 254# privacy flags
7ec5e19b 255_OPTION(PrivacyOptions, `confPRIVACY_FLAGS', authwarnings)
63381843 256
a151c868 257# who (if anyone) should get extra copies of error messages
7ec5e19b 258_OPTION(PostMasterCopy, `confCOPY_ERRORS_TO', Postmaster)
a151c868
EA
259
260# slope of queue-only function
7ec5e19b 261_OPTION(QueueFactor, `confQUEUE_FACTOR', 600000)
a151c868
EA
262
263# queue directory
7ec5e19b
EA
264O QueueDirectory=ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)
265
266# timeouts (many of these)
267_OPTION(Timeout.initial, `confTO_INITIAL', 5m)
268_OPTION(Timeout.helo, `confTO_HELO', 5m)
269_OPTION(Timeout.mail, `confTO_MAIL', 10m)
270_OPTION(Timeout.rcpt, `confTO_RCPT', 1h)
271_OPTION(Timeout.datainit, `confTO_DATAINIT', 5m)
272_OPTION(Timeout.datablock, `confTO_DATABLOCK', 1h)
273_OPTION(Timeout.datafinal, `confTO_DATAFINAL', 1h)
274_OPTION(Timeout.rset, `confTO_RSET', 5m)
275_OPTION(Timeout.quit, `confTO_QUIT', 2m)
276_OPTION(Timeout.misc, `confTO_MISC', 2m)
277_OPTION(Timeout.command, `confTO_COMMAND', 1h)
278_OPTION(Timeout.ident, `confTO_IDENT', 30s)
279_OPTION(Timeout.fileopen, `confTO_FILEOPEN', 60s)
280_OPTION(Timeout.queuereturn, `confTO_QUEUERETURN', 5d)
281_OPTION(Timeout.queuereturn.normal, `confTO_QUEUERETURN_NORMAL', 5d)
282_OPTION(Timeout.queuereturn.urgent, `confTO_QUEUERETURN_URGENT', 2d)
283_OPTION(Timeout.queuereturn.non-urgent, `confTO_QUEUERETURN_NONURGENT', 7d)
284_OPTION(Timeout.queuewarn, `confTO_QUEUEWARN', 4h)
285_OPTION(Timeout.queuewarn.normal, `confTO_QUEUEWARN_NORMAL', 4h)
286_OPTION(Timeout.queuewarn.urgent, `confTO_QUEUEWARN_URGENT', 1h)
287_OPTION(Timeout.queuewarn.non-urgent, `confTO_QUEUEWARN_NONURGENT', 12h)
a151c868 288
919277d7 289# should we not prune routes in route-addr syntax addresses?
7ec5e19b 290_OPTION(DontPruneRoutes, `confDONT_PRUNE_ROUTES')
919277d7 291
a151c868 292# queue up everything before forking?
7ec5e19b 293_OPTION(SuperSafe, `confSAFE_QUEUE')
a151c868
EA
294
295# status file
7ec5e19b 296_OPTION(StatusFile, `STATUS_FILE', /etc/sendmail.st)
a151c868
EA
297
298# time zone handling:
299# if undefined, use system default
300# if defined but null, use TZ envariable passed in
301# if defined and non-null, use that info
7ec5e19b
EA
302ifelse(confTIME_ZONE, `USE_SYSTEM', `#O TimeZoneSpec=',
303 confTIME_ZONE, `USE_TZ', `O TimeZoneSpec=',
304 `O TimeZoneSpec=confTIME_ZONE')
a151c868 305
7ec5e19b
EA
306# default UID (can be username or userid:groupid)
307_OPTION(DefaultUser, `confDEF_USER_ID', nobody)
a151c868
EA
308
309# list of locations of user database file (null means no lookup)
7ec5e19b 310_OPTION(UserDatabaseSpec, `confUSERDB_SPEC', /etc/userdb)
a151c868 311
4c230f32 312# fallback MX host
7ec5e19b 313_OPTION(FallbackMXhost, `confFALLBACK_MX', fall.back.host.net)
4c230f32 314
d8ebcd49 315# if we are the best MX host for a site, try it directly instead of config err
7ec5e19b 316_OPTION(TryNullMXList, `confTRY_NULL_MX_LIST')
d8ebcd49 317
a151c868 318# load average at which we just queue messages
7ec5e19b 319_OPTION(QueueLA, `confQUEUE_LA', 8)
a151c868
EA
320
321# load average at which we refuse connections
7ec5e19b 322_OPTION(RefuseLA, `confREFUSE_LA', 12)
a151c868
EA
323
324# work recipient factor
7ec5e19b 325_OPTION(RecipientFactor, `confWORK_RECIPIENT_FACTOR', 30000)
a151c868
EA
326
327# deliver each queued job in a separate process?
7ec5e19b 328_OPTION(ForkEachJob, `confSEPARATE_PROC')
a151c868
EA
329
330# work class factor
7ec5e19b 331_OPTION(ClassFactor, `confWORK_CLASS_FACTOR', 1800)
a151c868
EA
332
333# work time factor
7ec5e19b 334_OPTION(RetryFactor, `confWORK_TIME_FACTOR', 90000)
a151c868 335
26984f4d 336# shall we sort the queue by hostname first?
7ec5e19b
EA
337_OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', priority)
338
339# minimum time in queue before retry
340_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', 30m)
341
342# default character set
343_OPTION(DefaultCharSet, `confDEF_CHAR_SET', iso-8859-1)
344
345# service switch file (ignored on Solaris, Ultrix, OSF/1, others)
346_OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', /etc/service.switch)
347
348# dialup line delay on connection failure
349_OPTION(DialDelay, `confDIAL_DELAY', 10s)
350
351# action to take if there are no recipients in the message
352_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', add-to-undisclosed)
353
354# chrooted environment for writing to files
355_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', /arch)
26984f4d 356
a151c868
EA
357###########################
358# Message precedences #
359###########################
360
361Pfirst-class=0
362Pspecial-delivery=100
97dcbde7 363Plist=-30
a151c868
EA
364Pbulk=-60
365Pjunk=-100
366
367#####################
368# Trusted users #
369#####################
370
7ec5e19b
EA
371# this is equivalent to setting class "t"
372#Ft/etc/sendmail.trusted
a151c868
EA
373Troot
374Tdaemon
375Tuucp
376
377#########################
378# Format of headers #
379#########################
380
e0a38185 381H?P?Return-Path: $g
d1c8c981 382HReceived: confRECEIVED_HEADER
a151c868
EA
383H?D?Resent-Date: $a
384H?D?Date: $a
385H?F?Resent-From: $q
386H?F?From: $q
387H?x?Full-Name: $x
388HSubject:
389# HPosted-Date: $a
390# H?l?Received-Date: $b
391H?M?Resent-Message-Id: <$t.$i@$j>
392H?M?Message-Id: <$t.$i@$j>
7ec5e19b
EA
393ifdef(`_NULL_CLIENT_ONLY_',
394 `include(../m4/nullrelay.m4)m4exit',
395 `dnl')
f25ecb3d
EA
396#\f
397######################################################################
398######################################################################
399#####
400##### REWRITING RULES
401#####
402######################################################################
403######################################################################
404
da9b1c77 405undivert(9)dnl
f25ecb3d
EA
406
407###########################################
408### Rulset 3 -- Name Canonicalization ###
409###########################################
755e2424 410S3
f25ecb3d 411
d2fe4e9e 412# handle null input (translate to <@> special case)
66fe2d65 413R$@ $@ <@>
77e96a45 414
6449d970
EA
415# strip group: syntax (not inside angle brackets!) and trailing semicolon
416R$* $: $1 <@> mark addresses
417R$* < $* > $* <@> $: $1 < $2 > $3 unmark <addr>
418R$* :: $* <@> $: $1 :: $2 unmark host::addr
419R$* : $* <@> $: $2 strip colon if marked
420R$* <@> $: $1 unmark
421R$* ; $: $1 strip trailing semi
422
423# null input now results from list:; syntax
424R$@ $@ :; <@>
425
f25ecb3d 426# basic textual canonicalization -- note RFC733 heuristic here
0758279f 427R$*<$*>$*<$*>$* $2$3<$4>$5 strip multiple <> <>
4850f6e1 428R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting
66fe2d65 429R$*<>$* $@ <@> MAIL FROM:<> case
f25ecb3d
EA
430R$*<$+>$* $2 basic RFC821/822 parsing
431
432# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
56ec6f89 433R@ $+ , $+ @ $1 : $2 change all "," to ":"
f25ecb3d
EA
434
435# localize and dispose of route-based addresses
f22970ed 436R@ $+ : $+ $@ $>96 < @$1 > : $2 handle <route-addr>
f25ecb3d
EA
437
438# find focus for list syntax
f22970ed 439R $+ : $* ; @ $+ $@ $>96 $1 : $2 ; < @ $3 > list syntax
56ec6f89 440R $+ : $* ; $@ $1 : $2; list syntax
f25ecb3d
EA
441
442# find focus for @ syntax addresses
56ec6f89
EA
443R$+ @ $+ $: $1 < @ $2 > focus on domain
444R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right
f22970ed 445R$+ < @ $+ > $@ $>96 $1 < @ $2 > already canonical
f25ecb3d 446
d646efc4
EA
447# do some sanity checking
448R$* < @ $* : $* > $* $1 < @ $2 $3 > $4 nix colons in addrs
449
1429c39b
EA
450ifdef(`_NO_UUCP_', `dnl',
451`# convert old-style addresses to a domain-based address
f22970ed
EA
452R$- ! $+ $@ $>96 $2 < @ $1 .UUCP > resolve uucp names
453R$+ . $- ! $+ $@ $>96 $3 < @ $1 . $2 > domain uucps
454R$+ ! $+ $@ $>96 $2 < @ $1 .UUCP > uucp subdomains')
f25ecb3d
EA
455
456# if we have % signs, take the rightmost one
56ec6f89
EA
457R$* % $* $1 @ $2 First make them all @s.
458R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last.
f22970ed 459R$* @ $* $@ $>96 $1 < @ $2 > Insert < > and finish
f25ecb3d
EA
460
461# else we must be a local name
462
463
576bbd75 464################################################
f22970ed 465### Ruleset 96 -- bottom half of ruleset 3 ###
576bbd75 466################################################
f25ecb3d 467
45eb1b8f 468# At this point, everything should be in a "local_part<@domain>extra" format.
f22970ed 469S96
f25ecb3d
EA
470
471# handle special cases for local names
89906048
EA
472R$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all
473R$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain
474ifdef(`_NO_UUCP_', `dnl',
475`R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain')
e1beeb7d
EA
476R$* < @ [ $+ ] > $* $: $1 < @@ [ $2 ] > $3 mark [a.b.c.d]
477R$* < @@ $=w > $* $: $1 < @ $j . > $3 self-literal
1d9af8b4 478R$* < @@ $+ > $* $@ $1 < @ $2 > $3 canon IP addr
e653dde7 479ifdef(`DOMAIN_TABLE', `
4e973900
EA
480# look up domains in the domain table
481R$* < @ $+ > $* $: $1 < @ $(domaintable $2 $) > $3',
e653dde7 482`dnl')
dacf3c9f 483undivert(2)dnl
80961747 484
f5ade8ff
EA
485ifdef(`_NO_UUCP_', `dnl',
486`ifdef(`UUCP_RELAY',
1ab66980 487`# pass UUCP addresses straight through
9ee2219d 488R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP . > $3',
1ab66980 489`# if really UUCP, handle it immediately
6f403f33 490ifdef(`_CLASS_U_',
9ee2219d 491`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')
6f403f33 492ifdef(`_CLASS_V_',
9ee2219d 493`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')
6f403f33 494ifdef(`_CLASS_W_',
9ee2219d 495`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')
6f403f33 496ifdef(`_CLASS_X_',
9ee2219d 497`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')
6f403f33 498ifdef(`_CLASS_Y_',
9ee2219d 499`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')
80961747
EA
500
501# try UUCP traffic as a local address
9ee2219d 502R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP . > $3
f22970ed 503R$* < @ $+ . . UUCP . > $* $@ $1 < @ $2 . > $3')
f5ade8ff 504')
e0fe178c 505ifdef(`_NO_CANONIFY_', `dnl',
f5ade8ff 506`# pass to name server to make hostname canonical
ad8d5f97
EA
507R$* < @ $* $~P > $* $: $1 < @ $[ $2 $3 $] > $4')
508
e0fe178c
EA
509# local host aliases and pseudo-domains are always canonical
510R$* < @ $=w > $* $: $1 < @ $2 . > $3
9ee2219d 511R$* < @ $* $=P > $* $: $1 < @ $2 $3 . > $4
e0fe178c 512R$* < @ $* . . > $* $1 < @ $2 . > $3
9ee2219d 513
6f403f33
EA
514# if this is the local hostname, make sure we treat is as canonical
515R$* < @ $j > $* $: $1 < @ $j . > $2
f25ecb3d 516
f25ecb3d
EA
517
518##################################################
519### Ruleset 4 -- Final Output Post-rewriting ###
520##################################################
521S4
522
66fe2d65 523R$*<@> $@ $1 handle <> and list:;
f25ecb3d 524
6f403f33
EA
525# strip trailing dot off possibly canonical name
526R$* < @ $+ . > $* $1 < @ $2 > $3
f25ecb3d
EA
527
528# externalize local domain info
6f403f33
EA
529R$* < $+ > $* $1 $2 $3 defocus
530R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical
9d6b5c00 531R@ $* $@ @ $1 ... and exit
f25ecb3d 532
1429c39b
EA
533ifdef(`_NO_UUCP_', `dnl',
534`# UUCP must always be presented in old form
535R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u')
f25ecb3d
EA
536
537# delete duplicate local names
6f403f33 538R$+ % $=w @ $=w $1 @ $j u%host@host => u@host
f25ecb3d
EA
539
540
541
576bbd75 542##############################################################
f22970ed 543### Ruleset 97 -- recanonicalize and call ruleset zero ###
576bbd75
EA
544### (used for recursive calls) ###
545##############################################################
f25ecb3d 546
f22970ed 547S`'97
f25ecb3d
EA
548R$* $: $>3 $1
549R$* $@ $>0 $1
550
551
552######################################
553### Ruleset 0 -- Parse Address ###
554######################################
555
556S0
557
39789777 558R<@> $#_LOCAL_ $: <@> special case error msgs
f3f4549f 559R$* : $* ; $#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
2adfe5d6 560R<@ $+> $#error $@ USAGE $: "user address required"
39789777 561R$* <$* : $* > $* $#error $@ USAGE $: "colon illegal in host name part"
8395a858 562R$* < @ . > $* $#error $@ USAGE $: "invalid host name"
89d51ef0 563
56ec6f89
EA
564ifdef(`_MAILER_smtp_',
565`# handle numeric address spec
f22970ed 566R$* < @ [ $+ ] > $* $: $>98 $1 < @ [ $2 ] > $3 numeric internet spec
90307086 567R$* < @ [ $+ ] > $* $#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3 still numeric: send',
d8ebcd49 568 `dnl')
f25ecb3d 569
5461a68b 570# now delete the local info -- note $=O to find characters that cause forwarding
f22970ed
EA
571R$* < @ > $* $@ $>97 $1 user@ => user
572R< @ $=w . > : $* $@ $>97 $2 @here:... -> ...
573R$* $=O $* < @ $=w . > $@ $>97 $1 $2 $3 ...@here -> ...
194df6ac
EA
574
575# handle local hacks
f22970ed 576R$* $: $>98 $1
f25ecb3d
EA
577
578# short circuit local delivery so forwarded email works
664ff353
EA
579R$* < @ $=w . > $: < $R @ $H > $1 < @ $2 . > if both relay & hub ...
580R<$+ @ $+ > $* < $+ > $: $>_SET_95_ < $H > $3 < $4 > ... send direct to hub
581R<$* @ $* > $* < $+ > $: $3 < $4 >
efd6da82
EA
582ifdef(`_STICKY_LOCAL_DOMAIN_',
583`R$+ < @ $=w . > $: < $H > $1 < @ $2 . > first try hub
31a6de89 584R< $+ > $+ < $+ > $>95 < $1 > $2 < $3 > yep ....
efd6da82 585R< > $=D . $+ < $+ > $#_LOCAL_ $: $1 . $2 dotted name?
29e43b7a 586R< > $+ + $* < $+ > $#_LOCAL_ $: $1 + $2 plussed name?
efd6da82 587R< > $+ < $+ > $#_LOCAL_ $: @ $1 nope, local address',
664ff353
EA
588`R$+ < @ $=w . > $#_LOCAL_ $: $1 dispose directly',
589`R$+ < @ $=w . > $: $>_SET_95_ < $H > $1 < @ $2 . > sticky local names
590R$+ < @ $=w . > $#_LOCAL_ $: @ $1 sticky local names')
755e2424
EA
591undivert(4)dnl
592
979297f9
EA
593ifdef(`_NO_UUCP_', `dnl',
594`# resolve remotely connected UUCP links (if any)
708a514b 595ifdef(`_CLASS_V_',
7d426e19 596`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: @ $V : $1 @ $2.UUCP $3',
47523c33 597 `dnl')
708a514b 598ifdef(`_CLASS_W_',
7d426e19 599`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: @ $W : $1 @ $2.UUCP $3',
47523c33 600 `dnl')
708a514b 601ifdef(`_CLASS_X_',
7d426e19 602`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: @ $X : $1 @ $2.UUCP $3',
979297f9 603 `dnl')')
755e2424 604
f25ecb3d
EA
605# resolve fake top level domains by forwarding to other hosts
606ifdef(`BITNET_RELAY',
7d426e19 607`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 @ $2 . BITNET $3 user@host.BITNET',
7d426e19 608`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 @ $2 . CSNET $3 user@host.CSNET',
f25ecb3d 609 `dnl')
418602bc
EA
610ifdef(`_MAILER_pop_',
611`R$+ < @ POP. > $#pop $: $1 user@POP',
612 `dnl')
d2e7dfa9 613ifdef(`_MAILER_fax_',
9ee2219d 614`R$+ < @ $+ .FAX. > $#fax $@ $2 $: $1 user@host.FAX',
d2e7dfa9 615`ifdef(`FAX_RELAY',
7d426e19 616`R$*<@$+.FAX>$* $#smtp $@ $F $: $1 @ $2 . FAX $3 user@host.FAX',
d2e7dfa9 617 `dnl')')
f25ecb3d 618
755e2424
EA
619ifdef(`UUCP_RELAY',
620`# forward non-local UUCP traffic to our UUCP relay
7d426e19 621R$*<@$*.UUCP>$* $#smtp $@ $Y $: @ $Y : $1 @ $2.UUCP $3 uucp mail',
56ec6f89 622`ifdef(`_MAILER_uucp_',
755e2424 623`# forward other UUCP traffic straight to UUCP
7aa54c60 624R$* < @ $+ .UUCP. > $* $#uucp $@ $2 $: $1 < @ $2 .UUCP. > $3 user@host.UUCP',
755e2424 625 `dnl')')
194df6ac 626ifdef(`_MAILER_usenet_', `
e653dde7 627# addresses sent to net.group.USENET will get forwarded to a newsgroup
5adfff4e 628R$+ . USENET $#usenet $: $1',
3a5030a1 629 `dnl')
e653dde7 630
97dcbde7
EA
631ifdef(`_LOCAL_RULES_',
632`# figure out what should stay in our local mail system
7d426e19 633R$* < @ $* > $* $#smtp $@ $2 $: $1 @ $2 $3 user@host.domain')')
64100696 634# pass names that still have a host to a smarthost (if defined)
f22970ed 635R$* < @ $* > $* $: $>95 < $S > $1 < @ $2 > $3 glue on smarthost name
e653dde7 636
64100696 637# deal with other remote names
3bd9528c 638ifdef(`_MAILER_smtp_',
2c97939f 639`R$* < @$* > $* $#_SMTP_ $@ $2 $: $1 < @ $2 > $3 user@host.domain',
64100696 640`R$* < @$* > $* $#error $@NOHOST $: Unrecognized host name $2')
f25ecb3d 641
f22970ed 642# if this is quoted, strip the quotes and try again
ccfcf4aa 643R$+ $: $(dequote $1 $) strip quotes
f22970ed 644R$+ $=O $+ $@ $>97 $1 $2 $3 try again
ccfcf4aa
EA
645
646# handle locally delivered names
664ff353 647R$=L $: $>_SET_95_ < $H > $1 special local names
2c840221
EA
648R$=L $#_LOCAL_ $: @ $1 special local names
649R$+ $#_LOCAL_ $: $1 regular local names
6f403f33 650
56ec6f89
EA
651###########################################################################
652### Ruleset 5 -- special rewriting after aliases have been expanded ###
56ec6f89 653###########################################################################
f25ecb3d 654
6f403f33 655S5
f25ecb3d 656
f4d9c9f9
EA
657# if we have a "special dotted user", convert it back to the base name
658R$=D . * $#_LOCAL_ $: $1
659R$=D . $+ $#_LOCAL_ $: $1 . *
660
efd6da82
EA
661# prepend an empty "forward host" on the front
662R$+ $: <> $1
663
664ifdef(`LUSER_RELAY',
665`# send unrecognized local users to a relay host
0716b180
EA
666R< > $+ + $* $: < $L . > $( user $1 $) + $2
667R< > $+ $: < $L . > $( user $1 $) look up user
668R< $* > $+ <> $* $: < > $2 $3 found; strip $L
669R< $* . > $+ $: < $1 > $2 strip extra dot')
670
671# handle plussed local names
672R< > $+ + $* $#_LOCAL_ $@ $2 $: $1
efd6da82 673
32014295 674# see if we have a relay or a hub
664ff353
EA
675R$+ $: $>_SET_95_ < $R > $1 try relay
676R$+ $: $>_SET_95_ < $H > $1 try hub')
bc09d8d3
EA
677ifdef(`MAILER_TABLE',
678`
679
d8ebcd49
EA
680###################################################################
681### Ruleset 90 -- try domain part of mailertable entry ###
d8ebcd49 682###################################################################
bc09d8d3
EA
683
684S90
46977ce0
EA
685R<$*> <$- $+ > $* $: < $1 . $2 > < $3 > $4
686R<. $+ > $+ $: < $1 > $2
687R< $+ > < > $+ $: < $1 > < . > $2
688R<$*> < $+ > $* $: <$1> < $(mailertable $2 $@ $1 $) > $3 lookup
689R<$+> <$- : $+ > $* $# $2 $@ $3 $: $4 check -- resolved?
690R$* $: $>87 $1
691R<$+> < . $+ > $*<$*> $@ $>90 <$1> <$2> $3<$4> no -- strip & try again
692R$* $: $>88 $1
693R<$+> <$*> $* $@ $3 no match',
bc09d8d3 694`dnl')
d8ebcd49 695
feae130e 696###################################################################
f22970ed 697### Ruleset 95 -- canonify mailer:host syntax to triple ###
feae130e
EA
698###################################################################
699
f22970ed 700S95
feae130e
EA
701R< > $* $@ $1 strip off null relay
702R< $- : $+ > $* $# $1 $@ $2 $: $3 try qualified mailer
703R< $=w > $* $@ $2 delete local host
704R< $+ > $* $#_RELAY_ $@ $1 $: $2 use unqualified mailer
705
d8ebcd49 706###################################################################
f22970ed 707### Ruleset 98 -- local part of ruleset zero (can be null) ###
d8ebcd49
EA
708###################################################################
709
f22970ed 710S98
d8ebcd49 711undivert(3)dnl
f25ecb3d
EA
712#\f
713######################################################################
714######################################################################
715#####
ec174858 716`##### MAILER DEFINITIONS'
f25ecb3d
EA
717#####
718######################################################################
719######################################################################
f25ecb3d 720undivert(7)dnl