xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision 70c898fa)
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.38 (Berkeley) 05/11/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# strip message body to 7 bits on input?
114CONCAT(O7, confSEVEN_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# deliver MIME-encapsulated error messages?
177CONCAT(Oj, confMIME_FORMAT_ERRORS)
178
179# Forward file search path
180ifdef(`confFORWARD_PATH',
181	CONCAT(OJ, confFORWARD_PATH),
182	#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
183
184# open connection cache size
185CONCAT(Ok, confMCI_CACHE_SIZE)
186
187# open connection cache timeout
188CONCAT(OK, confMCI_CACHE_TIMEOUT)
189
190# log level
191CONCAT(OL, confLOG_LEVEL)
192
193# send to me too, even in an alias expansion?
194CONCAT(Om, confME_TOO)
195
196# verify RHS in newaliases?
197CONCAT(On, confCHECK_ALIASES)
198
199# default messages to old style headers if no special punctuation?
200CONCAT(Oo, confOLD_STYLE_HEADERS)
201
202# SMTP daemon options
203ifdef(`confDAEMON_OPTIONS',
204	CONCAT(OO, confDAEMON_OPTIONS),
205	#OOPort=esmtp)
206
207# privacy flags
208CONCAT(Op, confPRIVACY_FLAGS)
209
210# who (if anyone) should get extra copies of error messages
211ifdef(`confCOPY_ERRORS_TO',
212	CONCAT(OP, confCOPY_ERRORS_TO),
213	#OPPostmaster)
214
215# slope of queue-only function
216ifdef(`confQUEUE_FACTOR',
217	CONCAT(Oq, confQUEUE_FACTOR),
218	#Oq600000)
219
220# queue directory
221CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
222
223# read timeout -- now OK per RFC 1123 section 5.3.2
224ifdef(`confREAD_TIMEOUT',
225	CONCAT(Or, confREAD_TIMEOUT),
226	#Ordatablock=10m)
227
228# queue up everything before forking?
229CONCAT(Os, confSAFE_QUEUE)
230
231# status file
232CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
233
234# default message timeout interval
235CONCAT(OT, confMESSAGE_TIMEOUT)
236
237# time zone handling:
238#  if undefined, use system default
239#  if defined but null, use TZ envariable passed in
240#  if defined and non-null, use that info
241ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
242	confTIME_ZONE, `USE_TZ', `',
243	`CONCAT(Ot, confTIME_ZONE)')
244
245# default UID
246CONCAT(Ou, confDEF_USER_ID)
247
248# list of locations of user database file (null means no lookup)
249OU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
250
251# fallback MX host
252ifdef(`confFALLBACK_MX',
253	CONCAT(OV, confFALLBACK_MX),
254	#OVfall.back.host.net)
255
256# load average at which we just queue messages
257CONCAT(Ox, confQUEUE_LA)
258
259# load average at which we refuse connections
260CONCAT(OX, confREFUSE_LA)
261
262# work recipient factor
263ifdef(`confWORK_RECIPIENT_FACTOR',
264	CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
265	#Oy30000)
266
267# deliver each queued job in a separate process?
268CONCAT(OY, confSEPARATE_PROC)
269
270# work class factor
271ifdef(`confWORK_CLASS_FACTOR',
272	CONCAT(Oz, confWORK_CLASS_FACTOR),
273	#Oz1800)
274
275# work time factor
276ifdef(`confWORK_TIME_FACTOR',
277	CONCAT(OZ, confWORK_TIME_FACTOR),
278	#OZ90000)
279
280###########################
281#   Message precedences   #
282###########################
283
284Pfirst-class=0
285Pspecial-delivery=100
286Plist=-30
287Pbulk=-60
288Pjunk=-100
289
290#####################
291#   Trusted users   #
292#####################
293
294Troot
295Tdaemon
296Tuucp
297
298#########################
299#   Format of headers   #
300#########################
301
302H?P?Return-Path: $g
303HReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z) id $i; $b
304H?D?Resent-Date: $a
305H?D?Date: $a
306H?F?Resent-From: $q
307H?F?From: $q
308H?x?Full-Name: $x
309HSubject:
310# HPosted-Date: $a
311# H?l?Received-Date: $b
312H?M?Resent-Message-Id: <$t.$i@$j>
313H?M?Message-Id: <$t.$i@$j>
314#
315######################################################################
316######################################################################
317#####
318#####			REWRITING RULES
319#####
320######################################################################
321######################################################################
322
323undivert(9)dnl
324
325###########################################
326###  Rulset 3 -- Name Canonicalization  ###
327###########################################
328S3
329
330# handle null input and list syntax (translate to <@> special case)
331R$@			$@ <@>
332R$*:;$*			$@ $1 :; <@>
333
334# basic textual canonicalization -- note RFC733 heuristic here
335R$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
336R$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
337R$*<>$*			$@ <@>				MAIL FROM:<> case
338R$*<$+>$*		$2				basic RFC821/822 parsing
339
340# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
341R@ $+ , $+		@ $1 : $2			change all "," to ":"
342
343# localize and dispose of route-based addresses
344R@ $+ : $+		$@ $>6 < @$1 > : $2		handle <route-addr>
345
346# find focus for list syntax
347R $+ : $* ; @ $+	$@ $>6 $1 : $2 ; < @ $3 >	list syntax
348R $+ : $* ;		$@ $1 : $2;			list syntax
349
350# find focus for @ syntax addresses
351R$+ @ $+		$: $1 < @ $2 >			focus on domain
352R$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
353R$+ < @ $+ >		$@ $>6 $1 < @ $2 >		already canonical
354
355ifdef(`_NO_UUCP_', `dnl',
356`# convert old-style addresses to a domain-based address
357R$- ! $+		$@ $>6 $2 < @ $1 .UUCP >	resolve uucp names
358R$+ . $- ! $+		$@ $>6 $3 < @ $1 . $2 >		domain uucps
359R$+ ! $+		$@ $>6 $2 < @ $1 .UUCP >	uucp subdomains')
360
361# if we have % signs, take the rightmost one
362R$* % $*		$1 @ $2				First make them all @s.
363R$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
364R$* @ $*		$@ $>6 $1 < @ $2 >		Insert < > and finish
365
366# else we must be a local name
367
368
369###############################################
370###  Ruleset 6 -- bottom half of ruleset 3  ###
371###############################################
372
373#  At this point, everything should be in a "local_part<@domain>extra" format.
374S6
375
376# handle special cases for local names
377R$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
378R$* < @ $=w . UUCP > $*		$: $1 < @ $j . > $3		.UUCP domain
379undivert(2)dnl
380
381ifdef(`_NO_UUCP_', `dnl',
382`ifdef(`UUCP_RELAY',
383`# pass UUCP addresses straight through
384R$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
385`# if really UUCP, handle it immediately
386ifdef(`_CLASS_U_',
387`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
388ifdef(`_CLASS_V_',
389`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
390ifdef(`_CLASS_W_',
391`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
392ifdef(`_CLASS_X_',
393`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
394ifdef(`_CLASS_Y_',
395`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
396
397# try UUCP traffic as a local address
398R$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
399ifdef(`_OLD_SENDMAIL_',
400`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
401`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
402')
403ifdef(`_NO_CANONIFY_', `dnl',
404`# pass to name server to make hostname canonical
405R$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
406')
407# handle possible alternate names
408R$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
409R$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
410undivert(8)dnl
411
412# if this is the local hostname, make sure we treat is as canonical
413R$* < @ $j > $*			$: $1 < @ $j . > $2
414
415
416##################################################
417###  Ruleset 4 -- Final Output Post-rewriting  ###
418##################################################
419S4
420
421R$*<@>			$@ $1				handle <> and list:;
422
423# resolve numeric addresses to name if possible
424R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
425
426# strip trailing dot off possibly canonical name
427R$* < @ $+ . > $*	$1 < @ $2 > $3
428
429# externalize local domain info
430R$* < $+ > $*		$1 $2 $3			defocus
431R@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
432R@ $*			$@ @ $1				... and exit
433
434ifdef(`_NO_UUCP_', `dnl',
435`# UUCP must always be presented in old form
436R$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
437
438# delete duplicate local names
439R$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
440
441
442
443#############################################################
444###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
445###		   (used for recursive calls)		  ###
446#############################################################
447
448S7
449R$*			$: $>3 $1
450R$*			$@ $>0 $1
451
452
453######################################
454###   Ruleset 0 -- Parse Address   ###
455######################################
456
457S0
458
459R<@>			$#local $: <>			special case error msgs
460R$*:;<@>		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
461
462ifdef(`_MAILER_smtp_',
463`# handle numeric address spec
464R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
465R$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec',
466`dnl')
467
468# now delete the local info -- note $=O to find characters that cause forwarding
469R$* < @ > $*		$@ $>7 $1			user@ => user
470R< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
471R$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
472ifdef(`MAILER_TABLE',
473`
474# try mailer table lookup
475R$* < @ $+ > $*		$: $1 < @ $(mailertable $2 $) > $3
476R$* < @ $-:$+ > $*	$# $2 $@ $3 $: $1 < @ $3 > $4	found a match',
477`dnl')
478
479# short circuit local delivery so forwarded email works
480ifdef(`_LOCAL_NOT_STICKY_',
481`R$=L < @ $j . >		$#local $: @ $1			special local names
482R$+ < @ $j . >		$#local $: $1			dispose directly',
483`R$+ < @ $j . >		$: $1 < @ $j @ $H >		first try hub
484ifdef(`_OLD_SENDMAIL_',
485`R$+ < $+ @ $-:$+ >	$# $3 $@ $4 $: $1 < $2 >	yep ....
486R$+ < $+ @ $+ >		$#relay $@ $3 $: $1 < $2 >	yep ....
487R$+ < $+ @ >		$#local $: $1			nope, local address',
488`R$+ < $+ @ $+ >		$#local $: $1			yep ....
489R$+ < $+ @ >		$#local $: @ $1			nope, local address')')
490undivert(3)dnl
491undivert(4)dnl
492
493# resolve remotely connected UUCP links (if any)
494ifdef(`_CLASS_V_',
495`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
496	`dnl')
497ifdef(`_CLASS_W_',
498`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
499	`dnl')
500ifdef(`_CLASS_X_',
501`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
502	`dnl')
503
504# resolve fake top level domains by forwarding to other hosts
505ifdef(`BITNET_RELAY',
506`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
507	`dnl')
508ifdef(`CSNET_RELAY',
509`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
510	`dnl')
511ifdef(`_MAILER_fax_',
512`R$+ < @ $+ .FAX >	$#fax $@ $2 $: $1			user@host.FAX',
513`ifdef(`FAX_RELAY',
514`R$*<@$+.FAX>$*		$#smtp $@ $F $: $1 <@$2.FAX> $3		user@host.FAX',
515	`dnl')')
516
517ifdef(`UUCP_RELAY',
518`# forward non-local UUCP traffic to our UUCP relay
519R$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
520`ifdef(`_MAILER_uucp_',
521`# forward other UUCP traffic straight to UUCP
522R< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $2			@host.UUCP:...
523R$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
524	`dnl')')
525
526ifdef(`_LOCAL_RULES_',
527`# figure out what should stay in our local mail system
528undivert(1)',
529`ifdef(`_MAILER_smtp_',
530`# deal with other remote names
531R$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain')')
532ifdef(`SMART_HOST', `
533# pass names that still have a host to a smarthost
534R$* < @ $* > $*		$: < $S > $1 < @ $2 > $3	glue on smarthost name
535R<$-:$+> $* < @$* > $*	$# $1 $@ $2 $: $3 < @ $4 > $5	if non-null, use it
536R<$+> $* < @$* > $*	$#suucp $@ $1 $: $2 < @ $3 > $4	if non-null, use it
537R<> $* < @ $* > $*	$1 < @ $2 > $3			else strip off gunk',
538`ifdef(`_LOCAL_RULES_', `
539# reject messages that have host names we do not understand
540R$* < @ $* > $*		$#error $@ NOHOST $: Unrecognized host name $2',
541`dnl')')
542ifdef(`_MAILER_USENET_', `
543# addresses sent to net.group.USENET will get forwarded to a newsgroup
544R$+ . USENET		$# usenet $: $1')
545
546ifdef(`_OLD_SENDMAIL_',
547`# forward remaining names to local relay, if any
548R$=L			$#local $: $1			special local names
549R$+			$: $1 < @ $R >			append relay
550R$+ < @ >		$: $1 < @ $H >			no relay, try hub
551R$+ < @ >		$#local $: $1			no relay or hub: local
552R$+ < @ $j  >		$#local $: $1			we are relay/hub: local
553R$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		deliver to relay/hub
554R$+ < @ $+ >		$#relay $@ $2 $: $1		deliver to relay/hub',
555
556`# if this is quoted, strip the quotes and try again
557R$+			$: $(dequote $1 $)		strip quotes
558R$* $=O $*		$@ $>7 $1 $2 $3			try again
559
560# handle locally delivered names
561R$=L			$#local $: @ $1			special local names
562R$+			$#local $: $1			regular local names
563
564###########################################################################
565###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
566###		   (new sendmail only)					###
567###########################################################################
568
569S5
570
571# see if we have a relay or a hub
572R$+			$: $1 < @ $R >
573R$+ < @ >		$: $1 < @ $H >			no relay, try hub
574R$+ < @ $j >		$@ $1				we are relay/hub: local
575R$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		send to relay or hub
576ifdef(`_MAILER_smtp_',
577`R$+ < @ $+ >		$#relay $@ $2 $: $1		send to relay or hub')')
578#
579######################################################################
580######################################################################
581#####
582`#####			MAILER DEFINITIONS'
583#####
584######################################################################
585######################################################################
586undivert(7)dnl
587