xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision cb36a3b0)
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
11VERSIONID(`@(#)proto.m4	6.37 (Berkeley) 05/01/93')
12
13MAILER(local)dnl
14
15ifdef(`_OLD_SENDMAIL_', `dnl',
16`# level 4 config file format
17V4')
18
19##################
20#   local info   #
21##################
22
23Cwlocalhost
24ifdef(`USE_CW_FILE',
25`# file containing names of hosts for which we receive email
26CONCAT(`Fw', confCW_FILE)', `dnl')
27
28ifdef(`UUCP_RELAY',
29`# UUCP relay host
30CONCAT(DY, UUCP_RELAY)
31
32')dnl
33ifdef(`BITNET_RELAY',
34`#  BITNET relay host
35CONCAT(DB, BITNET_RELAY)
36
37')dnl
38ifdef(`CSNET_RELAY',
39`# CSNET relay host
40CONCAT(DC, CSNET_RELAY)
41
42')dnl
43ifdef(`FAX_RELAY',
44`# FAX relay host
45CONCAT(DF, FAX_RELAY)
46
47')dnl
48ifdef(`SMART_HOST',
49`# "Smart" UUCP relay host
50CONCAT(DS, SMART_HOST)
51
52')dnl
53ifdef(`MAILER_TABLE',
54`# Mailer table (overriding domains)
55Kmailertable MAILER_TABLE
56
57')dnl
58# who I send unqualified names to (null means deliver locally)
59CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
60
61# who gets all local email traffic ($R has precedence for unqualified names)
62CONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
63
64# my official hostname ($w or $w.$D)
65CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
66
67# who I masquerade as (can be $j)
68CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
69
70# class L: names that should be delivered locally, even if we have a relay
71# class E: names that should be exposed as from this host, even if we masquerade
72CLroot
73CEroot
74undivert(5)dnl
75
76# operators that cannot be in local usernames (i.e., network indicators)
77CO @ % ifdef(`_NO_UUCP_', `', `!')
78
79# a class with just dot (for identifying canonical names)
80C..
81
82ifdef(`_OLD_SENDMAIL_', `dnl',
83`# dequoting map
84Kdequote dequote')
85
86undivert(6)dnl
87
88######################
89#   Special macros   #
90######################
91
92# SMTP initial login message
93CONCAT(De, confSMTP_LOGIN_MSG)
94
95# UNIX initial From header format
96CONCAT(Dl, confFROM_LINE)
97
98# my name for error messages
99CONCAT(Dn, confMAILER_NAME)
100
101# delimiter (operator) characters
102CONCAT(Do, confOPERATORS)
103
104# format of a total name
105CONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER,
106	ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.')))
107include(`../m4/version.m4')
108
109###############
110#   Options   #
111###############
112
113# preserve 8 bits on message body on input?
114CONCAT(O8, confEIGHT_BIT_INPUT)
115
116# wait (in minutes) for alias file rebuild
117CONCAT(Oa, confALIAS_WAIT)
118
119# location of alias file
120CONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases))
121
122# minimum number of free blocks on filesystem
123CONCAT(Ob, confMIN_FREE_BLOCKS)
124
125# substitution for space (blank) characters
126CONCAT(OB, confBLANK_SUB)
127
128# connect to "expensive" mailers on initial submission?
129CONCAT(Oc, confCON_EXPENSIVE)
130
131# checkpoint queue runs after every N successful deliveries
132CONCAT(OC, confCHECKPOINT_INTERVAL)
133
134# default delivery mode
135CONCAT(Od, confDELIVERY_MODE)
136
137# automatically rebuild the alias database?
138CONCAT(OD, confAUTO_REBUILD)
139
140# error message header/file */
141ifdef(`confERROR_MESSAGE',
142	concat(OE, confERROR_MESSAGE),
143	#OE/etc/sendmail.oE)
144
145# error mode
146ifdef(`confERROR_MODE',
147	concat(Oe, confERROR_MODE),
148	#Oep)
149
150# save Unix-style "From_" lines at top of header?
151CONCAT(Of, confSAVE_FROM_LINES)
152
153# temporary file mode
154CONCAT(OF, confTEMP_FILE_MODE)
155
156# match recipients against GECOS field?
157CONCAT(OG, confMATCH_GECOS)
158
159# default GID
160CONCAT(Og, confDEF_GROUP_ID)
161
162# maximum hop count
163CONCAT(Oh, confMAX_HOP)
164
165# location of help file
166CONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf))
167
168# ignore dots as terminators in incoming messages?
169CONCAT(Oi, confIGNORE_DOTS)
170
171# Insist that the BIND name server be running to resolve names
172ifdef(`confBIND_OPTS',
173	CONCAT(OI, confBIND_OPTS),
174	#OI)
175
176# Forward file search path
177ifdef(`confFORWARD_PATH',
178	CONCAT(OJ, confFORWARD_PATH),
179	#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
180
181# open connection cache size
182CONCAT(Ok, confMCI_CACHE_SIZE)
183
184# open connection cache timeout
185CONCAT(OK, confMCI_CACHE_TIMEOUT)
186
187# log level
188CONCAT(OL, confLOG_LEVEL)
189
190# send to me too, even in an alias expansion?
191CONCAT(Om, confME_TOO)
192
193# verify RHS in newaliases?
194CONCAT(On, confCHECK_ALIASES)
195
196# default messages to old style headers if no special punctuation?
197CONCAT(Oo, confOLD_STYLE_HEADERS)
198
199# SMTP daemon options
200ifdef(`confDAEMON_OPTIONS',
201	CONCAT(OO, confDAEMON_OPTIONS),
202	#OOPort=esmtp)
203
204# privacy flags
205CONCAT(Op, confPRIVACY_FLAGS)
206
207# who (if anyone) should get extra copies of error messages
208ifdef(`confCOPY_ERRORS_TO',
209	CONCAT(OP, confCOPY_ERRORS_TO),
210	#OPPostmaster)
211
212# slope of queue-only function
213ifdef(`confQUEUE_FACTOR',
214	CONCAT(Oq, confQUEUE_FACTOR),
215	#Oq600000)
216
217# queue directory
218CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
219
220# read timeout -- now OK per RFC 1123 section 5.3.2
221ifdef(`confREAD_TIMEOUT',
222	CONCAT(Or, confREAD_TIMEOUT),
223	#Ordatablock=10m)
224
225# queue up everything before forking?
226CONCAT(Os, confSAFE_QUEUE)
227
228# status file
229CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
230
231# default message timeout interval
232CONCAT(OT, confMESSAGE_TIMEOUT)
233
234# time zone handling:
235#  if undefined, use system default
236#  if defined but null, use TZ envariable passed in
237#  if defined and non-null, use that info
238ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
239	confTIME_ZONE, `USE_TZ', `',
240	`CONCAT(Ot, confTIME_ZONE)')
241
242# default UID
243CONCAT(Ou, confDEF_USER_ID)
244
245# list of locations of user database file (null means no lookup)
246OU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
247
248# fallback MX host
249ifdef(`confFALLBACK_MX',
250	CONCAT(OV, confFALLBACK_MX),
251	#OVfall.back.host.net)
252
253# load average at which we just queue messages
254CONCAT(Ox, confQUEUE_LA)
255
256# load average at which we refuse connections
257CONCAT(OX, confREFUSE_LA)
258
259# work recipient factor
260ifdef(`confWORK_RECIPIENT_FACTOR',
261	CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
262	#Oy30000)
263
264# deliver each queued job in a separate process?
265CONCAT(OY, confSEPARATE_PROC)
266
267# work class factor
268ifdef(`confWORK_CLASS_FACTOR',
269	CONCAT(Oz, confWORK_CLASS_FACTOR),
270	#Oz1800)
271
272# work time factor
273ifdef(`confWORK_TIME_FACTOR',
274	CONCAT(OZ, confWORK_TIME_FACTOR),
275	#OZ90000)
276
277###########################
278#   Message precedences   #
279###########################
280
281Pfirst-class=0
282Pspecial-delivery=100
283Plist=-30
284Pbulk=-60
285Pjunk=-100
286
287#####################
288#   Trusted users   #
289#####################
290
291Troot
292Tdaemon
293Tuucp
294
295#########################
296#   Format of headers   #
297#########################
298
299H?P?Return-Path: $g
300HReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z) id $i; $b
301H?D?Resent-Date: $a
302H?D?Date: $a
303H?F?Resent-From: $q
304H?F?From: $q
305H?x?Full-Name: $x
306HSubject:
307# HPosted-Date: $a
308# H?l?Received-Date: $b
309H?M?Resent-Message-Id: <$t.$i@$j>
310H?M?Message-Id: <$t.$i@$j>
311#
312######################################################################
313######################################################################
314#####
315#####			REWRITING RULES
316#####
317######################################################################
318######################################################################
319
320undivert(9)dnl
321
322###########################################
323###  Rulset 3 -- Name Canonicalization  ###
324###########################################
325S3
326
327# handle null input and list syntax (translate to <@> special case)
328R$@			$@ <@>
329R$*:;$*			$@ $1 :; <@>
330
331# basic textual canonicalization -- note RFC733 heuristic here
332R$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
333R$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
334R$*<>$*			$@ <@>				MAIL FROM:<> case
335R$*<$+>$*		$2				basic RFC821/822 parsing
336
337# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
338R@ $+ , $+		@ $1 : $2			change all "," to ":"
339
340# localize and dispose of route-based addresses
341R@ $+ : $+		$@ $>6 < @$1 > : $2		handle <route-addr>
342
343# find focus for list syntax
344R $+ : $* ; @ $+	$@ $>6 $1 : $2 ; < @ $3 >	list syntax
345R $+ : $* ;		$@ $1 : $2;			list syntax
346
347# find focus for @ syntax addresses
348R$+ @ $+		$: $1 < @ $2 >			focus on domain
349R$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
350R$+ < @ $+ >		$@ $>6 $1 < @ $2 >		already canonical
351
352ifdef(`_NO_UUCP_', `dnl',
353`# convert old-style addresses to a domain-based address
354R$- ! $+		$@ $>6 $2 < @ $1 .UUCP >	resolve uucp names
355R$+ . $- ! $+		$@ $>6 $3 < @ $1 . $2 >		domain uucps
356R$+ ! $+		$@ $>6 $2 < @ $1 .UUCP >	uucp subdomains')
357
358# if we have % signs, take the rightmost one
359R$* % $*		$1 @ $2				First make them all @s.
360R$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
361R$* @ $*		$@ $>6 $1 < @ $2 >		Insert < > and finish
362
363# else we must be a local name
364
365
366###############################################
367###  Ruleset 6 -- bottom half of ruleset 3  ###
368###############################################
369
370#  At this point, everything should be in a "local_part<@domain>extra" format.
371S6
372
373# handle special cases for local names
374R$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
375R$* < @ $=w . UUCP > $*		$: $1 < @ $j . > $3		.UUCP domain
376undivert(2)dnl
377
378ifdef(`_NO_UUCP_', `dnl',
379`ifdef(`UUCP_RELAY',
380`# pass UUCP addresses straight through
381R$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
382`# if really UUCP, handle it immediately
383ifdef(`_CLASS_U_',
384`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
385ifdef(`_CLASS_V_',
386`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
387ifdef(`_CLASS_W_',
388`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
389ifdef(`_CLASS_X_',
390`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
391ifdef(`_CLASS_Y_',
392`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
393
394# try UUCP traffic as a local address
395R$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
396ifdef(`_OLD_SENDMAIL_',
397`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
398`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
399')
400ifdef(`_NO_CANONIFY_', `dnl',
401`# pass to name server to make hostname canonical
402R$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
403')
404# handle possible alternate names
405R$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
406R$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
407undivert(8)dnl
408
409# if this is the local hostname, make sure we treat is as canonical
410R$* < @ $j > $*			$: $1 < @ $j . > $2
411
412
413##################################################
414###  Ruleset 4 -- Final Output Post-rewriting  ###
415##################################################
416S4
417
418R$*<@>			$@ $1				handle <> and list:;
419
420# resolve numeric addresses to name if possible
421R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
422
423# strip trailing dot off possibly canonical name
424R$* < @ $+ . > $*	$1 < @ $2 > $3
425
426# externalize local domain info
427R$* < $+ > $*		$1 $2 $3			defocus
428R@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
429R@ $*			$@ @ $1				... and exit
430
431ifdef(`_NO_UUCP_', `dnl',
432`# UUCP must always be presented in old form
433R$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
434
435# delete duplicate local names
436R$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
437
438
439
440#############################################################
441###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
442###		   (used for recursive calls)		  ###
443#############################################################
444
445S7
446R$*			$: $>3 $1
447R$*			$@ $>0 $1
448
449
450######################################
451###   Ruleset 0 -- Parse Address   ###
452######################################
453
454S0
455
456R<@>			$#local $: <>			special case error msgs
457
458ifdef(`_MAILER_smtp_',
459`# handle numeric address spec
460R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
461R$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec',
462`dnl')
463
464# now delete the local info -- note $=O to find characters that cause forwarding
465R$* < @ > $*		$@ $>7 $1			user@ => user
466R< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
467R$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
468ifdef(`MAILER_TABLE',
469`
470# try mailer table lookup
471R$* < @ $+ > $*		$: $1 < @ $(mailertable $2 $) > $3
472R$* < @ $-:$+ > $*	$# $2 $@ $3 $: $1 < @ $3 > $4	found a match',
473`dnl')
474
475# short circuit local delivery so forwarded email works
476ifdef(`_LOCAL_NOT_STICKY_',
477`R$=L < @ $j . >		$#local $: @ $1			special local names
478R$+ < @ $j . >		$#local $: $1			dispose directly',
479`R$+ < @ $j . >		$: $1 < @ $j @ $H >		first try hub
480ifdef(`_OLD_SENDMAIL_',
481`R$+ < $+ @ $-:$+ >	$# $3 $@ $4 $: $1 < $2 >	yep ....
482R$+ < $+ @ $+ >		$#relay $@ $3 $: $1 < $2 >	yep ....
483R$+ < $+ @ >		$#local $: $1			nope, local address',
484`R$+ < $+ @ $+ >		$#local $: $1			yep ....
485R$+ < $+ @ >		$#local $: @ $1			nope, local address')')
486undivert(3)dnl
487undivert(4)dnl
488
489# resolve remotely connected UUCP links (if any)
490ifdef(`_CLASS_V_',
491`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
492	`dnl')
493ifdef(`_CLASS_W_',
494`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
495	`dnl')
496ifdef(`_CLASS_X_',
497`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
498	`dnl')
499
500# resolve fake top level domains by forwarding to other hosts
501ifdef(`BITNET_RELAY',
502`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
503	`dnl')
504ifdef(`CSNET_RELAY',
505`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
506	`dnl')
507ifdef(`_MAILER_fax_',
508`R$+ < @ $+ .FAX >	$#fax $@ $2 $: $1			user@host.FAX',
509`ifdef(`FAX_RELAY',
510`R$*<@$+.FAX>$*		$#smtp $@ $F $: $1 <@$2.FAX> $3		user@host.FAX',
511	`dnl')')
512
513ifdef(`UUCP_RELAY',
514`# forward non-local UUCP traffic to our UUCP relay
515R$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
516`ifdef(`_MAILER_uucp_',
517`# forward other UUCP traffic straight to UUCP
518R< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $2			@host.UUCP:...
519R$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
520	`dnl')')
521
522ifdef(`_LOCAL_RULES_',
523`# figure out what should stay in our local mail system
524undivert(1)',
525`ifdef(`_MAILER_smtp_',
526`# deal with other remote names
527R$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain')')
528ifdef(`SMART_HOST', `
529# pass names that still have a host to a smarthost
530R$* < @ $* > $*		$: < $S > $1 < @ $2 > $3	glue on smarthost name
531R<$-:$+> $* < @$* > $*	$# $1 $@ $2 $: $3 < @ $4 > $5	if non-null, use it
532R<$+> $* < @$* > $*	$#suucp $@ $1 $: $2 < @ $3 > $4	if non-null, use it
533R<> $* < @ $* > $*	$1 < @ $2 > $3			else strip off gunk',
534`ifdef(`_LOCAL_RULES_', `
535# reject messages that have host names we do not understand
536R$* < @ $* > $*		$#error $@ NOHOST $: Unrecognized host name $2',
537`dnl')')
538ifdef(`_MAILER_USENET_', `
539# addresses sent to net.group.USENET will get forwarded to a newsgroup
540R$+ . USENET		$# usenet $: $1')
541
542ifdef(`_OLD_SENDMAIL_',
543`# forward remaining names to local relay, if any
544R$=L			$#local $: $1			special local names
545R$+			$: $1 < @ $R >			append relay
546R$+ < @ >		$: $1 < @ $H >			no relay, try hub
547R$+ < @ >		$#local $: $1			no relay or hub: local
548R$+ < @ $j  >		$#local $: $1			we are relay/hub: local
549R$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		deliver to relay/hub
550R$+ < @ $+ >		$#relay $@ $2 $: $1		deliver to relay/hub',
551
552`# if this is quoted, strip the quotes and try again
553R$+			$: $(dequote $1 $)		strip quotes
554R$* $=O $*		$@ $>7 $1 $2 $3			try again
555
556# handle locally delivered names
557R$=L			$#local $: @ $1			special local names
558R$+			$#local $: $1			regular local names
559
560###########################################################################
561###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
562###		   (new sendmail only)					###
563###########################################################################
564
565S5
566
567# see if we have a relay or a hub
568R$+			$: $1 < @ $R >
569R$+ < @ >		$: $1 < @ $H >			no relay, try hub
570R$+ < @ $j >		$@ $1				we are relay/hub: local
571R$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		send to relay or hub
572ifdef(`_MAILER_smtp_',
573`R$+ < @ $+ >		$#relay $@ $2 $: $1		send to relay or hub')')
574#
575######################################################################
576######################################################################
577#####
578`#####			MAILER DEFINITIONS'
579#####
580######################################################################
581######################################################################
582undivert(7)dnl
583