xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 51997)
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*51997SericVERSIONID(@(#)proto.m4	2.20 (Berkeley) 12/17/91)
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1551222Seric##################
1651222Seric#   local info   #
1751222Seric##################
1851222Seric
1951889SericCwlocalhost
2051887Sericifdef(`USE_CW_FILE',
2151889Seric`# file containing names of hosts for which we receive email
2251222SericFw/etc/sendmail.cw', `dnl')
2351222Seric
2451222Sericifdef(`UUCP_RELAY',
2551222Seric`# UUCP relay host
2651281SericCONCAT(DY, UUCP_RELAY)
2751222Seric')dnl
2851222Sericifdef(`BITNET_RELAY',
2951222Seric`#  BITNET relay host
3051222SericCONCAT(DB, BITNET_RELAY)
3151222Seric')dnl
3251222Sericifdef(`CSNET_RELAY',
3351222Seric`# CSNET relay host
3451222SericCONCAT(DC, CSNET_RELAY)
3551222Seric')dnl
3651222Seric# my official hostname ($w or $w.$D)
3751291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
3851222Seric
3951222Seric# who I masquerade as (can be $j)
4051222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
4151222Seric
4251222Seric# who I send unqualified names to (null means deliver locally)
4351222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
4451222Seric
4551279Seric# names that should be delivered locally, even if we have a relay
4651279SericCLroot
4751279Sericundivert(5)dnl
4851889Sericundivert(6)dnl
4951279Seric
5051222Sericifdef(`UUCP_NAME',
5151260Seric`# uucp hostnames
5251222SericUUCP_NAME
5351222SericUUCP_ALIASES
5451222Seric
5551222Seric# local UUCP connections
5651260Sericinclude(UUCP_HOSTS_FILE)',
5751244Seric`dnl')
5851222Seric
5951222Seric# operators that cannot be in local usernames (i.e., network indicators)
6051222SericCO @ % !
6151222Seric
6251322Seric# a class with just dot (for identifying canonical names)
6351322SericC..
6451322Seric
6551887Seric# list of locations of user database file (null means no lookup)
6651887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
6751222Seric
6851887Seric# set if we can guarantee no wildcard MX records matching our domain
6951887Sericifdef(`_NO_WILDCARD_MX_', `', `#')Ow
7051222Seric
7151992Sericifdef(`_OLD_SENDMAIL_', `dnl',
7251322Seric`# level 2 config file format
7351992SericO=2')
7451322Seric
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
9751222SericR$*<>$*			$@@				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
10551222SericR@$+,$+			@$1:$2				change all "," to ":"
10651222Seric
10751222Seric# localize and dispose of route-based addresses
10851222SericR@$+:$+			$@$>6<@$1>:$2			handle <route-addr>
10951222Seric
11051222Seric# find focus for list syntax
11151222SericR$+:$*;@$+		$@$>6$1:$2;<@$3>		list syntax
11251222SericR$+:$*;			$@$1:$2;			list syntax
11351222Seric
11451222Seric# find focus for @ syntax addresses
11551222SericR$+@$+			$:$1<@$2>			focus on domain
11651222SericR$+<$+@$+>		$1$2<@$3>			move gaze right
11751222SericR$+<@$+>		$@$>6$1<@$2>			already canonical
11851222Seric
11951222Seric# convert old-style addresses to a domain-based address
12051222SericR$-!$+			$@$>6$2<@$1.UUCP>		resolve uucp names
12151222SericR$+.$-!$+		$@$>6$3<@$1.$2>			domain uucps
12251222SericR$+!$+			$@$>6$2<@$1.UUCP>		uucp subdomains
12351222Seric
12451222Seric# if we have % signs, take the rightmost one
12551222SericR$*%$*			$1@$2				First make them all @s.
12651222SericR$*@$*@$*		$1%$2@$3			Undo all but the last.
12751222SericR$*@$*			$@$>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
14251322SericR$* < @ $=w .UUCP> $*		$: $1 < @ $j . > $3		.UUCP domain
14351889Sericundivert(2)dnl
14451222Seric
14551274Sericifdef(`UUCP_RELAY',
14651274Seric`# pass UUCP addresses straight through
14751274SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 .UUCP > $3',
14851274Seric`# if really UUCP, handle it immediately
14951322Sericifdef(`_CLASS_U_',
15051322Seric`R$* < @ $=U . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15151322Sericifdef(`_CLASS_V_',
15251322Seric`R$* < @ $=V . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15351322Sericifdef(`_CLASS_W_',
15451322Seric`R$* < @ $=W . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15551322Sericifdef(`_CLASS_X_',
15651322Seric`R$* < @ $=X . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15751322Sericifdef(`_CLASS_Y_',
15851322Seric`R$* < @ $=Y . UUCP > $*		$@ $1 < @ $2 .UUCP > $3', `dnl')
15951267Seric
16051267Seric# try UUCP traffic as a local address
16151322SericR$* < @ $+ .UUCP > $*			$: $1 < @ $[ $2 $] .UUCP > $3
16251992Sericifdef(`_OLD_SENDMAIL_',
16351992Seric`R$* < @ $+ . $+ .UUCP > $*		$@ $1 < @ $2 . $3 > $4',
16451993Seric`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
194*51997SericR@ $*			$@ @ $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
22051222Seric# handle numeric address spec
22151322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
22251322SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec
22351222Seric
22451222Seric#R@			$#error$:Invalid address	handle <> form
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
23751260Seric# resolve remotely connected UUCP links
23851285Sericifdef(`_CLASS_V_',
23951285Seric`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: $1<@$2.UUCP>$3', `dnl')
24051285Sericifdef(`_CLASS_W_',
24151285Seric`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: $1<@$2.UUCP>$3', `dnl')
24251285Sericifdef(`_CLASS_X_',
24351285Seric`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: $1<@$2.UUCP>$3', `dnl')
24451260Seric
24551222Seric# resolve fake top level domains by forwarding to other hosts
24651222Sericifdef(`BITNET_RELAY',
24751222Seric`R$*<@$+.BITNET>$*	$#smtp$@$B$:$1<@$2.BITNET>$3		user@host.BITNET',
24851222Seric	`dnl')
24951222Sericifdef(`CSNET_RELAY',
25051222Seric`R$*<@$+.CSNET>$*	$#smtp$@$C$:$1<@$2.CSNET>$3		user@host.CSNET',
25151222Seric	`dnl')
25251222Seric
25351260Sericifdef(`UUCP_RELAY',
25451260Seric`# forward non-local UUCP traffic to our UUCP relay
25551281SericR$*<@$*.UUCP>$*		$#smtp$@$Y$:$1<@$2.UUCP>		uucp mail',
25651260Seric`ifdef(`_UUCP_LINKED_',
25751260Seric`# forward other UUCP traffic straight to UUCP
25851260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
25951322SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
26051260Seric	`dnl')')
26151222Seric
26251260Seric# deal with other remote names
26351222SericR$* < @ $* > $*		$# smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
26451222Seric
26551992Sericifdef(`_OLD_SENDMAIL_',
26651887Seric`# forward remaining names to local relay, if any
26751887SericR$+			$: $1 < @ $R >
26851887SericR$+ < @ >		$# local $: $1
26951992SericR$+ < @ $+ >		$# smtp $@ $2 $: $1',
27051992Seric`# handle locally delivered names
27151992SericR$=L			$# local $: @ $1		special local names
27251992SericR$+			$# local $: $1			regular local names')
27351222Seric
27451992Sericifdef(`_OLD_SENDMAIL_', `dnl',
27551322Seric`#
27651322Seric# special rewriting after aliases have been expanded
27751322Seric#
27851222Seric
27951322SericS5
28051322Seric
28151887SericR$+			$: $1 < @ $R >
28251887SericR$+ < @ $+ >		$# smtp $@ $2 $: $1		send to relay')
28351222Seric#
28451222Seric######################################################################
28551222Seric######################################################################
28651222Seric#####
28751222Seric#####			MAILER DEFINITIONS
28851222Seric#####
28951222Seric######################################################################
29051222Seric######################################################################
29151222Sericundivert(7)dnl
292