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