[comp.sources.unix] v10i016: The IDA Sendmail Kit, Part05/07

rs@uunet.UUCP (06/23/87)

Mod.sources: Volume 10, Number 16
Submitted by: Lennart Lovstrand <mcvax!ida.liu.se!lel>
Archive-name: ida/Part05


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 5 (of 7)."
# Contents:  ida/cf/Sendmail.mc
# Wrapped by lenlo@prefix on Wed Jun 10 15:39:56 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f ida/cf/Sendmail.mc -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"ida/cf/Sendmail.mc\"
else
echo shar: Extracting \"ida/cf/Sendmail.mc\" \(36429 characters\)
sed "s/^X//" >ida/cf/Sendmail.mc <<'END_OF_ida/cf/Sendmail.mc'
X##########################################################################
X###	The IDA Sendmail Master Configuration File	##################
X##########################################################################
X###	Lennart.Lovstrand@IDA.LiU.SE (aka lel@liuida.UUCP)	       ###
X###	Dept of Comp and Info Sci, University of Linkoping, Sweden     ###
X###	Copyright (c) 1984-87 -- Use it, abuse it, but don't sell it   ###
X##########################################################################
X# Current version (5.21)
XDVVxxi
Xchangequote({,})
X
X####### INTRODUCTION #####################################################
X#
X#	This is The IDA Sendmail Master Configuration File--a completely
X#	independent development having nothing to do with the version
X#	distributed by Berkeley.  In order to work properly, it requires
X#	a set of new functions implemented by the IDA Sendmail Enhancement
X#	Kit, available from your nearest comp.sources.unix archive.
X#
X#	Get it today, tomorrow they might have a disk crash!
X
X
X####### REWRITING STRATEGIES #############################################
X#
X#	Ruleset 3 completely canonicalizes addresses to an internal
X#	format which looks like "user@.domain", including the dot
X#	after the atsign.  The "user" part may end up containing a
X#	route in either standard RFC822 format or using the %-kludge.
X#	The "domain" will be mapped to its full, official domain name
X#	using the TCP/IP name server and a dbm domaintable.  !- and
X#	::-style paths are rewritten into RFC822 routes internally.
X#	Resonable mixtures of !-, %-, and RFC822 routes are resolved,
X#	either using straight domain preference, or using heuristics.
X#	Some effort is made to repair malformed addresses.
X#
X#	This format is used in all internal rulesets until finally
X#	rewritten by the mailer dependant rules, where they are fully
X#	transformed into the mailer's preferred address syntax.  Three
X#	kinds of mailers currently exist:
X#
X#	[1]  Domain based mailers, for which the official domain names
X#	     are used and routes are given in the %-format for header
X#	     addresses and envelope recipient addresses, while
X#	     envelope return paths are kept in RFC822 route syntax.
X#	     Typical examples of this type are the TCP/IP and LOCAL
X#	     mailers.
X#
X#	[2]  Domain based mailers with flat node name mappings.  These
X#	     use full domain names in header addresses but translate
X#	     envelope domains to names relative the actual network's
X#	     name space.  Two mailers fit into this category: The DECnet
X#	     mailer, which map domain names to DECnet names, and the
X#	     UUCP-A/B mailers, which map domains to UUCP node names.
X#	     Both the DECnet and the UUCP worlds use flat namespaces.
X#	     The DECnet and the UUCP-B mailers essentially uses type I
X#	     routes while the UUCP-A mailer uses type III routes (ie,
X#	     !-paths).
X#
X#	[3]  UUCP !-path based mailers.  This mailer type rewrites all
X#	     addresses into !-paths, both header and envelope addresses.
X#	     Header addresses are made relative the remote node by
X#	     removing "remote!" from them or prefixing "localhost!" to
X#	     them. UUCP nodes with domain names are translated to their
X#	     UUCP equivlanents.
X
X
X####### SENDMAIL CONFIGURATION EXTENSIONS ################################
X#
X#	This is a short table describing extensions to the configuration
X#	language.  See the reference guide for a detailed definition.
X#
X#	Option "/" will turn on general envelope/header specific
X#	rewriting.  Mailer specific e/h rulesets are given as in
X#	"R=14/15", where ruleset 14 is used for envelope recipient
X#	addresses and ruleset 15 for header recipients.
X#
X#	The M_FROMPATH (p) flag will work for mailers that use "From_"
X#	line envelopes as well as SMTP mailers.
X#
X#	The M_RELATIVIZE (V) flag has been added, which make all header
X#	lines relative the recipient host by removing "remote!" or
X#	adding "localhost!".
X#
X#	TCP/IP nameserver lookups are extended with a default argument,
X#	as in "$[ hostname $: default $]".  The "default" string will be
X#	returned if the host isn't known to gethostname(3).
X#
X#	General dbm database functions have been added.  The option "K"
X#	will declare a dbm database and associate it with a letter,
X#	which later on is used in constructs like:
X#		"$(x key $@ arg $: default $)"
X#	The "x" is the one-letter name of the database, the "key" is the
X#	lookup string; the optional "arg" is then sprintf(3)'ed through
X#	the result, if found.  The whole expression evaluates to
X#	"default", or "key" if "$: default" is not present, if the "key"
X#	can't be found in the database.  The "@" database is
X#	automatically connected to the aliases(5) file.
X
X
X####### M4 IDENTIFIERS ###################################################
X#
X#	NOTE: Be aware that this is an m4 source where curly braces are
X#	used as quote characters.  You will lose heavily if you care-
X#	lessly mention reserved m4 words or use curly braces where you
X#	shouldn't.
X#
X#	The following is a list of all m4 identifiers used in this file.
X#	All of them are optional.
X#
X#	ALIASES
X#		Name of the aliases file, defaults to sendmail's default.
X#	BSD29
X#		Activates various hacks for usage on BSD 2.9 systems.
X#	BANGIMPLIESUUCP
X#		If defined, will inhibit domaintable lookups for
X#		unqualified nodes first in !-paths and always inter-
X#		preting them to reside in the UUCP pseudo-domain.
X#	DECNETNODES
X#		A file containing DECnet host names.  Used in combination
X#		with DECNETXTABLE to determine delivery through the DECnet
X#		mailer and when to expand flatspaced DECnet host names into
X#		domains.
X#	DECNETXTABLE
X#		The DECnet translation table.  Returns a node's DECnet
X#		host name if given its domain name.  (Dbm file, see
X#		ruleset 24 for more info).
X#	DEFAULT_HOST
X#		Explicit host name, replaces automatic definition of $w.
X#	DEFAULT_DOMAIN
X#		The string that (+ ".") will be attached to $w to
X#		form $j, this node's official domain name.
X#	DOMAINTABLE
X#		Dbm database used for hostname canonicalization, ie.
X#		to find the official domain name for local or otherwise
X#		unqualified hosts.
X#	GENERICFROM
X#		A database mapping actual user names to generic user
X#		names.  Used instead of HIDDENNET in a heterogenous
X#		environment.
X#	HIDDENNET
X#		Points to a file containing a list of host names, one
X#		per line.  Mail from users on any of these hosts will
X#		have the host name substituted for our host, $w.
X#	LIBDIR	
X#		The directory that will hold most data files, including
X#		sendmail.{hf,st}; defaults to /usr/lib/mail.
X#	PATHTABLE
X#		The heart & soul of this sendmail configuration--the
X#		pathalias routing table in dbm format, as produced by
X#		the pathalias program.  Either you define this or rel(a)y
X#		on RELAYHOST/RELAYMAILER.
X#	MAILERTABLE
X#		A dbm table mapping node names to "mailer:host" pairs.
X#		It is used for special cases when the resolving heuristics
X#		of ruleset 26 aren't enough.
X#	NEWALIASES
X#		If defined, will make ruleset 26 return all addresses
X#		as local.  This should be used by the newaliases program
X#		only when parsing the aliases file if you want to handle
X#		non-local aliases as well.
X#	PSEUDONYMS
X#		Additional names that we are known under (in addition
X#		to those returned by gethostbyname()).
X#	RELAY_HOST & RELAY_MAILER
X#		Name of the host and mailer to ship unknown recipient
X#		addresses to.
X#	RSH_SERVER
X#		If defined, do local deliveries by rsh'ing /bin/mail
X#		on the RSH_SERVER host.
X#	SPOOLDIR
X#		Directory for sendmail queue files; defaults to
X#		/usr/spool/mqueue.
X#	UUCPNAME
X#		This node's UUCP host name, if different from $w.
X#	UUCPNODES
X#		A file containing names of directly connectable UUCP nodes.
X#	UUCPPRECEDENCE
X#		If defined, will change the interpretation of mixed
X#		!/@ addresses to use heuristics instead of always
X#		preferring RFC822 style. (NOT FULLY TESTED!)
X#	UUCPRELAYS
X#		Name of file containing names of known (UUCP) relays.
X#		Header addresses containing paths through any of these
X#		will be shortened by having the path to the relay removed.
X#		(It is assumed that paths to each of these are known to
X#		everybody)
X#	UUCPXTABLE
X#		A table mapping domain node names to UUCP node names.
X#		Used in envelope addresses sent using UUCP/rmail.
X
X
X####### CLASSES, DEFINITIONS, and DATABASES ##############################
X#
X#	The following classes, macro definitions and keyed databases are
X#	being used:
X#
X#	CA	An atsign (@), used in class membership negations
X#	CD	Known DECnet host names (see DECNETNODES above)
X#	CH	Node names that should be hidden by $w (see HIDDENNET above)
X#	CR	Removeable relays from header addresses (see UUCPRELAYS above)
X#	CT	Known top level domains (global + local)
X#	CU	Directly connectable UUCP nodes
X#	CX	A set of chars that delimit the LHS of a domain (@ %)
X#	CY	A set of chars that delimit the RHS of a domain (, : % @)
X#	CZ	RFC822 Source Route punctuation chars (, :)
X#
X#	DV	Configuration version number
X#
X#	OK@	The aliases database (automatically defined; see ALIASES above)
X#	OKD	DECnet domain translation table (see DECNETXTABLE above)
X#	OKG	Generic usernames (see GENERICFROM above)
X#	OKM	Special domain => mailer:host table (see MAILERTABLE above)
X#	OKN	Official name lookup table (see DOMAINTABLE above)
X#	OKP	Pathalias routing database (see PATHTABLE above)
X#	OKU	UUCP domain translation table (see UUCPXTABLE above)
X
X
X##########################################################################
X## Default Definitions ###################################################
X##########################################################################
Xifdef({LIBDIR},,{define(LIBDIR, /usr/lib/mail)})
Xifdef({SPOOLDIR},,{define(SPOOLDIR, /usr/spool/mqueue)})
X
X#
X##########################################################################
X## Domain Definitions ####################################################
X##########################################################################
X
X##########################################################################
X#	Universally known top-level domains
X
X#					Organizational domains
XCTcom edu gov org mil net
X#					National domains
XCTau ca cdn de fi fr gb il jp kr nl nz oz se uk us
X#					Network based domains
XCTarpa bitnet csnet junet mailnet uucp
X
X
X##########################################################################
X## Misc Definitions ######################################################
X##########################################################################
X
Xifdef({DEFAULT_HOST},
X# This node's local host name
X{Dw}DEFAULT_HOST)
X
X# This node's official domain name
Xifdef({DEFAULT_DOMAIN},
X{Dj$w.}DEFAULT_DOMAIN,
XDj$w)
X
Xifdef({PSEUDONYMS},
X# Other names for this node
X{Cw}PSEUDONYMS)
XCw$k
X
X# my name
XDnMAILER-DAEMON
X
X# UNIX header format
XDlFrom $g $d
X
X# delimiter (operator) characters
XDo".:;%@!=/[]?#^,<>"
X
X# Characters that mark the left (X) & right (Y) hand side of a domain
XCX@ %
XCY, : % @
X
X# Pure RFC822 route punctuation characters
XCZ, :
X
X# The atsign-in-a-class
XCA@
X
X# Format of a total name: Personal Name <user@domain>
XDq$?x$x <$g>$|$g$.
X
X# SMTP login message
XDeGolly wosh!  Sendmail $v/$V still running on $j
X
X
X##########################################################################
X#	Options
X
X#				set default alias file
Xifdef({ALIASES},{OA}ALIASES)
X#				time to look for "@:@" in alias file
XOa15
X#				substitution for blank character
XOB.
X#				don't connect to "expensive" mailers
XOc
X#				delivery mode
XOdb
X#				rebuild alias database as needed
XOD
X#				set error processing mode
X# Oe
X#				temporary file mode
XOF0660
X#				save Unix-style From lines on front
X# Of
X#				default gid
XOg1
X#				help file
X{OH}LIBDIR/sendmail.hf
X#				ignore dot lines in message
X# Oi
X#				database files
Xifdef({DECNETXTABLE},{OKD}DECNETXTABLE)
Xifdef({GENERICFROM},{OKG}GENERICFROM)
Xifdef({MAILERTABLE},{OKM}MAILERTABLE)
Xifdef({DOMAINTABLE},{OKN}DOMAINTABLE)
Xifdef({PATHTABLE},{OKP}PATHTABLE)
Xifdef({UUCPXTABLE},{OKU}UUCPXTABLE)
X#				log level
XOL9
X#				define macro
X# OM
X#				send to me too
XOm
X#				local network name
Xifdef({DEFAULT_DOMAIN},{ON}DEFAULT_DOMAIN)
X#				assume old style headers
XOo
X#				postmaster copy of returned messages
XOPPostmaster
X#				queue directory
X{OQ}SPOOLDIR
X#				read timeout -- violates protocols
XOr30m
X#				status file
X{OS}LIBDIR/sendmail.st
X#				be super safe, even if expensive
XOs
X#				queue timeout
XOT2w
X#				time zone name
X# OtMET,MET DST
X#				set default uid
XOu1
X#				run in verbose mode
X# Ov
X#				wizard's password
XOWanuZMxS7nTb2U
X#				load avg at which to auto-queue msgs
XOx3
X#				load avg to auto-reject connections
XOX8
X#				fork when running the queue
Xifdef({BSD29},OY)
X#				use separate envelope/header rewriting rulesets
XO/
X
X##########################################################################
X#	Message precedences
X
XPfirst-class=0
XPspecial-delivery=100
XPjunk=-100
X
X##########################################################################
X#	Trusted users
X
XTroot
XTdaemon
XTuucp
XTnetwork
XTlenlo
X
X##########################################################################
X#	Header Formats
X
XHReceived: $?sfrom $s $.by $j; $b
X#HReceived: $?sfrom $s $.by $j$?r with $r$.; $b
XH?P?Return-Path: <$g>
XH?D?Date: $a
XH?F?From: $q
XH?x?Full-Name: $x
XH?M?Message-ID: <$t.$i@$j>
X
X
X#
X##########################################################################
X## Mailer Specifications #################################################
X##########################################################################
X
X##########################################################################
X#	Local & Prog mailer definitions
X
X# List of nodes that should be hidden by our name (header senders)
Xifdef({HIDDENNET},{FH}HIDDENNET)
X
Xifdef({RSH_SERVER}, {
XMlocal,	P=/usr/ucb/rsh, F=DFMlmns,	A=RSH_SERVER /bin/mail -d $u
X}, {
Xifdef({BSD29}, {
XMlocal,	P=/bin/mail, F=DFMSlms,		A=mail $u	}, {
XMlocal,	P=/bin/mail, F=DFMSlmnrs,	A=mail -d $u	})
X})
XMprog,	P=/bin/csh,  F=DFMhlsu,		A=csh -fc $u
X
X
X##########################################################################
X#	TCP/IP mailer specification
X#
X#	Kludge: Flatten envelope recipient DECnet domains.
X#		The message will probably go through our TCP/IP-DECnet
X#		gateway, which can't take care of domains (sigh).
X
XMTCP,  P=[IPC], F=CDFMXhnmpsu, E=\r\n, R=24/0, A=IPC $h
X
X
X##########################################################################
X#	(Pseudo)DECnet mailer specification
X#
X#	Send all envelope recipients thru DECnet domain name flattener.
X
X# List of DECnet nodes
Xifdef({DECNETNODES},{FD}DECNETNODES)
X
X# Since we don't have any Unix boxes with DECnet yet, we cheat...
XMDECnet,  P=[IPC], F=CDFMXhnmpsu, R=24/0, E=\r\n, A=IPC lisbet.liu.se
X
X
X##########################################################################
X#	UUCP mailer definitions
X
X# Our UUCP name, if other than $w
Xifdef({UUCPNAME},{Dk}UUCPNAME)
X
X# List of known UUCP nodes
Xifdef({UUCPNODES},{FU}/usr/lib/uucp/L.sys)
XCU$k
X
X# List of UUCP relays that are to be removed from sender paths
Xifdef({UUCPRELAYS},{FR}UUCPRELAYS)
X
XMUUCP,   P=/usr/bin/uux, F=DFMUVShpsu, S=19, R=19,    A=uux - -z -r $h!rmail (
$u)
XMUUCP-A, P=/usr/bin/uux, F=DFMShmpu,  S=19/0, R=15/0, A=uux - -z -r $h!rmail (
$u)
XMUUCP-B, P=/usr/bin/uux, F=BDFMSXhmpu, S=0,  R=15/0,  A=uux - -z -r $h!bsmtp
X
X# Canonicalize envelope recipient addresses before UUCP-ifying them.
XS14
XR$+			$@ $>19$>3 $1
X
X# UUCP-ify address, then move domain back if not UUCP destination
XS15
XR$+			$: $>19 $1		UUCP-ify
XR$+!$+			$: $1?$2		mark first bang
XR$+.$=T?$+		$@ $3@.$1.$2		restore if real domain
XR$+?$+			$@ $1!$2		just put bang back otherwise
X
X#
X##########################################################################
X## Standard Rewriting Rules ##############################################
X##########################################################################
X
X#########################################################################
X#									#
X#	Rule Set #0:	Mailer Resolving Ruleset			#
X#									#
X#	This is rather straightforward.  The code should say it all.	#
X#									#
X#########################################################################
XS0
X
X# Digest routes through ourself (can't use S28 'cause it only strips one level
)
XR$+@$+@.$=w		$@$>0$>3 $1@$2			RFC822 Src Route
XR$+%$+@.$=w		$@$>0$>3 $1%$2			%-Path
X
X# Try immediate delivery
XR$+@.$+			$:$>26 $1@.$2			try to find mai
ler
XR$#$+			$# $1				found, return it
X
X# Unknown domain, try to find a pathalias route
XR$+@.$+			$:$>26$>22 $1@.$2		go get route & 
mailer
XR$#$+			$# $1				found, return it
X
Xifdef({RELAY_HOST}, {
X# Relay other unknowns through RELAY_HOST/RELAY_MAILER
XR$+@.$+			${#}RELAY_MAILER $@RELAY_HOST $:$1@.$2
X})
X
X# Undeliverable recepients--complain loudly & return to sender
XR$+@.$-		$#ERROR $:Host $2 not known--please specify domain
XR$+@.$-.$*$=T	$#ERROR $:Host $2 not known within the $3$4 domain
XR$+@.$+.$-	$#ERROR $:Domain $3 not known--please try to route manually
XR@$+		$#ERROR $:"Incomplete Source Route--use <...> format"
XR$*		$#ERROR $:Could not parse $1
X
X
X#########################################################################
X#									#
X#	Rule Set #1:	[Envelope] Sender Specific Rewriting		#
X#									#
X#	[Currently nothing.]						#
X#									#
X#########################################################################
XS1
X
X
X#########################################################################
X#									#
X#	Rule Set #2:	[Envelope] Receiver Specific Rewriting		#
X#									#
X#	Turn RFC822 Source Routes into a %-paths since most MTAs	#
X#	don't know about how to handle the former format.		#
X#									#
X#########################################################################
XS2
X
XR$+@.$+			$:$>25 $1@.$2		Src Routes => %-routes
X
X
X#########################################################################
X#									#
X#	Rule Set #3:	Address Canonicalization			#
X#									#
X#	Turns the address into the (internally) canonical format	#
X#	mailbox@.domain.  The `domain' is what you think it is, but	#
X#	the `mailbox' may be either a "real" mailbox in which case	#
X#	no further meaning is associated to it, or a route in either	#
X#	the Source Route format as specified by RFC822 or the (un-	#
X#	documented) Good Ole ARPAnet %-Kludge Format.			#
X#									#
X#	Input formats include the standard "mailbox@domain" format,	#
X#	RFC822 Source Routes, RFC822 Group Names, ARPAnet %-Kludges,	#
X#	UUCP !-Paths, the Berknet "host:user" format, the VAX/VMS	#
X#	"host::user" format and resonable mixtures of the above.	#
X#									#
X#	The code even tries to clean up after various mistakes that	#
X#	other nodes has done when reformatting the addresses, such	#
X#	as mangled Xerox distribution lists or malformatted RFC822	#
X#	Group Specifications.						#
X#									#
X#########################################################################
XS3
X
XR$*<$+>$*		$2			turn to essentials
XR$*<>$*			Postmaster		default user
X
X# These are not for us
XR:{include}:$*@$*	$@:{include}:$1@.$2	indirect address
XR:{include}:$*		$@:{include}:$1@.$w	indirect address
XR$*/$*@$*		$@$1/$2@.$3		file name
XR$*/$*			$@$1/$2@.$w		file name
X
X# Fix group names and return them
XR$+:;@$+		$:$1:;			remove host info
XR$+:			$:$1:;			missing semicolon
XR$+!;			$:$1:;			UUCP-style mangled group
XR$+!$+:;		$2:;			remove UUCP host info
XR$+:;			$@$1:;			Finally return group
X
X# Miscellaneous cleanup (sigh)
XR$+!.$+			$1^.$2			fix mangled Xerox dList
XR$+::$+			$1!$2			VAX/VMS relative addres
s
XR$+!:$+@$+		$1!$3!$2		scrambled source route
XR$+!:$+			$1!$2			mangled VAX/VMS address
XR$-:$-			$1!$2			Berknet style address
XR$+ at $+		$: $1@$2		"at" -> "@"
XR$+:@$+			$1,@$2			slightly malformed src 
route
XR$*$~Z@$+@$+		$1$2%$3@$4		fix user@host@relay
XRenea!$+!!$+,!$+	enea!$1!!$2,@$3		brutally beaten src route
XRenea!$+!!$+:$+!$+	$: enea!$1!$2!$4!$3	seriously smashed src route
XRenea!$+!!$+		$: enea!@$2@$1		maddenly messy src route
XR$+@$+.$=T.UUCP		$1@$2.$3		strip UUCP off foo@bar.
EDU.UUCP
X
X# Fix %-kludgified RFC822 source routes (double sigh)
XR$+!%$+:$+%$+		$1!%$2:$3@$4		change all %'s into @'s
XR$+!%$+,%$+		$1!%$2,@$3
XR$+!%$+			$1!@$2
X
X###
X###	The address should be in a reasonable format now--time to
X###	resolve mixed !/@ hybrid addresses.
X###
X
X# Case 0: !-prefixed RFC822 source route--extend to complete source route
XR$+!$+!@$+		$1,@$2!@$3		!-path to ,@-route
XR$+!@$+			$: @$1,@$2		including first & last 
!-host
X
Xifdef({UUCPPRECEDENCE}, {
X# Case 1: Unqualified domain--guess UUCP style address
XR$~A$*!$+@$-		$:$>21 $1$2!$3%$4@	guess originally UUCP style
X
X# Case 2: Qualified domain--guess RFC822 style address
XR$~A$*!$+@$+		$:$>21 $4!$1$2!$3@	guess originally domain style
X}, {
X### Always assume RFC822 style
X# Case 1: !-path on top of %-route on top of @-domain (God, why me?!)
XR$~A$*!$+%$+@$+		$: $1$2?$3%$4@$5	mark first bang
XR$+?$+!$+%$+		$1!$2?$3%$4		find rightmost
XR$+?$+%$+%$+@$+		$3!$1?$2%$4@$5		move %hosts around
XR$+?$+%$+@$+		$:$>21 $4!$3!$1!$2@	now send it thru unbanger
X
X# Case 2: Domain address without %-route
XR$~A$*!$+@$+		$:$>21 $4!$1$2!$3@	guess originally domain style
X})
X
X# Case 3: Pure UUCP-path (or not UUCPPRECEDENCE)
XR$~A$*!$+		$:$>21 $1$2!$3@		pure UUCP style
X
X###
X###	Address should be close to canonical now, give or take
X###	the @domain part.  Make it really internal by adding a
X###	dot before the [direct] domain (if any).  Also qualify
X###	some domain names.
X###
X
X# Add dot and put direct host on back for RFC822 Source Routes
XR$+			$: $1@			make sure address has atsign
XR$+@$+@			$: $1@$2		remove again if already
 there
XR$*@$+			$: $1@.$2		add dot after [direct] domain
XR@.$+$=Z$+		$: $3@.$1		tack direct domain on end
XR$+@..$+		$: $1@.$2		one dot is enough! (intern fix)
X
X# Routed address (good ol' ARPA version)
XR$+%$+@			$:$1@.$2		replace '%' with '@.'
XR$+@.$+%$+		$1%$2@.$3		move gaze right
X
X# Sometimes users try to send to RFC822 Source Routes without angle
X# brackets.  This will cause the mailer to split the comma-separated
X# domain path into separate phony addresses, which all look like
X# "@domain".  There's not much to do about it here though.
XR@.$+@			$@ @$1			incomplete Source Route
X
X# No domain, attach default
XR$+@			$: $1@.$w		no host/domain, attach default
X
X# Try to find official name for domain
XR$+@.$+			$: $1@.$[ $2 $]		officialize using TCP/I
P
XR$+@.$+			$: $1@.$(N $2 $)	officialize using domai
ntable
X
X
X#########################################################################
X#									#
X#	Rule Set #4:	Address PrettyPrinter				#
X#									#
X#	Does the final prettyprinting before the address is included	#
X#	in the message.  (This is essentially a trivial reformatting	#
X#	from internal to external format)				#
X#									#
X#########################################################################
XS4
X
X# Remove dot and return RFC822 Source Routes
XR@$+@.$+		$@ @$2,@$1
XR$+@$+@.$+		$@ @$3:$1@$2
X
X# Remove dot for normal domain addresses
XR$+@.$+			$@ $1@$2
X
X
X#########################################################################
X#									#
X#	Rule Set #5:	[Header] Sender Specific Rewriting		#
X#									#
X#	Rewrite RFC822 source routes into %-routes, since most mailer	#
X#	UAs can't handle them.  Compact obvious routes, mostly for	#
X#	aesthetical reasons.  Possibly hide local nodes behind ourself.	#
X#	Substitute generic names for physical senders.			#
X#									#
X#########################################################################
XS5
X
XR$+@.$+			$:$>23 $1@.$2			unsourcify & pr
ettify
X
X# Hide these nodes using our own name
XR$+@.$=H		$: $1@.$j
X
Xifdef({GENERICFROM}, {
X# Use (canonicalized) generic names for local users
X# (Assumes that it never will find a $+@.$+ address in the db, ie. with dot)
XR$+@.$+			$: $1@.$2 ? $1@.$2		duplicate
XR$+?$+@.$+.$-		$1 ? $(G $2@$3.$4 $: $2@.$3 $)	search db foreach dom
XR$+?$+@.$-		$: $1 ? $(G $2@$3 $: $2@.   $)	search for last dom
XR$+@.$=w?$+@.		$: $1@.$2 ? $(G $3 $: $3@.  $)	search for locals
XR$+@.$+?$+@.$*		$@ $1@.$2			not found
XR$+?$+			$@ $>3 $2			found, canonicalize
X})
X
X
X#########################################################################
X#									#
X#	Rule Set #6:	[Header] Receiver Specific Rewriting		#
X#									#
X#	Rewrite RFC822 source routes into %-routes, since most mailer	#
X#	UAs can't handle them.  Compact obvious routes, mostly for	#
X#	aesthetical reasons.						#
X#									#
X#########################################################################
XS6
X
XR$+@.$+			$:$>23 $1@.$2			unsourcify & pr
ettify
X
X
X#
X##########################################################################
X## General Rewriting Rule Subroutines ####################################
X##########################################################################
X
X#########################################################################
X#									#
X#	Rule Set #19:	Translate domain addresses to UUCP !-paths	#
X#									#
X#	Takes an domain style address as input and transforms this	#
X#	into a !-path.  There will be no atsign left in the address	#
X#	after this, but there may(?) still be a percent sign.		#
X#	Routes are specially processed, trying to qualify all non-	#
X#	qualified nodes in the path.  This is to make sure local nodes	#
X#	will have their proper domains properly attached before the	#
X#	messages leavs us.  I'm not sure if this is a good thing or	#
X#	not, since they may not be local at all.  UUCP nodes with	#
X#	domain style names are qualified, anyway.			#
X#									#
X#########################################################################
XS19
X
X# Don't touch groups!
XR$+:;			$@ $1:;			return groups
X
X# Translate RFC822 Source Routes FULLY into !-path format
XR$+@$+@.$+		$:$>4 $1@$2@.$3		first externalize
XR@$+			$: ?@$1			mark first node
XR$*?@$+$=Z$+		$1$2!?$4		change prefix path to !
XR$+?$~A$*@$+		$: $1$4!$2$3		turn last pair into ! format 2
XR$*?$*			$: $1$2			remove possible trailing mark
X
X# Translate normal domain addresses
Xifdef({UUCPXTABLE},{
XR$+%$-@.$+		$: $1%$2@.$3 ? $(U $3 $: $)	UUCP node as domain?
XR$+%$-@.$+?$+		$:$>20 $1%$2@.$3	yes, !-ify
XR$+%$-@.$+?		$: $1%$2@.$3		no, remove mark
X})
XR$+%$-@.$+.UUCP		$:$>20 $1%$2@.$3.UUCP	!-ify "obvious" UUCP ro
utes
XR$+%$-@.$+.$-		$: $3.$4!$1%$2		don't know about other domains
XR$+@.$+			$:$>20 $1@.$2		all the rest to the !-i
fyer
X
X###
X### Address should be in !-path format now.
X###
X
Xifdef({DOMAINTABLE},{
X# Qualify all nodes that we know of
X# THIS IS DANGEROUS AND WRONG!  But still needed since some nodes out there
X# do heavy path optimizations and our DECnet nodes may lose due to that.
XR$*			$: ?$1			mark start
XR$*?$+!$+		$1$(N $2 $)!?$3		qualify node
XR$*?$*			$: $1$2			remove mark
X})
X
X# Unqualify all UUCP nodes
Xifdef({UUCPXTABLE},{
XR$*			$: ?$1			mark start
XR$*?$+!$+		$1$(U $2 $)!?$3		unqualify node
XR$*?$*			$: $1$2			remove mark
X})
XR$-.UUCP!$+		$: $1!$2		remove first .UUCP
XR$+!$-.UUCP!$+		$1!$2!$3		remove other .UUCP's
X
X
X#########################################################################
X#									#
X#	Rule Set #20:	%-Route to !-Path Translator			#
X#									#
X#	Translates Good Ol' ARPA %-Routes to UUCP style !-paths.	#
X#	This is done up to, but not beyond, the first non-UUCP		#
X#	domain found in the path.					#
X#	   This ruleset is used strictly for heuristical reasons.	#
X#	Nodes with Real Domain Names are assumed in general not to	#
X#	understand !-paths, but rather prefer %-routes.  This wouldn't	#
X#	have been necessary to do here if all gateways had fully	#
X#	converted all addresses.					#
X#	Eg.	mbox%a%b%c@.domain	=> domain!c!b!a!mbox		#
X#		mbox%a.b%c%d@.domain	=> domain!d!c!mbox%a.b		#
X#									#
X#########################################################################
XS20
X
Xifdef({UUCPXTABLE},{
XR$+@.$+			$: $(U $2 $)?$1		move translated domain 
to front
X},{
XR$+@.$+			$: $2?$1		move domain to front
X})
XR$+?$+%$-		$1!$3?$2		prefix host route
Xifdef({UUCPXTABLE},{
XR$+?$+%$+		$: $1?$2%$(U $3 $)	translate UUCP domains to hosts
XR$+?$+%$-		$@$>20 $1?$2%$3		recurse if host found
X})
XR$+?$+%$-.UUCP		$@$>20 $1?$2%$3		recurse if ending in host.UUCP
XR$+?$+			$: $1!$2		get rid of temp !-subst
X
X
X#########################################################################
X#									#
X#	Rule Set #21:	Prehost to Posthost Converter			#
X#									#
X#	Changes !-paths into RFC822 Source Routes.			#
X#	Eg. a!b!c!d	=> a,@b,@c,@d	=> @a,@b:d@c			#
X#	    a!b!c%d	=> a,@b,@c%d	=> @a:c%d@b			#
X#	    a!b!c@d	=> a,@b,@c@d	=> @a,@b:c@d)			#
X#									#
X#########################################################################
XS21
X
X# Initial canonicalization (get rid of possible '@' as in path!u@h)
XR$+@			$: $1			remove optional trailing '@'
XR$+!$+			$: $1?$2		find the rightmost '!'
XR$+?$+!$+		$1!$2?$3		..and change it into a '?'
XR$+?$+@$+		$: $1!$3!$2		change last u@h to h!u if any
XR$+?$+			$: $1!$2		just remove '?' otherwise
X
X# The address is now formatted as a!b!..!h!u -- transform it into a,@b,@..?h?u
XR$+!$+			$: ?$1?$2		find last h!u-pair
XR$*?$+?$+!$+		$1,@$2?$3?$4		change all '!'s before to ',@'
XR?$+?$+			$: $2@$1		h!u => u@h
XR,$+?$+?$+		$: $1:$3@$2		,path..h!u => path:u@h
X
Xifdef({DOMAINTABLE},{
X# Infer .UUCP domain on first host if unqualified and not known in domaintable
XR@$-$=Z$+		$@ @$(N $1 $: $1.UUCP $)$2$3	domainify route
XR@$+			$@ @$1				already has domain
XR$+@$-			$@ $1@$(N $2 $: $2.UUCP $)	domainify host
X},{
XR@$-$=Z$+		$@ @$1.UUCP$2$3			assume .UUCP
XR$+@$-			$@ $1@$2.UUCP			dito
X})
X
X#########################################################################
X#									#
X#	Rule Set #22:	General Pathalias Router			#
X#									#
X#	Tries to find a route for an address using the pathalias	#
X#	database.  It will return the complete (canonicalized)		#
X#	route if found, or the same address otherwise.			#
X#									#
X#########################################################################
XS22
X
Xifdef({PATHTABLE},{
X# Change RFC822 Source Routes into %-path to get rid of multiple atsigns
XR$+@$+@.$+	$:$>25 $1@$2@.$3			Src Route to %-path
X
X# Search pathalias database
XR$+@.$+		$: $(P  $2 $@$1          $:$1@?$2 $)	1st: try full d
omain
XR$+@$*?$-.$+	$(P .$3.$4 $@$1%$2.$3.$4 $:$1@$2.$3?$4 $)	2nd: subdomains
XR$+@.$+?$-	$: $(P .$3 $@$1%$2.$3    $:$1@?$2.$3 $)	3rd: try top domain
X
X# Found a route?
XR$+@?$+		$@ $1@.$2				failure: return
XR$+%.$+		$1%$2					success: remove
 '.'
X
X# Yes, canonicalize result
XR$+@$+		$@$>3 $1@$2				canonicalize domains
XR$+!$+		$@$>3 $1!$2				canonicalize !-paths
XR$+%$+		$@$>3 $1%$2				canonicalize %-paths
XR$+		$@ $1@.$w				canonicalize users
X})
X
X#########################################################################
X#									#
X#	Rule Set #23:	Route prettyprinter & compressor.		#
X#									#
X#	This code rewrities RFC822 Source Routes into %-routes, which	#
X#	most users and mail FEs understand better.  It also comresses	#
X#	"obvious" routes whenever considered necessary -- mostly just	#
X#	for aesthetical reasons, though.  If you don't like this, feel	#
X#	free to disable it.  Sendmail shouldn't break, anyway.  (But	#
X#	there will probably be others...)
X#									#
X#########################################################################
XS23
X
X# Turn RFC822 Source Route into %-path
XR$+@$+@.$+		$:$>25 $1@$2@.$3
X
X# Remove route to well-known domain
XR$+%$+.$=T$=Y$+		$:$>3 $1%$2.$3		known top domain
X
X# Strip routes through well-known UUCP relays
XR$+%$-@.$=R		$:$>3 $2!$1		known UUCP relay
X
X# LOCAL FIX: Strip header %-routes that paranoid instances of MM produce
XR$+%aida%$+@.majestix.liu.se	$@ $1@.$(N aida $)	AIDA's MM does this
XR$+%carmen%$+@.majestix.liu.se	$@ $1@.$(N carmen $)	CARMEN's too
X
X
X#########################################################################
X#									#
X#	Rule Set #24:	Unqualify domains for DECnet nodes		#
X#									#
X#	This is needed since DECnet has a flat namespace.  All DECnet	#
X#	nodes that are [externally] known to have a certain domain	#
X#	name are unqualified to their corresponding DECnet host name.	#
X#									#
X#########################################################################
XS24
X
Xifdef({DECNETXTABLE}, {
XR$+			$: ?$1			mark beginning of addrs
XR$*?$*$=X$+$=Y$*	$1$2$3$(D $4 $)?$5$6	scan & lookup domains
XR$*?$*@.$+		$1$2@.$(D $3 $)		lookup direct domain
X})
X# LOCAL FIX: The SUNET.SE domain only consists of DECnet nodes.
XR$*$=X$-.SUNET.SE$=Y$*	$1$2$3$4$5		*.SUNET.SE are on DECnet
XR$+@.$-.SUNET.SE	$1@.$2			dito
X
X
X#########################################################################
X#									#
X#	Rule Set #25:	Translate RFC822 Source Routes into %-Paths	#
X#									#
X#	This ruleset takes a (perhaps internalized) RFC822 Source	#
X#	Route and translates it into it's %-kludgified equivalent.	#
X#	Non-RFC822 Source Routes should pass through unharmed.		#
X#									#
X#	Eg: [u@h@.a	=>] @a:u@h	=> u%h@a			#
X#	    [@b:u@h@.a	=>] @a,@b:u@h	=> u%h%b@a			#
X#	  [@c,@b:u@h@.a	=>] @a,@b,@c:u@h => u%h%b%a%c@d			#
X#									#
X#########################################################################
XS25
X
X# Take care of internal mbox@.domain format
XR@$+:$+@$+@.$+	$: @$4,@$1:$2@$3		move @.domain to front
XR$+@$+@.$+	$: @$3:$1@$2			dito
X
X# Address is now real RFC822 Source Route--make sure user isn't !-path
XR$+:$+@$+	$: $1:$>4$>3 $2@$3		canonicalize last user@host
XR$+:$+:$+@$+	$: $1,$2:$3@$4			merge possible double Src Route
X
X# Finally, the actual translation
XR$+:$+@$+	$: $1:$2%$3?			path:u@.h => path:u%h + mark
XR$+:$+@		$: $1:$2?			path:u@ => path:u + mar
k
XR@$+$=Z$+?$*	$3?%$1$4			rotate & concat
XR$+%$+?$*	$1@.$2$3			instantiate '%' & remove mark
XR$+@.$+%$+	$1%$2@.$3			move gaze right
X
X
X#########################################################################
X#									#
X#	Rule Set #26:	Determine Mailer for Address			#
X#									#
X#	Takes an address in canonical format as input and returns	#
X#	a complete mailer specification if a mailer is known for	#
X#	the supplied domain.  Just returns the address otherwise.	#
X#									#
X#########################################################################
XS26
X
Xifdef({NEWALIASES}, {
X# Updating aliases database -- return all addresses as local
XR$+@.$w			$#LOCAL  $@$w $:$1		default host
XR$+@.$+			$#LOCAL  $@$2 $:$1@.$2		specified host
X})
X
X
X# Search for possible global alias
XR$+@.$+			$: $1@.$2 ? $>4$>10$>2 $1@.$2	externalize
XR$+?$+			$: $1 ? $(@ $2 $:$)		search aliases
XR$+@.$+?$+		$#LOCAL  $@$2 $:$1@.$2		found it!
XR$+?			$: $1				not found, remove mark
X
X# Deliver to locals right away
XR$+@.$=w		$#LOCAL  $@$2 $:$1
X
Xifdef({MAILERTABLE},{
X###
X###	Determine delivery over specific media
X###
XR$+@.$+			$: $1@.$2 ? $(M $2 $: $)	search mailer t
able
XR$+@.$+?$+:$+		$#$3     $@$4 $:$>28 $1@.$2	relativize & return
XR$+@.$+?$*		$: $1@.$2			no match, remove mark
X})
X
X###
X###	Determine delivery over TCP/IP
X###
XR$+@.$+			$: $1@.$2 ? $[ $2 $: $]		ask nameserver
XR$+@.$+?$+		$#TCP    $@$3 $:$>28 $1@.$2	relativize & return
XR$+@.$+?$*		$: $1@.$2			no match, remove mark
X
X###
X###	Determine delivery over DECnet
X###	(Kludge: Should relativize too if we had a real DECnet connection)
X###
XR$+@.$+			$: $1@.$2 ? $(D $2 $: $)	check DECnet ta
ble
XR$+@.$+?$=D		$#DECnet $@$3 $:$1@.$2		only return real ones
XR$+@.$+?$*		$: $1@.$2			not found, remove mark
X
X###
X###	Determine delivery over UUCP
X###	(Can't use ruleset 28 since we need to relativize immediate users)
X###
Xifdef({UUCPXTABLE},{
XR$+@.$+			$: $1@.$2 ? $(U $2 $: $)	check UUCP tabl
e
XR$+@.$+?$=U		$: $1@.$3			replace if found real
XR$+@.$+?$*		$: $1@.$2			not found, remove mark
X})
XR$+@.$=U.UUCP		$: $1@.$2.UUCP			remove pseudo domain
XR$+%$+@.$=U		$#UUCP   $@$3 $:$>3 $1%$2	(canonicalize routes)
XR$+@$+@.$=U		$#UUCP   $@$3 $:$>3 $1@$2	(canonicalize routes)
XR$+@.$=U		$#UUCP   $@$2 $:$1		(immediate delivery)
X
X
X#########################################################################
X#									#
X#	Rule Set #27:	Simple %-Path to !-Paths Translator		#
X#									#
X#	Subroutine of other address translators.  Will change a		#
X#	"a!b!c%d%e" path into "e!d!a!b!c".  Typically used when		#
X#	a message have travelled from UUCP-land into Domain land	#
X#	(and back again).						#
X#									#
X#########################################################################
XS27
X
XR$+%$+			$: $1?$2		mark first %
XR$+?$+%$+		$1%$2?$3		find last %
XR$+?$+!$+		$@ $1%$2!$3		this is weird--don't change it
XR$+?$+			$: $2!$>27 $1		put on front and recurse
X
X
X#########################################################################
X#									#
X#	Rule Set #28:	One-level route stripper			#
X#									#
X#	Remove immediate host for routed addresses.  Typically used	#
X#	in ruleset 26 to produce a recipient relative to the immediate	#
X#	host.								#
X#									#
X#########################################################################
XS28
X
XR$+@$+@.$+		$@$>3 $1@$2		relativize & return src route
XR$+%$+@.$+		$@$>3 $1@$2		relativize & return %-path
END_OF_ida/cf/Sendmail.mc
if test 36429 -ne `wc -c <ida/cf/Sendmail.mc`; then
    echo shar: \"ida/cf/Sendmail.mc\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 5 \(of 7\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 7 archives.
    echo "See ida/README and ida/INSTALL for further instructions."
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0