xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 51279)
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*51279SericVERSIONID(@(#)proto.m4	2.8 (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
43*51279Seric# names that should be delivered locally, even if we have a relay
44*51279SericCLroot
45*51279Sericundivert(5)dnl
46*51279Seric
4751222Sericifdef(`UUCP_NAME',
4851260Seric`# uucp hostnames
4951222SericUUCP_NAME
5051222SericUUCP_ALIASES
5151222Seric
5251222Seric# local UUCP connections
5351260Sericinclude(UUCP_HOSTS_FILE)',
5451244Seric`dnl')
5551222Seric
5651222Seric# operators that cannot be in local usernames (i.e., network indicators)
5751222SericCO @ % !
5851222Seric
5951244Sericifdef(`USERDB_FILE',
6051244Seric`# location of user database file (null means no lookup)
6151260SericCONCAT(`OU', USERDB_FILE)',
6251260Seric`dnl')
6351222Seric
6451222Sericifdef(`_NO_WILDCARD_MX_',
6551222Seric`# we can guarantee no wildcard MX records matching our domain
6651260SericOw',
6751260Seric`dnl')
6851222Seric
6951222Sericinclude(`../m4/version.m4')
7051222Seric
7151260Sericifdef(`INTERNET_RELAY',
7251260Seric`include(../sitedep/nicregistered.m4)',
7351260Seric`dnl')
7451222Sericinclude(`../m4/boilerplate.m4')
7551222Seric#
7651222Seric######################################################################
7751222Seric######################################################################
7851222Seric#####
7951222Seric#####			REWRITING RULES
8051222Seric#####
8151222Seric######################################################################
8251222Seric######################################################################
8351222Seric
8451222Seric
8551222Seric###########################################
8651222Seric###  Rulset 3 -- Name Canonicalization  ###
8751222Seric###########################################
8851260SericS3
8951222Seric
9051222Seric# handle "from:<>" special case
9151222SericR$*<>$*			$@@				turn into magic token
9251222Seric
9351222Seric# basic textual canonicalization -- note RFC733 heuristic here
9451222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
9551222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
9651222SericR$*<$+>$*		$2				basic RFC821/822 parsing
9751222Seric
9851222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
9951222SericR@$+,$+			@$1:$2				change all "," to ":"
10051222Seric
10151222Seric# localize and dispose of route-based addresses
10251222SericR@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
10351222Seric
10451222Seric# find focus for list syntax
10551222SericR$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
10651222SericR$+:$*;			$@$1:$2;			list syntax
10751222Seric
10851222Seric# find focus for @ syntax addresses
10951222SericR$+@$+			$:$1<@$2>			focus on domain
11051222SericR$+<$+@$+>		$1$2<@$3>			move gaze right
11151222SericR$+<@$+>		$@$>6$1<@$2>			already canonical
11251222Seric
11351222Seric# convert old-style addresses to a domain-based address
11451222SericR$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
11551222SericR$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
11651222SericR$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
11751222Seric
11851222Seric# if we have % signs, take the rightmost one
11951222SericR$*%$*			$1@$2				First make them all @s.
12051222SericR$*@$*@$*		$1%$2@$3			Undo all but the last.
12151222SericR$*@$*			$@$>6$1<@$2>			Insert < > and finish
12251222Seric
12351222Seric# else we must be a local name
12451222Seric
12551222Seric
12651222Seric###############################################
12751222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
12851222Seric###############################################
12951222Seric
13051222Seric#  At this point, everything should be in a local_part@domain format.
13151222Seric
13251222SericS6
13351222Sericundivert(2)dnl
13451222Seric
13551222Seric# handle special cases for local names
13651267SericR$* < @ $=w > $*		$: $1 < @ $w > $3		no domain at all
13751267SericR$* < @ $=w .UUCP> $*		$: $1 < @ $w > $3		.UUCP domain
13851222Seric
13951274Sericifdef(`UUCP_RELAY',
14051274Seric`# pass UUCP addresses straight through
14151274SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 .UUCP > $3',
14251274Seric`# if really UUCP, handle it immediately
14351267SericR$* < @ $=U . UUCP > $*		$@ $1 < @ $2 .UUCP > $3
14451267SericR$* < @ $=V . UUCP > $*		$@ $1 < @ $2 .UUCP > $3
14551267SericR$* < @ $=W . UUCP > $*		$@ $1 < @ $2 .UUCP > $3
14651267SericR$* < @ $=X . UUCP > $*		$@ $1 < @ $2 .UUCP > $3
14751267SericR$* < @ $=Y . UUCP > $*		$@ $1 < @ $2 .UUCP > $3
14851267Seric
14951267Seric# try UUCP traffic as a local address
15051267SericR$* < @ $- .UUCP > $*		$: $1 < @ $[ $2 $] .UUCP > $3
15151274SericR$* < @ $+ . $+ .UUCP > $*	$@ $1 < @ $2 . $3 > $4')
15251267Seric
15351222Seric# pass to name server to make hostname canonical
15451267SericR$* < @ $+ > $*			$: $1 < @ $[ $2 $] > $3		then do anything
15551222Seric
15651222Seric
15751222Seric##################################################
15851222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
15951222Seric##################################################
16051222SericS4
16151222Seric
16251222SericR@			$@				handle <> error addr
16351222Seric
16451222Seric# resolve numeric addresses to name if possible
16551222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		lookup numeric internet addr
16651222Seric
16751222Seric# externalize local domain info
16851222SericR$*<$+>$*		$1$2$3				defocus
16951222SericR@$+:@$+:$+		@$1,@$2:$3			<route-addr> canonical
17051222Seric
17151222Seric# UUCP must always be presented in old form
17251222SericR$+@$-.UUCP		$2!$1				u@h.UUCP => h!u
17351222Seric
17451222Seric# delete duplicate local names
17551222SericR$+%$=w@$=w		$1@$w				u%host@host => u@host
17651222Seric
17751222Seric
17851222Seric
17951222Seric#############################################################
18051222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
18151222Seric###		   (used for recursive calls)		  ###
18251222Seric#############################################################
18351222Seric
18451222SericS7
18551222SericR$*			$: $>3 $1
18651222SericR$*			$@ $>0 $1
18751222Seric
18851222Seric
18951222Seric######################################
19051222Seric###   Ruleset 0 -- Parse Address   ###
19151222Seric######################################
19251222Seric
19351222SericS0
19451222Seric
19551222Seric# handle numeric address spec
19651222SericR$*<@[$+]>$*		$:$1<@$[[$2]$]>$3		numeric internet addr
19751222SericR$*<@[$+]>$*		$#smtp$@[$2]$:$1@[$2]$3		numeric internet spec
19851222Seric
19951222Seric#R@			$#error$:Invalid address	handle <> form
20051222Seric
20151222Seric# now delete the local info -- note $=O to find characters that cause forwarding
20251222SericR<@$w>:$*		$@$>7$1				@here:... -> ...
20351222SericR$*$=O$*<@$w>		$@$>7$1$2$3			...@here -> ...
20451222Seric
20551222Seric# short circuit local delivery so forwarded email works
20651222SericR$+<@$w>		$#local$:$1			local address
20751222Seric
20851222Sericundivert(3)dnl
20951222Seric
21051260Sericundivert(4)dnl
21151260Seric
21251260Seric# resolve remotely connected UUCP links
21351260SericR$* < @ $=W . UUCP > $*		$#smtp $@ $W $: $1<@$2.UUCP>$3
21451260SericR$* < @ $=X . UUCP > $*		$#smtp $@ $X $: $1<@$2.UUCP>$3
21551260SericR$* < @ $=Y . UUCP > $*		$#smtp $@ $Y $: $1<@$2.UUCP>$3
21651260Seric
21751222Seric# resolve fake top level domains by forwarding to other hosts
21851222Sericifdef(`BITNET_RELAY',
21951222Seric`R$*<@$+.BITNET>$*	$#smtp$@$B$:$1<@$2.BITNET>$3		user@host.BITNET',
22051222Seric	`dnl')
22151222Sericifdef(`CSNET_RELAY',
22251222Seric`R$*<@$+.CSNET>$*	$#smtp$@$C$:$1<@$2.CSNET>$3		user@host.CSNET',
22351222Seric	`dnl')
22451222Seric
22551260Sericifdef(`UUCP_RELAY',
22651260Seric`# forward non-local UUCP traffic to our UUCP relay
22751260SericR$*<@$*.UUCP>$*		$#smtp$@$U$:$1<@$2.UUCP>		uucp mail',
22851260Seric`ifdef(`_UUCP_LINKED_',
22951260Seric`# forward other UUCP traffic straight to UUCP
23051260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
23151260SericR$+ < @ $+ .UUCP>	$#uucp $@ $2 $: $1			user@host.UUCP',
23251260Seric	`dnl')')
23351222Seric
23451260Seric# deal with other remote names
23551222SericR$* < @ $* > $*		$# smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
23651222Seric
23751222Seric# see if we forward local names
23851222SericR$=L			$# local $: $1			special local names
23951222SericR$+			$: $1 @ $R
24051222SericR$+ @			$: $1				no, we don't
24151222SericR$+ @ $+		$# smtp $@ $2 $: $1		yes, we do
24251222Seric
24351222Seric# remaining names must be local
24451222SericR$+			$#local$:$1			everything else
24551222Seric
24651222Seric#
24751222Seric######################################################################
24851222Seric######################################################################
24951222Seric#####
25051222Seric#####			MAILER DEFINITIONS
25151222Seric#####
25251222Seric######################################################################
25351222Seric######################################################################
25451222Seric
25551222Sericundivert(7)dnl
256