xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 55416)
151222Sericdivert(-1)
251222Seric#
351222Seric# Copyright (c) 1983 Eric P. Allman
451222Seric# Copyright (c) 1988 The Regents of the University of California.
551222Seric# All rights reserved.
651222Seric#
751222Seric# %sccs.include.redist.sh%
851222Seric#
951222Sericdivert(0)
1051222Seric
11*55416SericVERSIONID(@(#)proto.m4	2.26 (Berkeley) 07/20/92)
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1552646Sericifdef(`_OLD_SENDMAIL_', `dnl',
1652646Seric`# level 3 config file format
1752646SericV3')
1852646Seric
1951222Seric##################
2051222Seric#   local info   #
2151222Seric##################
2251222Seric
2351889SericCwlocalhost
2451887Sericifdef(`USE_CW_FILE',
2551889Seric`# file containing names of hosts for which we receive email
2651222SericFw/etc/sendmail.cw', `dnl')
2751222Seric
2851222Sericifdef(`UUCP_RELAY',
2951222Seric`# UUCP relay host
3051281SericCONCAT(DY, UUCP_RELAY)
3151222Seric')dnl
3251222Sericifdef(`BITNET_RELAY',
3351222Seric`#  BITNET relay host
3451222SericCONCAT(DB, BITNET_RELAY)
3551222Seric')dnl
3651222Sericifdef(`CSNET_RELAY',
3751222Seric`# CSNET relay host
3851222SericCONCAT(DC, CSNET_RELAY)
3951222Seric')dnl
4051222Seric# my official hostname ($w or $w.$D)
4151291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
4251222Seric
4351222Seric# who I masquerade as (can be $j)
4451222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
4551222Seric
4651222Seric# who I send unqualified names to (null means deliver locally)
4751222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
4851222Seric
4951279Seric# names that should be delivered locally, even if we have a relay
5051279SericCLroot
5151279Sericundivert(5)dnl
5251889Sericundivert(6)dnl
5351279Seric
5451222Sericifdef(`UUCP_NAME',
5551260Seric`# uucp hostnames
5651222SericUUCP_NAME
5751222SericUUCP_ALIASES
5851222Seric
5951222Seric# local UUCP connections
6051260Sericinclude(UUCP_HOSTS_FILE)',
6151244Seric`dnl')
6251222Seric
6351222Seric# operators that cannot be in local usernames (i.e., network indicators)
6451222SericCO @ % !
6551222Seric
6651322Seric# a class with just dot (for identifying canonical names)
6751322SericC..
6851322Seric
6951887Seric# list of locations of user database file (null means no lookup)
7051887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
7151222Seric
7251887Seric# set if we can guarantee no wildcard MX records matching our domain
7352108SericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False')
7451222Seric
7551222Sericinclude(`../m4/version.m4')
7651222Seric
7751260Sericifdef(`INTERNET_RELAY',
7851260Seric`include(../sitedep/nicregistered.m4)',
7951260Seric`dnl')
8051222Sericinclude(`../m4/boilerplate.m4')
8151222Seric#
8251222Seric######################################################################
8351222Seric######################################################################
8451222Seric#####
8551222Seric#####			REWRITING RULES
8651222Seric#####
8751222Seric######################################################################
8851222Seric######################################################################
8951222Seric
9051222Seric
9151222Seric###########################################
9251222Seric###  Rulset 3 -- Name Canonicalization  ###
9351222Seric###########################################
9451260SericS3
9551222Seric
9651222Seric# handle "from:<>" special case
97*55416SericR$* < > $*		$@ @				turn into magic token
9851222Seric
9951222Seric# basic textual canonicalization -- note RFC733 heuristic here
10051222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
10151222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
10251222SericR$*<$+>$*		$2				basic RFC821/822 parsing
10351222Seric
10451222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
105*55416SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
10651222Seric
10751222Seric# localize and dispose of route-based addresses
108*55416SericR@ $+ : $+		$@ $>6 < @$1 > : $2		handle <route-addr>
10951222Seric
11051222Seric# find focus for list syntax
111*55416SericR $+ : $* ; @ $+	$@ $>6 $1 : $2 ; < @ $3 >	list syntax
112*55416SericR $+ : $* ;		$@ $1 : $2;			list syntax
11351222Seric
11451222Seric# find focus for @ syntax addresses
115*55416SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
116*55416SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
117*55416SericR$+ < @ $+ >		$@ $>6 $1 < @ $2 >		already canonical
11851222Seric
11951222Seric# convert old-style addresses to a domain-based address
120*55416SericR$- ! $+		$@ $>6 $2 < @ $1 .UUCP >	resolve uucp names
121*55416SericR$+ . $- ! $+		$@ $>6 $3 < @ $1 . $2 >		domain uucps
122*55416SericR$+ ! $+		$@ $>6 $2 < @ $1 .UUCP >	uucp subdomains
12351222Seric
12451222Seric# if we have % signs, take the rightmost one
125*55416SericR$* % $*		$1 @ $2				First make them all @s.
126*55416SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
127*55416SericR$* @ $*		$@ $>6 $1 < @ $2 >		Insert < > and finish
12851222Seric
12951222Seric# else we must be a local name
13051222Seric
13151222Seric
13251222Seric###############################################
13351222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
13451222Seric###############################################
13551222Seric
13651222Seric#  At this point, everything should be in a local_part@domain format.
13751222Seric
13851222SericS6
13951222Seric
14051222Seric# handle special cases for local names
14151322SericR$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
142*55416SericR$* < @ $=w . UUCP > $*		$: $1 < @ $j . > $3		.UUCP domain
14351889Sericundivert(2)dnl
14451222Seric
14551274Sericifdef(`UUCP_RELAY',
14651274Seric`# pass UUCP addresses straight through
147*55416SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
14851274Seric`# if really UUCP, handle it immediately
14951322Sericifdef(`_CLASS_U_',
150*55416Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15151322Sericifdef(`_CLASS_V_',
152*55416Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15351322Sericifdef(`_CLASS_W_',
154*55416Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15551322Sericifdef(`_CLASS_X_',
156*55416Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15751322Sericifdef(`_CLASS_Y_',
158*55416Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15951267Seric
16051267Seric# try UUCP traffic as a local address
161*55416SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
16251992Sericifdef(`_OLD_SENDMAIL_',
163*55416Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
164*55416Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
16551267Seric
16651222Seric# pass to name server to make hostname canonical
16751322SericR$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
16851222Seric
16951889Seric# handle possible alternate names
17051889SericR$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
17151889SericR$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
17251889Sericundivert(8)dnl
17351889Seric
17451322Seric# if this is the local hostname, make sure we treat is as canonical
17551322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
17651222Seric
17751322Seric
17851222Seric##################################################
17951222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
18051222Seric##################################################
18151222SericS4
18251222Seric
18351222SericR@			$@				handle <> error addr
18451222Seric
18551222Seric# resolve numeric addresses to name if possible
18651322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
18751222Seric
18851322Seric# strip trailing dot off possibly canonical name
18951322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
19051322Seric
19151222Seric# externalize local domain info
19251322SericR$* < $+ > $*		$1 $2 $3			defocus
19351322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
19451997SericR@ $*			$@ @ $1				... and exit
19551222Seric
19651222Seric# UUCP must always be presented in old form
19751322SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u
19851222Seric
19951222Seric# delete duplicate local names
20051322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
20151222Seric
20251222Seric
20351222Seric
20451222Seric#############################################################
20551222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
20651222Seric###		   (used for recursive calls)		  ###
20751222Seric#############################################################
20851222Seric
20951222SericS7
21051222SericR$*			$: $>3 $1
21151222SericR$*			$@ $>0 $1
21251222Seric
21351222Seric
21451222Seric######################################
21551222Seric###   Ruleset 0 -- Parse Address   ###
21651222Seric######################################
21751222Seric
21851222SericS0
21951222Seric
220*55416Sericifdef(`_MAILER_smtp_',
221*55416Seric`# handle numeric address spec
22251322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
223*55416SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec',
224*55416Seric`dnl')dnl
22551222Seric
22651887Seric# now delete the local info -- note $=O to find characters that cause forwarding
22751322SericR< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
22851322SericR$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
22951222Seric
23051222Seric# short circuit local delivery so forwarded email works
23151992Sericifdef(`_OLD_SENDMAIL_',
23251992Seric`R$+ < @ $j . >		$#local $: $1			local address',
23351992Seric`R$+ < @ $j . >		$#local $: @ $1			local address')
23451222Sericundivert(3)dnl
23551260Sericundivert(4)dnl
23651260Seric
237*55416Seric# resolve remotely connected UUCP links (if any)
23851285Sericifdef(`_CLASS_V_',
23952044Seric`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
24052044Seric	`dnl')
24151285Sericifdef(`_CLASS_W_',
24252044Seric`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
24352044Seric	`dnl')
24451285Sericifdef(`_CLASS_X_',
24552044Seric`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
24652044Seric	`dnl')
24751260Seric
24851222Seric# resolve fake top level domains by forwarding to other hosts
24951222Sericifdef(`BITNET_RELAY',
25052044Seric`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
25151222Seric	`dnl')
25251222Sericifdef(`CSNET_RELAY',
25352044Seric`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
25451222Seric	`dnl')
25551222Seric
25651260Sericifdef(`UUCP_RELAY',
25751260Seric`# forward non-local UUCP traffic to our UUCP relay
25852044SericR$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
259*55416Seric`ifdef(`_MAILER_uucp_',
26051260Seric`# forward other UUCP traffic straight to UUCP
26151260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
26251322SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
26351260Seric	`dnl')')
26451222Seric
265*55416Sericifdef(`_MAILER_smtp_',
266*55416Seric`# deal with other remote names
26752041SericR$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
268*55416Seric', `dnl')
26951222Seric
27051992Sericifdef(`_OLD_SENDMAIL_',
27151887Seric`# forward remaining names to local relay, if any
27252041SericR$=L			$#local $: $1			special local names
27352041SericR$+			$: $1 < @ $R >			append relay
27452041SericR$+ < @ >		$#local $: $1			if no relay, local
27552044SericR$+ < @ $+ >		$#smtp $@ $2 $: $1		deliver to relay',
27651992Seric`# handle locally delivered names
27752041SericR$=L			$#local $: @ $1			special local names
27852041SericR$+			$#local $: $1			regular local names
27951222Seric
280*55416Seric###########################################################################
281*55416Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
282*55416Seric###		   (new sendmail only)					###
283*55416Seric###########################################################################
28451222Seric
28551322SericS5
28651322Seric
287*55416Sericifdef(`_MAILER_smtp_',
288*55416Seric`R$+			$: $1 < @ $R >
289*55416SericR$+ < @ $+ >		$#smtp $@ $2 $: $1 < @ $2 >	send to relay')',
290*55416Seric`dnl')
29151222Seric#
29251222Seric######################################################################
29351222Seric######################################################################
29451222Seric#####
29551222Seric#####			MAILER DEFINITIONS
29651222Seric#####
29751222Seric######################################################################
29851222Seric######################################################################
29951222Sericundivert(7)dnl
300