xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 51887)
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*51887SericVERSIONID(@(#)proto.m4	2.16 (Berkeley) 12/12/91)
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1551222Seric##################
1651222Seric#   local info   #
1751222Seric##################
1851222Seric
19*51887Sericifdef(`USE_CW_FILE',
2051222Seric`# file containing internet aliases in our primary domain
2151222SericFw/etc/sendmail.cw', `dnl')
2251222Seric
2351222Sericifdef(`UUCP_RELAY',
2451222Seric`# UUCP relay host
2551281SericCONCAT(DY, UUCP_RELAY)
2651222Seric')dnl
2751222Sericifdef(`BITNET_RELAY',
2851222Seric`#  BITNET relay host
2951222SericCONCAT(DB, BITNET_RELAY)
3051222Seric')dnl
3151222Sericifdef(`CSNET_RELAY',
3251222Seric`# CSNET relay host
3351222SericCONCAT(DC, CSNET_RELAY)
3451222Seric')dnl
3551222Seric# my official hostname ($w or $w.$D)
3651291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
3751222Seric
3851222Seric# who I masquerade as (can be $j)
3951222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
4051222Seric
4151222Seric# who I send unqualified names to (null means deliver locally)
4251222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
4351222Seric
4451279Seric# names that should be delivered locally, even if we have a relay
4551279SericCLroot
4651279Sericundivert(5)dnl
4751279Seric
4851222Sericifdef(`UUCP_NAME',
4951260Seric`# uucp hostnames
5051222SericUUCP_NAME
5151222SericUUCP_ALIASES
5251222Seric
5351222Seric# local UUCP connections
5451260Sericinclude(UUCP_HOSTS_FILE)',
5551244Seric`dnl')
5651222Seric
5751222Seric# operators that cannot be in local usernames (i.e., network indicators)
5851222SericCO @ % !
5951222Seric
6051322Seric# a class with just dot (for identifying canonical names)
6151322SericC..
6251322Seric
63*51887Seric# list of locations of user database file (null means no lookup)
64*51887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
6551222Seric
66*51887Seric# set if we can guarantee no wildcard MX records matching our domain
67*51887Sericifdef(`_NO_WILDCARD_MX_', `', `#')Ow
6851222Seric
6951322Sericifdef(`NEWSENDMAIL',
7051322Seric`# level 2 config file format
7151322SericO=2', `dnl')
7251322Seric
73*51887Seric# if new sendmail and we want to ignore UDB for fully qualified user names
74*51887Seric# (e.g., "user@thishost" instead of "user"), set this to "@", else set to null
75*51887SericCONCAT(`DO', ifdef(`NEWSENDMAIL', ifdef(`ALWAYS_USE_UDB', `', `@')))
76*51887Seric
7751222Sericinclude(`../m4/version.m4')
7851222Seric
7951260Sericifdef(`INTERNET_RELAY',
8051260Seric`include(../sitedep/nicregistered.m4)',
8151260Seric`dnl')
8251222Sericinclude(`../m4/boilerplate.m4')
8351222Seric#
8451222Seric######################################################################
8551222Seric######################################################################
8651222Seric#####
8751222Seric#####			REWRITING RULES
8851222Seric#####
8951222Seric######################################################################
9051222Seric######################################################################
9151222Seric
9251222Seric
9351222Seric###########################################
9451222Seric###  Rulset 3 -- Name Canonicalization  ###
9551222Seric###########################################
9651260SericS3
9751222Seric
9851222Seric# handle "from:<>" special case
9951222SericR$*<>$*			$@@				turn into magic token
10051222Seric
10151222Seric# basic textual canonicalization -- note RFC733 heuristic here
10251222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
10351222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
10451222SericR$*<$+>$*		$2				basic RFC821/822 parsing
10551222Seric
10651222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
10751222SericR@$+,$+			@$1:$2				change all "," to ":"
10851222Seric
10951222Seric# localize and dispose of route-based addresses
11051222SericR@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
11151222Seric
11251222Seric# find focus for list syntax
11351222SericR$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
11451222SericR$+:$*;			$@$1:$2;			list syntax
11551222Seric
11651222Seric# find focus for @ syntax addresses
11751222SericR$+@$+			$:$1<@$2>			focus on domain
11851222SericR$+<$+@$+>		$1$2<@$3>			move gaze right
11951222SericR$+<@$+>		$@$>6$1<@$2>			already canonical
12051222Seric
12151222Seric# convert old-style addresses to a domain-based address
12251222SericR$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
12351222SericR$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
12451222SericR$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
12551222Seric
12651222Seric# if we have % signs, take the rightmost one
12751222SericR$*%$*			$1@$2				First make them all @s.
12851222SericR$*@$*@$*		$1%$2@$3			Undo all but the last.
12951222SericR$*@$*			$@$>6$1<@$2>			Insert < > and finish
13051222Seric
13151222Seric# else we must be a local name
13251222Seric
13351222Seric
13451222Seric###############################################
13551222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
13651222Seric###############################################
13751222Seric
13851222Seric#  At this point, everything should be in a local_part@domain format.
13951222Seric
14051222SericS6
14151222Sericundivert(2)dnl
14251222Seric
14351222Seric# handle special cases for local names
14451322SericR$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
14551322SericR$* < @ $=w .UUCP> $*		$: $1 < @ $j . > $3		.UUCP domain
14651222Seric
14751274Sericifdef(`UUCP_RELAY',
14851274Seric`# pass UUCP addresses straight through
14951274SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 .UUCP > $3',
15051274Seric`# if really UUCP, handle it immediately
15151322Sericifdef(`_CLASS_U_',
15251322Seric`R$* < @ $=U . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15351322Sericifdef(`_CLASS_V_',
15451322Seric`R$* < @ $=V . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15551322Sericifdef(`_CLASS_W_',
15651322Seric`R$* < @ $=W . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15751322Sericifdef(`_CLASS_X_',
15851322Seric`R$* < @ $=X . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15951322Sericifdef(`_CLASS_Y_',
16051322Seric`R$* < @ $=Y . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
16151267Seric
16251267Seric# try UUCP traffic as a local address
16351322SericR$* < @ $+ .UUCP > $*			$: $1 < @ $[ $2 $] .UUCP > $3
16451322Sericifdef(`NEWSENDMAIL',
16551322Seric`R$* < @ $+ . .UUCP > $*		$@ $1 < @ $2 . > $3',
16651322Seric`R$* < @ $+ . $+ .UUCP > $*		$@ $1 < @ $2 . $3 > $4')')
16751267Seric
16851222Seric# pass to name server to make hostname canonical
16951322SericR$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
17051222Seric
17151322Seric# if this is the local hostname, make sure we treat is as canonical
17251322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
17351222Seric
17451322Seric
17551222Seric##################################################
17651222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
17751222Seric##################################################
17851222SericS4
17951222Seric
18051222SericR@			$@				handle <> error addr
18151222Seric
18251222Seric# resolve numeric addresses to name if possible
18351322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
18451222Seric
18551322Seric# strip trailing dot off possibly canonical name
18651322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
18751322Seric
18851222Seric# externalize local domain info
18951322SericR$* < $+ > $*		$1 $2 $3			defocus
19051322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
19151222Seric
19251222Seric# UUCP must always be presented in old form
19351322SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u
19451222Seric
19551222Seric# delete duplicate local names
19651322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
19751222Seric
19851222Seric
19951222Seric
20051222Seric#############################################################
20151222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
20251222Seric###		   (used for recursive calls)		  ###
20351222Seric#############################################################
20451222Seric
20551222SericS7
20651222SericR$*			$: $>3 $1
20751222SericR$*			$@ $>0 $1
20851222Seric
20951222Seric
21051222Seric######################################
21151222Seric###   Ruleset 0 -- Parse Address   ###
21251222Seric######################################
21351222Seric
21451222SericS0
21551222Seric
21651222Seric# handle numeric address spec
21751322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
21851322SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec
21951222Seric
22051222Seric#R@			$#error$:Invalid address	handle <> form
22151222Seric
222*51887Seric# now delete the local info -- note $=O to find characters that cause forwarding
22351322SericR< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
22451322SericR$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
22551222Seric
22651222Seric# short circuit local delivery so forwarded email works
227*51887SericR$+ < @ $j . >		$#local $: $O $1		local address
22851222Seric
22951222Sericundivert(3)dnl
23051222Seric
23151260Sericundivert(4)dnl
23251260Seric
23351260Seric# resolve remotely connected UUCP links
23451285Sericifdef(`_CLASS_V_',
23551285Seric`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl')
23651285Sericifdef(`_CLASS_W_',
23751285Seric`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl')
23851285Sericifdef(`_CLASS_X_',
23951285Seric`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl')
24051260Seric
24151222Seric# resolve fake top level domains by forwarding to other hosts
24251222Sericifdef(`BITNET_RELAY',
24351222Seric`R$*<@$+.BITNET>$*	$#smtp$@$B$:$1<@$2.BITNET>$3		user@host.BITNET',
24451222Seric	`dnl')
24551222Sericifdef(`CSNET_RELAY',
24651222Seric`R$*<@$+.CSNET>$*	$#smtp$@$C$:$1<@$2.CSNET>$3		user@host.CSNET',
24751222Seric	`dnl')
24851222Seric
24951260Sericifdef(`UUCP_RELAY',
25051260Seric`# forward non-local UUCP traffic to our UUCP relay
25151281SericR$*<@$*.UUCP>$*		$#smtp$@$Y$:$1<@$2.UUCP>		uucp mail',
25251260Seric`ifdef(`_UUCP_LINKED_',
25351260Seric`# forward other UUCP traffic straight to UUCP
25451260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
25551322SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
25651260Seric	`dnl')')
25751222Seric
25851260Seric# deal with other remote names
25951222SericR$* < @ $* > $*		$# smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
26051222Seric
26151322Sericifdef(`NEWSENDMAIL',
26251322Seric`# handle locally delivered names
263*51887SericR$=L			$# local $: $O $1		special local names
26451322SericR$+			$# local $: $1			regular local names
265*51887Seric',
266*51887Seric`# forward remaining names to local relay, if any
267*51887SericR$+			$: $1 < @ $R >
268*51887SericR$+ < @ >		$# local $: $1
269*51887SericR$+ < @ $+ >		$# smtp $@ $2 $: $1')
27051222Seric
271*51887Sericifdef(`NEWSENDMAIL',
27251322Seric`#
27351322Seric# special rewriting after aliases have been expanded
27451322Seric#
27551222Seric
27651322SericS5
27751322Seric
278*51887SericR$+			$: $1 < @ $R >
279*51887SericR$+ < @ $+ >		$# smtp $@ $2 $: $1		send to relay')
28051222Seric#
28151222Seric######################################################################
28251222Seric######################################################################
28351222Seric#####
28451222Seric#####			MAILER DEFINITIONS
28551222Seric#####
28651222Seric######################################################################
28751222Seric######################################################################
28851222Seric
28951222Sericundivert(7)dnl
290