xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 57527)
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*57527SericVERSIONID(`@(#)proto.m4	6.2 (Berkeley) 01/13/93')
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
49*57527Seric# who gets all local email traffic ($R has precedence for unqualified names)
50*57527SericCONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
51*57527Seric
5257245Seric# class L: names that should be delivered locally, even if we have a relay
5357245Seric# class E: names that should be exposed as from this host, even if we masquerade
5451279SericCLroot
5557245SericCEroot
5651279Sericundivert(5)dnl
5751279Seric
5851222Seric# operators that cannot be in local usernames (i.e., network indicators)
5951222SericCO @ % !
6051222Seric
6151322Seric# a class with just dot (for identifying canonical names)
6251322SericC..
6351322Seric
6451887Seric# list of locations of user database file (null means no lookup)
6551887SericOU`'ifdef(`USERDB_SPEC', `USERDB_SPEC')
6651222Seric
6751887Seric# set if we can guarantee no wildcard MX records matching our domain
6852108SericOw`'ifdef(`_NO_WILDCARD_MX_', `True', `False')
6951222Seric
7051222Sericinclude(`../m4/version.m4')
7151222Sericinclude(`../m4/boilerplate.m4')
7256786Sericundivert(6)dnl
7351222Seric#
7451222Seric######################################################################
7551222Seric######################################################################
7651222Seric#####
7751222Seric#####			REWRITING RULES
7851222Seric#####
7951222Seric######################################################################
8051222Seric######################################################################
8151222Seric
8251222Seric
8351222Seric###########################################
8451222Seric###  Rulset 3 -- Name Canonicalization  ###
8551222Seric###########################################
8651260SericS3
8751222Seric
8851222Seric# handle "from:<>" special case
8955416SericR$* < > $*		$@ @				turn into magic token
9051222Seric
9151222Seric# basic textual canonicalization -- note RFC733 heuristic here
9257012SericR$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
9351222SericR$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
9451222SericR$*<$*<$+>$*>$*		$3				2-level <> nesting
9551222SericR$*<$+>$*		$2				basic RFC821/822 parsing
9651222Seric
9751222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
9855416SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
9951222Seric
10051222Seric# localize and dispose of route-based addresses
10155416SericR@ $+ : $+		$@ $>6 < @$1 > : $2		handle <route-addr>
10251222Seric
10351222Seric# find focus for list syntax
10455416SericR $+ : $* ; @ $+	$@ $>6 $1 : $2 ; < @ $3 >	list syntax
10555416SericR $+ : $* ;		$@ $1 : $2;			list syntax
10651222Seric
10751222Seric# find focus for @ syntax addresses
10855416SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
10955416SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
11055416SericR$+ < @ $+ >		$@ $>6 $1 < @ $2 >		already canonical
11151222Seric
11251222Seric# convert old-style addresses to a domain-based address
11355416SericR$- ! $+		$@ $>6 $2 < @ $1 .UUCP >	resolve uucp names
11455416SericR$+ . $- ! $+		$@ $>6 $3 < @ $1 . $2 >		domain uucps
11555416SericR$+ ! $+		$@ $>6 $2 < @ $1 .UUCP >	uucp subdomains
11651222Seric
11751222Seric# if we have % signs, take the rightmost one
11855416SericR$* % $*		$1 @ $2				First make them all @s.
11955416SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
12055416SericR$* @ $*		$@ $>6 $1 < @ $2 >		Insert < > and finish
12151222Seric
12251222Seric# else we must be a local name
12351222Seric
12451222Seric
12551222Seric###############################################
12651222Seric###  Ruleset 6 -- bottom half of ruleset 3  ###
12751222Seric###############################################
12851222Seric
12957245Seric#  At this point, everything should be in a "local_part<@domain>extra" format.
13051222SericS6
13151222Seric
13251222Seric# handle special cases for local names
13351322SericR$* < @ $=w > $*		$: $1 < @ $j . > $3		no domain at all
13455416SericR$* < @ $=w . UUCP > $*		$: $1 < @ $j . > $3		.UUCP domain
13551889Sericundivert(2)dnl
13651222Seric
13751274Sericifdef(`UUCP_RELAY',
13851274Seric`# pass UUCP addresses straight through
13955416SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
14051274Seric`# if really UUCP, handle it immediately
14151322Sericifdef(`_CLASS_U_',
14255416Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14351322Sericifdef(`_CLASS_V_',
14455416Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14551322Sericifdef(`_CLASS_W_',
14655416Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14751322Sericifdef(`_CLASS_X_',
14855416Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
14951322Sericifdef(`_CLASS_Y_',
15055416Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
15151267Seric
15251267Seric# try UUCP traffic as a local address
15355416SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
15451992Sericifdef(`_OLD_SENDMAIL_',
15555416Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
15655416Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
15751267Seric
15851222Seric# pass to name server to make hostname canonical
15951322SericR$* < @ $* $~. > $*		$: $1 < @ $[ $2 $3 $] > $4
16051222Seric
16151889Seric# handle possible alternate names
16251889SericR$* < @ $=w . $m . > $*		$: $1 < @ $j . > $3
16351889SericR$* < @ $=w . $m > $*		$: $1 < @ $j . > $3
16451889Sericundivert(8)dnl
16551889Seric
16651322Seric# if this is the local hostname, make sure we treat is as canonical
16751322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
16851222Seric
16951322Seric
17051222Seric##################################################
17151222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
17251222Seric##################################################
17351222SericS4
17451222Seric
17551222SericR@			$@				handle <> error addr
17651222Seric
17751222Seric# resolve numeric addresses to name if possible
17851322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
17951222Seric
18051322Seric# strip trailing dot off possibly canonical name
18151322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
18251322Seric
18351222Seric# externalize local domain info
18451322SericR$* < $+ > $*		$1 $2 $3			defocus
18551322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
18651997SericR@ $*			$@ @ $1				... and exit
18751222Seric
18851222Seric# UUCP must always be presented in old form
18951322SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u
19051222Seric
19151222Seric# delete duplicate local names
19251322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
19351222Seric
19451222Seric
19551222Seric
19651222Seric#############################################################
19751222Seric###   Ruleset 7 -- recanonicalize and call ruleset zero   ###
19851222Seric###		   (used for recursive calls)		  ###
19951222Seric#############################################################
20051222Seric
20151222SericS7
20251222SericR$*			$: $>3 $1
20351222SericR$*			$@ $>0 $1
20451222Seric
20551222Seric
20651222Seric######################################
20751222Seric###   Ruleset 0 -- Parse Address   ###
20851222Seric######################################
20951222Seric
21051222SericS0
21151222Seric
21255416Sericifdef(`_MAILER_smtp_',
21355416Seric`# handle numeric address spec
21451322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr
21555416SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	numeric internet spec',
21656785Seric`dnl')
21751222Seric
21851887Seric# now delete the local info -- note $=O to find characters that cause forwarding
21951322SericR< @ $j . > : $*	$@ $>7 $1			@here:... -> ...
22051322SericR$* $=O $* < @ $j . >	$@ $>7 $1 $2 $3			...@here -> ...
22151222Seric
22251222Seric# short circuit local delivery so forwarded email works
223*57527SericR$+ < @ $j . >		$: $1 < @ $j @ $H >		first try hub
22451992Sericifdef(`_OLD_SENDMAIL_',
225*57527Seric`R$+ < $+ @ $+ >		$#smtp $@ $3 $: $1 < $2 >	yep ....
226*57527SericR$+ < $+ @ >		$#local $: $1			nope, local address',
227*57527Seric`R$+ < $+ @ $+ >		$#local $: $1			yep ....
228*57527SericR$+ < $+ @ >		$#local $: @ $1			nope, local address')
22951222Sericundivert(3)dnl
23051260Sericundivert(4)dnl
23151260Seric
23255416Seric# resolve remotely connected UUCP links (if any)
23351285Sericifdef(`_CLASS_V_',
23452044Seric`R$* < @ $=V . UUCP > $*		$#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3',
23552044Seric	`dnl')
23651285Sericifdef(`_CLASS_W_',
23752044Seric`R$* < @ $=W . UUCP > $*		$#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3',
23852044Seric	`dnl')
23951285Sericifdef(`_CLASS_X_',
24052044Seric`R$* < @ $=X . UUCP > $*		$#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3',
24152044Seric	`dnl')
24251260Seric
24351222Seric# resolve fake top level domains by forwarding to other hosts
24451222Sericifdef(`BITNET_RELAY',
24552044Seric`R$*<@$+.BITNET>$*	$#smtp $@ $B $: $1 <@$2.BITNET> $3	user@host.BITNET',
24651222Seric	`dnl')
24751222Sericifdef(`CSNET_RELAY',
24852044Seric`R$*<@$+.CSNET>$*	$#smtp $@ $C $: $1 <@$2.CSNET> $3	user@host.CSNET',
24951222Seric	`dnl')
25051222Seric
25151260Sericifdef(`UUCP_RELAY',
25251260Seric`# forward non-local UUCP traffic to our UUCP relay
25352044SericR$*<@$*.UUCP>$*		$#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3	uucp mail',
25455416Seric`ifdef(`_MAILER_uucp_',
25551260Seric`# forward other UUCP traffic straight to UUCP
25651260SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $1:$2			@host.UUCP:...
25751322SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1			user@host.UUCP',
25851260Seric	`dnl')')
25951222Seric
26055416Sericifdef(`_MAILER_smtp_',
26155416Seric`# deal with other remote names
26252041SericR$* < @ $* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain
26355416Seric', `dnl')
26451222Seric
26551992Sericifdef(`_OLD_SENDMAIL_',
26651887Seric`# forward remaining names to local relay, if any
26752041SericR$=L			$#local $: $1			special local names
26852041SericR$+			$: $1 < @ $R >			append relay
269*57527SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
270*57527SericR$+ < @ >		$#local $: $1			no relay or hub: local
271*57527SericR$+ < @ $j  >		$#local $: $1			we are relay/hub: local
272*57527SericR$+ < @ $+ >		$#smtp $@ $2 $: $1		deliver to relay/hub',
27351992Seric`# handle locally delivered names
27452041SericR$=L			$#local $: @ $1			special local names
27552041SericR$+			$#local $: $1			regular local names
27651222Seric
27755416Seric###########################################################################
27855416Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
27955416Seric###		   (new sendmail only)					###
28055416Seric###########################################################################
28151222Seric
28251322SericS5
28351322Seric
28455416Sericifdef(`_MAILER_smtp_',
28555416Seric`R$+			$: $1 < @ $R >
286*57527SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
287*57527SericR$+ < @ $j >		$@ $1				we are relay/hub: local
288*57527SericR$+ < @ $+ >		$#smtp $@ $2 $: $1		send to relay or hub')')
28951222Seric#
29051222Seric######################################################################
29151222Seric######################################################################
29251222Seric#####
29356790Seric`#####			MAILER DEFINITIONS'
29451222Seric#####
29551222Seric######################################################################
29651222Seric######################################################################
29751222Sericundivert(7)dnl
298