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