xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision 525ff8d9)
16f4c5567Sericdivert(-1)
26f4c5567Seric#
36f4c5567Seric# Copyright (c) 1983 Eric P. Allman
46f4c5567Seric# Copyright (c) 1988 The Regents of the University of California.
56f4c5567Seric# All rights reserved.
66f4c5567Seric#
76f4c5567Seric# %sccs.include.redist.sh%
86f4c5567Seric#
96f4c5567Sericdivert(0)
106f4c5567Seric
11*525ff8d9SericVERSIONID(`@(#)proto.m4	6.2 (Berkeley) 01/13/93')
126f4c5567Seric
1363eeb308SericMAILER(local)dnl
146f4c5567Seric
15472f2a37Sericifdef(`_OLD_SENDMAIL_', `dnl',
16472f2a37Seric`# level 3 config file format
17472f2a37SericV3')
18472f2a37Seric
196f4c5567Seric##################
206f4c5567Seric#   local info   #
216f4c5567Seric##################
226f4c5567Seric
2331695942SericCwlocalhost
24b1286b66Sericifdef(`USE_CW_FILE',
2531695942Seric`# file containing names of hosts for which we receive email
266f4c5567SericFw/etc/sendmail.cw', `dnl')
276f4c5567Seric
286f4c5567Sericifdef(`UUCP_RELAY',
296f4c5567Seric`# UUCP relay host
3013c6b009SericCONCAT(DY, UUCP_RELAY)
316f4c5567Seric')dnl
326f4c5567Sericifdef(`BITNET_RELAY',
336f4c5567Seric`#  BITNET relay host
346f4c5567SericCONCAT(DB, BITNET_RELAY)
356f4c5567Seric')dnl
366f4c5567Sericifdef(`CSNET_RELAY',
376f4c5567Seric`# CSNET relay host
386f4c5567SericCONCAT(DC, CSNET_RELAY)
396f4c5567Seric')dnl
406f4c5567Seric# my official hostname ($w or $w.$D)
41b47d0647SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
426f4c5567Seric
436f4c5567Seric# who I masquerade as (can be $j)
446f4c5567SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
456f4c5567Seric
466f4c5567Seric# who I send unqualified names to (null means deliver locally)
476f4c5567SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
486f4c5567Seric
49*525ff8d9Seric# who gets all local email traffic ($R has precedence for unqualified names)
50*525ff8d9SericCONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
51*525ff8d9Seric
5282027dd5Seric# class L: names that should be delivered locally, even if we have a relay
5382027dd5Seric# class E: names that should be exposed as from this host, even if we masquerade
5471dc253dSericCLroot
5582027dd5SericCEroot
5671dc253dSericundivert(5)dnl
5771dc253dSeric
586f4c5567Seric# operators that cannot be in local usernames (i.e., network indicators)
596f4c5567SericCO @ % !
606f4c5567Seric
6163eeb308Seric# a class with just dot (for identifying canonical names)
6263eeb308SericC..
6363eeb308Seric
64b1286b66Seric# list of locations of user database file (null means no lookup)
65b1286b66SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
666f4c5567Seric
67b1286b66Seric# set if we can guarantee no wildcard MX records matching our domain
680a276cdfSericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False')
696f4c5567Seric
706f4c5567Sericinclude(`../m4/version.m4')
716f4c5567Sericinclude(`../m4/boilerplate.m4')
72c97ed732Sericundivert(6)dnl
736f4c5567Seric#
746f4c5567Seric######################################################################
756f4c5567Seric######################################################################
766f4c5567Seric#####
776f4c5567Seric#####			REWRITING RULES
786f4c5567Seric#####
796f4c5567Seric######################################################################
806f4c5567Seric######################################################################
816f4c5567Seric
826f4c5567Seric
836f4c5567Seric###########################################
846f4c5567Seric###  Rulset 3 -- Name Canonicalization  ###
856f4c5567Seric###########################################
8671e1a4d1SericS3
876f4c5567Seric
886f4c5567Seric# handle "from:<>" special case
896f4c5567SericR$* < > $*		$@ @				turn into magic token
906f4c5567Seric
916f4c5567Seric# basic textual canonicalization -- note RFC733 heuristic here
927b2c0d8dSericR$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
936f4c5567SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
946f4c5567SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
956f4c5567SericR$*<$+>$*		$2				basic RFC821/822 parsing
966f4c5567Seric
976f4c5567Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
986f4c5567SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
996f4c5567Seric
1006f4c5567Seric# localize and dispose of route-based addresses
1016f4c5567SericR@ $+ : $+		$@ $>6 < @$1 > : $2		handle <route-addr>
1026f4c5567Seric
1036f4c5567Seric# find focus for list syntax
1046f4c5567SericR $+ : $* ; @ $+	$@ $>6 $1 : $2 ; < @ $3 >	list syntax
1056f4c5567SericR $+ : $* ;		$@ $1 : $2;			list syntax
1066f4c5567Seric
1076f4c5567Seric# find focus for @ syntax addresses
1086f4c5567SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
1096f4c5567SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
1106f4c5567SericR$+ < @ $+ >		$@ $>6 $1 < @ $2 >		already canonical
1116f4c5567Seric
1126f4c5567Seric# convert old-style addresses to a domain-based address
1136f4c5567SericR$- ! $+		$@ $>6 $2 < @ $1 .UUCP >	resolve uucp names
1146f4c5567SericR$+ . $- ! $+		$@ $>6 $3 < @ $1 . $2 >		domain uucps
1156f4c5567SericR$+ ! $+		$@ $>6 $2 < @ $1 .UUCP >	uucp subdomains
1166f4c5567Seric
1176f4c5567Seric# if we have % signs, take the rightmost one
1186f4c5567SericR$* % $*		$1 @ $2				First make them all @s.
1196f4c5567SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
1206f4c5567SericR$* @ $*		$@ $>6 $1 < @ $2 >		Insert < > and finish
1216f4c5567Seric
1226f4c5567Seric# else we must be a local name
1236f4c5567Seric
1246f4c5567Seric
1256f4c5567Seric###############################################
1266f4c5567Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
1276f4c5567Seric###############################################
1286f4c5567Seric
12982027dd5Seric#  At this point, everything should be in a "local_part<@domain>extra" format.
1306f4c5567SericS6
1316f4c5567Seric
1326f4c5567Seric# handle special cases for local names
13363eeb308SericR$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
13463eeb308SericR$* < @ $=w . UUCP > $*		$: $1 < @ $j . > $3		.UUCP domain
13531695942Sericundivert(2)dnl
1366f4c5567Seric
137788179f5Sericifdef(`UUCP_RELAY',
138788179f5Seric`# pass UUCP addresses straight through
139788179f5SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
140788179f5Seric`# if really UUCP, handle it immediately
14163eeb308Sericifdef(`_CLASS_U_',
14263eeb308Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14363eeb308Sericifdef(`_CLASS_V_',
14463eeb308Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14563eeb308Sericifdef(`_CLASS_W_',
14663eeb308Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14763eeb308Sericifdef(`_CLASS_X_',
14863eeb308Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14963eeb308Sericifdef(`_CLASS_Y_',
15063eeb308Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
151a027f997Seric
152a027f997Seric# try UUCP traffic as a local address
15363eeb308SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
1544588ece0Sericifdef(`_OLD_SENDMAIL_',
1554cad3747Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
15697777037Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
157a027f997Seric
1586f4c5567Seric# pass to name server to make hostname canonical
15963eeb308SericR$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
16063eeb308Seric
16131695942Seric# handle possible alternate names
16231695942SericR$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
16331695942SericR$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
16431695942Sericundivert(8)dnl
16531695942Seric
16663eeb308Seric# if this is the local hostname, make sure we treat is as canonical
16763eeb308SericR$* < @ $j > $*			$: $1 < @ $j . > $2
1686f4c5567Seric
1696f4c5567Seric
1706f4c5567Seric##################################################
1716f4c5567Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
1726f4c5567Seric##################################################
1736f4c5567SericS4
1746f4c5567Seric
1756f4c5567SericR@			$@				handle <> error addr
1766f4c5567Seric
1776f4c5567Seric# resolve numeric addresses to name if possible
1786f4c5567SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
1796f4c5567Seric
18063eeb308Seric# strip trailing dot off possibly canonical name
18163eeb308SericR$* < @ $+ . > $*	$1 < @ $2 > $3
18263eeb308Seric
1836f4c5567Seric# externalize local domain info
1846f4c5567SericR$* < $+ > $*		$1 $2 $3			defocus
1856f4c5567SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
1861f23b499SericR@ $*			$@ @ $1				... and exit
1876f4c5567Seric
1886f4c5567Seric# UUCP must always be presented in old form
1896f4c5567SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u
1906f4c5567Seric
1916f4c5567Seric# delete duplicate local names
192b47d0647SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
1936f4c5567Seric
1946f4c5567Seric
1956f4c5567Seric
1966f4c5567Seric#############################################################
1976f4c5567Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
1986f4c5567Seric###		   (used for recursive calls)		  ###
1996f4c5567Seric#############################################################
2006f4c5567Seric
2016f4c5567SericS7
2026f4c5567SericR$*			$: $>3 $1
2036f4c5567SericR$*			$@ $>0 $1
2046f4c5567Seric
2056f4c5567Seric
2066f4c5567Seric######################################
2076f4c5567Seric###   Ruleset 0 -- Parse Address   ###
2086f4c5567Seric######################################
2096f4c5567Seric
2106f4c5567SericS0
2116f4c5567Seric
2124cad3747Sericifdef(`_MAILER_smtp_',
2134cad3747Seric`# handle numeric address spec
2146f4c5567SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
2154cad3747SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec',
2163c5c069fSeric`dnl')
2176f4c5567Seric
218b1286b66Seric# now delete the local info -- note $=O to find characters that cause forwarding
21963eeb308SericR< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
22063eeb308SericR$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
2216f4c5567Seric
2226f4c5567Seric# short circuit local delivery so forwarded email works
223*525ff8d9SericR$+ < @ $j . >		$: $1 < @ $j @ $H >		first try hub
2244588ece0Sericifdef(`_OLD_SENDMAIL_',
225*525ff8d9Seric`R$+ < $+ @ $+ >		$#smtp $@ $3 $: $1 < $2 >	yep ....
226*525ff8d9SericR$+ < $+ @ >		$#local $: $1			nope, local address',
227*525ff8d9Seric`R$+ < $+ @ $+ >		$#local $: $1			yep ....
228*525ff8d9SericR$+ < $+ @ >		$#local $: @ $1			nope, local address')
2296f4c5567Sericundivert(3)dnl
23071e1a4d1Sericundivert(4)dnl
23171e1a4d1Seric
2324cad3747Seric# resolve remotely connected UUCP links (if any)
233138c6544Sericifdef(`_CLASS_V_',
2346dafc3b0Seric`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
2356dafc3b0Seric	`dnl')
236138c6544Sericifdef(`_CLASS_W_',
2376dafc3b0Seric`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
2386dafc3b0Seric	`dnl')
239138c6544Sericifdef(`_CLASS_X_',
2406dafc3b0Seric`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
2416dafc3b0Seric	`dnl')
24271e1a4d1Seric
2436f4c5567Seric# resolve fake top level domains by forwarding to other hosts
2446f4c5567Sericifdef(`BITNET_RELAY',
2456f4c5567Seric`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
2466f4c5567Seric	`dnl')
2476f4c5567Sericifdef(`CSNET_RELAY',
2486f4c5567Seric`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
2496f4c5567Seric	`dnl')
2506f4c5567Seric
25171e1a4d1Sericifdef(`UUCP_RELAY',
25271e1a4d1Seric`# forward non-local UUCP traffic to our UUCP relay
2536dafc3b0SericR$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
2544cad3747Seric`ifdef(`_MAILER_uucp_',
25571e1a4d1Seric`# forward other UUCP traffic straight to UUCP
25671e1a4d1SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
25771e1a4d1SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
25871e1a4d1Seric	`dnl')')
2596f4c5567Seric
2604cad3747Sericifdef(`_MAILER_smtp_',
2614cad3747Seric`# deal with other remote names
2626f4c5567SericR$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
2634cad3747Seric', `dnl')
2646f4c5567Seric
2654588ece0Sericifdef(`_OLD_SENDMAIL_',
266b1286b66Seric`# forward remaining names to local relay, if any
267adca7ddbSericR$=L			$#local $: $1			special local names
268adca7ddbSericR$+			$: $1 < @ $R >			append relay
269*525ff8d9SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
270*525ff8d9SericR$+ < @ >		$#local $: $1			no relay or hub: local
271*525ff8d9SericR$+ < @ $j  >		$#local $: $1			we are relay/hub: local
272*525ff8d9SericR$+ < @ $+ >		$#smtp $@ $2 $: $1		deliver to relay/hub',
2734588ece0Seric`# handle locally delivered names
2744588ece0SericR$=L			$#local $: @ $1			special local names
275adca7ddbSericR$+			$#local $: $1			regular local names
2766f4c5567Seric
2774cad3747Seric###########################################################################
2784cad3747Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
2794cad3747Seric###		   (new sendmail only)					###
2804cad3747Seric###########################################################################
2816f4c5567Seric
28263eeb308SericS5
28363eeb308Seric
2844cad3747Sericifdef(`_MAILER_smtp_',
2854cad3747Seric`R$+			$: $1 < @ $R >
286*525ff8d9SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
287*525ff8d9SericR$+ < @ $j >		$@ $1				we are relay/hub: local
288*525ff8d9SericR$+ < @ $+ >		$#smtp $@ $2 $: $1		send to relay or hub')')
2896f4c5567Seric#
2906f4c5567Seric######################################################################
2916f4c5567Seric######################################################################
2926f4c5567Seric#####
2931297e20cSeric`#####			MAILER DEFINITIONS'
2946f4c5567Seric#####
2956f4c5567Seric######################################################################
2966f4c5567Seric######################################################################
2976f4c5567Sericundivert(7)dnl
298