xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 51260)
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*51260SericVERSIONID(@(#)proto.m4	2.4 (Berkeley) 10/02/91)
1251222Seric
1351222Seric
1451222Seric##################
1551222Seric#   local info   #
1651222Seric##################
1751222Seric
1851222Sericifdef(`_USE_CW_FILE_',
1951222Seric`# file containing internet aliases in our primary domain
2051222SericFw/etc/sendmail.cw', `dnl')
2151222Seric
2251222Sericifdef(`UUCP_RELAY',
2351222Seric`# UUCP relay host
2451222SericCONCAT(DU, UUCP_RELAY)
2551222Seric')dnl
2651222Sericifdef(`BITNET_RELAY',
2751222Seric`#  BITNET relay host
2851222SericCONCAT(DB, BITNET_RELAY)
2951222Seric')dnl
3051222Sericifdef(`CSNET_RELAY',
3151222Seric`# CSNET relay host
3251222SericCONCAT(DC, CSNET_RELAY)
3351222Seric')dnl
3451222Seric# my official hostname ($w or $w.$D)
3551222SericDj$w
3651222Seric
3751222Seric# who I masquerade as (can be $j)
3851222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
3951222Seric
4051222Seric# who I send unqualified names to (null means deliver locally)
4151222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
4251222Seric
4351222Sericifdef(`UUCP_NAME',
44*51260Seric`# uucp hostnames
4551222SericUUCP_NAME
4651222SericUUCP_ALIASES
4751222Seric
4851222Seric# local UUCP connections
49*51260Sericinclude(UUCP_HOSTS_FILE)',
5051244Seric`dnl')
5151222Seric
5251222Seric# operators that cannot be in local usernames (i.e., network indicators)
5351222SericCO @ % !
5451222Seric
5551244Sericifdef(`USERDB_FILE',
5651244Seric`# location of user database file (null means no lookup)
57*51260SericCONCAT(`OU', USERDB_FILE)',
58*51260Seric`dnl')
5951222Seric
6051222Sericifdef(`_NO_WILDCARD_MX_',
6151222Seric`# we can guarantee no wildcard MX records matching our domain
62*51260SericOw',
63*51260Seric`dnl')
6451222Seric
6551222Sericinclude(`../m4/version.m4')
6651222Seric
67*51260Sericifdef(`INTERNET_RELAY',
68*51260Seric`include(../sitedep/nicregistered.m4)',
69*51260Seric`dnl')
7051222Sericinclude(`../m4/boilerplate.m4')
7151222Seric#
7251222Seric######################################################################
7351222Seric######################################################################
7451222Seric#####
7551222Seric#####			REWRITING RULES
7651222Seric#####
7751222Seric######################################################################
7851222Seric######################################################################
7951222Seric
8051222Seric
8151222Seric###########################################
8251222Seric###  Rulset 3 -- Name Canonicalization  ###
8351222Seric###########################################
84*51260SericS3
8551222Seric
8651222Seric# handle "from:<>" special case
8751222SericR$*<>$*			$@@				turn into magic token
8851222Seric
8951222Seric# basic textual canonicalization -- note RFC733 heuristic here
9051222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
9151222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
9251222SericR$*<$+>$*		$2				basic RFC821/822 parsing
9351222Seric
9451222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
9551222SericR@$+,$+			@$1:$2				change all "," to ":"
9651222Seric
9751222Seric# localize and dispose of route-based addresses
9851222SericR@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
9951222Seric
10051222Seric# find focus for list syntax
10151222SericR$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
10251222SericR$+:$*;			$@$1:$2;			list syntax
10351222Seric
10451222Seric# find focus for @ syntax addresses
10551222SericR$+@$+			$:$1<@$2>			focus on domain
10651222SericR$+<$+@$+>		$1$2<@$3>			move gaze right
10751222SericR$+<@$+>		$@$>6$1<@$2>			already canonical
10851222Seric
10951222Seric# convert old-style addresses to a domain-based address
11051222SericR$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
11151222SericR$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
11251222SericR$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
11351222Seric
11451222Seric# if we have % signs, take the rightmost one
11551222SericR$*%$*			$1@$2				First make them all @s.
11651222SericR$*@$*@$*		$1%$2@$3			Undo all but the last.
11751222SericR$*@$*			$@$>6$1<@$2>			Insert < > and finish
11851222Seric
11951222Seric# else we must be a local name
12051222Seric
12151222Seric
12251222Seric###############################################
12351222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
12451222Seric###############################################
12551222Seric
12651222Seric#  At this point, everything should be in a local_part@domain format.
12751222Seric
12851222SericS6
12951222Sericundivert(2)dnl
13051222Seric
13151222Seric# handle special cases for local names
13251222SericR$*<@$=w>$*		$:$1<@$w>$3			no domain at all
13351222SericR$*<@$=w.UUCP>$*	$:$1<@$w>$3			.UUCP domain
13451222Seric
13551222Seric# pass to name server to make hostname canonical
13651222SericR$* < @ $+ > $*		$: $1 < @ $[ $2 $] > $3		then do anything
13751222Seric
13851222Seric# hack to add local domain if nothing sofar has done so
13951222SericR$* < @ $- > $*		$: $1 < @ $2 @ $w > $3		throw on local host
14051222SericR$* < @ $- @ $- $* > $*	$: $1 < @ $2 $4 > $5		strip host part only
14151222Seric
14251222Seric
14351222Seric##################################################
14451222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
14551222Seric##################################################
14651222SericS4
14751222Seric
14851222SericR@			$@				handle <> error addr
14951222Seric
15051222Seric# resolve numeric addresses to name if possible
15151222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		lookup numeric internet addr
15251222Seric
15351222Seric# externalize local domain info
15451222SericR$*<$+>$*		$1$2$3				defocus
15551222SericR@$+:@$+:$+		@$1,@$2:$3			<route-addr> canonical
15651222Seric
15751222Seric# UUCP must always be presented in old form
15851222SericR$+@$-.UUCP		$2!$1				u@h.UUCP => h!u
15951222Seric
16051222Seric# delete duplicate local names
16151222SericR$+%$=w@$=w		$1@$w				u%host@host => u@host
16251222Seric
16351222Seric
16451222Seric
16551222Seric#############################################################
16651222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
16751222Seric###		   (used for recursive calls)		  ###
16851222Seric#############################################################
16951222Seric
17051222SericS7
17151222SericR$*			$: $>3 $1
17251222SericR$*			$@ $>0 $1
17351222Seric
17451222Seric
17551222Seric######################################
17651222Seric###   Ruleset 0 -- Parse Address   ###
17751222Seric######################################
17851222Seric
17951222SericS0
18051222Seric
18151222Seric# handle numeric address spec
18251222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		numeric internet addr
18351222SericR$*<@[$+]>$*		$#smtp$@[$2]$:$1@[$2]$3		numeric internet spec
18451222Seric
18551222Seric#R@			$#error$:Invalid address	handle <> form
18651222Seric
18751222Seric# now delete the local info -- note $=O to find characters that cause forwarding
18851222SericR<@$w>:$*		$@$>7$1				@here:... -> ...
18951222SericR$*$=O$*<@$w>		$@$>7$1$2$3			...@here -> ...
19051222Seric
19151222Seric# short circuit local delivery so forwarded email works
19251222SericR$+<@$w>		$#local$:$1			local address
19351222Seric
19451222Sericundivert(3)dnl
19551222Seric
196*51260Sericundivert(4)dnl
197*51260Seric
198*51260Seric# resolve remotely connected UUCP links
199*51260SericR$* < @ $=W . UUCP > $*		$#smtp $@ $W $: $1<@$2.UUCP>$3
200*51260SericR$* < @ $=X . UUCP > $*		$#smtp $@ $X $: $1<@$2.UUCP>$3
201*51260SericR$* < @ $=Y . UUCP > $*		$#smtp $@ $Y $: $1<@$2.UUCP>$3
202*51260Seric
20351222Seric# resolve fake top level domains by forwarding to other hosts
20451222Sericifdef(`BITNET_RELAY',
20551222Seric`R$*<@$+.BITNET>$*	$#smtp$@$B$:$1<@$2.BITNET>$3		user@host.BITNET',
20651222Seric	`dnl')
20751222Sericifdef(`CSNET_RELAY',
20851222Seric`R$*<@$+.CSNET>$*	$#smtp$@$C$:$1<@$2.CSNET>$3		user@host.CSNET',
20951222Seric	`dnl')
21051222Seric
211*51260Sericifdef(`UUCP_RELAY',
212*51260Seric`# forward non-local UUCP traffic to our UUCP relay
213*51260SericR$*<@$*.UUCP>$*		$#smtp$@$U$:$1<@$2.UUCP>		uucp mail',
214*51260Seric`ifdef(`_UUCP_LINKED_',
215*51260Seric`# forward other UUCP traffic straight to UUCP
216*51260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
217*51260SericR$+ < @ $+ .UUCP>	$#uucp $@ $2 $: $1			user@host.UUCP',
218*51260Seric	`dnl')')
21951222Seric
220*51260Seric# deal with other remote names
22151222SericR$* < @ $* > $*		$# smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
22251222Seric
22351222Seric# see if we forward local names
22451222SericR$=L			$# local $: $1			special local names
22551222SericR$+			$: $1 @ $R
22651222SericR$+ @			$: $1				no, we don't
22751222SericR$+ @ $+		$# smtp $@ $2 $: $1		yes, we do
22851222Seric
22951222Seric# remaining names must be local
23051222SericR$+			$#local$:$1			everything else
23151222Seric
23251222Seric#
23351222Seric######################################################################
23451222Seric######################################################################
23551222Seric#####
23651222Seric#####			MAILER DEFINITIONS
23751222Seric#####
23851222Seric######################################################################
23951222Seric######################################################################
24051222Seric
24151222Sericundivert(7)dnl
242