[comp.unix.ultrix] sendmail.cf stuff for ultrix/uucp/decnet/lan

grr@cbmvax.UUCP (George Robbins) (02/05/88)

A few of you may have had the fun of trying to get sendmail to work
"correctly" on Ultrix in a mixed environment.  A while back, Fred Avolio
was nice enough to send me a sendmail.cf that seemed to be a big step
in the right direction.  Of couse it didn't magically solve all my
problems, but served as a base for some late night hacking and confusion.

As with all things sendmail, it not really "correct", but so far no net
police have come to drag me away.  It's here as a "it worked for me" item,
either as a basis for your sendmail.cf file or inspiration for hacking.

Cbmvax is primarily a uucp site, however we have a decnet link to some
VMS systems and a local ethernet including suns, apollos, etc.

The original is pretty much the same as is being distibuted in the with
the smail mailer if you want do use diff to see what areas were changed.
There are a couple of open issues - mostly on whether to add the hostname
and stuff to the minimal addresses on outgoing mail.  For example ruleset
S11 for the ethernet mailer has this commented out, since our local net
is fully aliased and I want to see "grr" in my headers, not some kind of
gruk like "grr@cbmvax.cbm.commodore.com".  Of course this would be dead
wrong if the mail was aimed at the internet.

Major Hacks/Changes/etc.

1) If the destination includes a "known" host, any intevening hops are
   stripped and the mail is sent using the mailer appropriate for that
   host, regardless of what was specified.  A script for extracting
   the known hosts from uucp, ncp and /etc/hosts is provided.  This is
   wrong for cases where a private internal name conflicts with something
   in the outer world, sorry...

2) If an address can't be resolved to something locally deliverable,
   or has routing specified that doesn't start with a known site,
   the mail is dumped on a local site known to be running a "smart",
   rerouting mailer.  Translations for the domain addresses for some
   sites we talk to directly via uucp are hardcoded (lazyness...).

3) The DECnet/Mail11 address stuff (::) got moved and diddled with,
   since it seemed overly specific.


For debugging, you want to just run /usr/lib/sendmail directly, specifying
suitable debugging options.  The one that lets you type in rule,address
pairs is partiularly useful, once you understand that it applies, if I
remember,  ruleset 0 before any you specify and ruleset 4 afterwards.
This may seem goofy, but it's the same what happens to all address in
normal processing.

					George


############################################################
############################################################
#####
#####		SENDMAIL CONFIGURATION FILE
#####
#####	UUCP project prototype: supports domain style 
#####   addressing over UUCP and ethernet links.
#####
#####   A product of the UUCP Project.
#####
#####   Somewhat Mutilated by cbmvax!grr
#####
#####		@(#)sendmail.cf	1.7  (UUCP-Project/CS)  5/18/86
#####
############################################################
############################################################


############################################################
###
###  Local configuration options - HINTS
###

# Host name and domain name macros.  Dw set $w, DD sets $D, and
# CD sets $=D.  Most sendmails set $w to `hostname`, so you can 
# probably leave out Dw.  $D and $=D lists all domains in which this 
# host sits, and $D goes into outbound addresses, i.e. "user@$w.$D".
# $A is another domain for which this host is authoratative, which
# will be turned into $D.

#Dwhost
#DDYour.domain
DDUUCP
DAARPA
CDcbmvax.commodore.com commodore.com amber.ether 

# Preemptive ether and UUCP connections.  We prefer these connections 
# over both designated transport mechanisms and the general depository.
# You can add more classes (here and in S0).

# these are extracted daily by /usr/local/lib/hosts.extract

FE/usr/local/lib/hosts.tcp %s
FU/usr/local/lib/hosts.uucp %s
FG/usr/local/lib/hosts.dnet %s

# Mock top-level domain names.  These name designate a transport mechanism
# and appear internally only, set in S3, used in S0, and removed in S4 and
# (possibly) the ruleset for the particular mailer.  

CTETHER UUX DNET

# Relay host.  Used at the end of S0 as the general depository for 
# addresses which didn't resolve locally.  

DRrutgers

###
###  End Local configuration options
###
############################################################

############################################################
#
#	General configuration information
#
#	This information is basically just "boiler-plate"; it must be
#	there, but is essentially constant.
#
#	Information in this file should be independent of location --
#	i.e., although there are some policy decisions made, they are
#	not specific to Berkeley per se.
#
#		@(#)base.m4	4.3		8/30/83
#
############################################################

DVUUCP-Project/Commodore 12/21/87)

##########################
###   Special macros   ###
##########################

# official hostname
Dj$w.$D
# my name
DnMAILER-DAEMON
# UNIX header format
DlFrom $g  $d
# delimiter (operator) characters
#Do.:%@!^=/[]\ 
Do.:%@!^=/[]
# format of a total name
Dq$g$?x ($x)$.
# SMTP login message
De$j Sendmail $v/$V ready at $b


###################
###   Options   ###
###################

# location of alias file
OA/usr/lib/aliases
# default delivery mode (deliver in background)
Odbackground
# (don't) connect to "expensive" mailers
#Oc
# temporary file mode
OF0644
# default GID
Og1
# location of help file
OH/usr/lib/sendmail.hf
# log level
OL6
# default messages to old style
Oo
# queue directory
OQ/usr/spool/mqueue
# read timeout -- violates protocols
Or2h
# status file
OS/usr/lib/sendmail.st
# queue up everything before starting transmission
Os
# default timeout interval
OT3d
# time zone names (V6 only)
OtEST,EDT
# default UID
Ou1
# wizard's password
OWXCLKNM7zV4o/o
###############################
###   Message precedences   ###
###############################

Pfirst-class=0
Pspecial-delivery=100
Pjunk=-100

#########################
###   Trusted users   ###
#########################

Troot
Tdaemon
Tuucp
Tnetwork

#############################
###   Format of headers   ###
#############################

#H?P?Return-Path: <$g>
HReceived: $?sfrom $s 
	$.by $j ($v/$V)
	id $i; $b
H?D?Resent-Date: $a
H?D?Date: $a
H?F?Resent-From: $q
H?F?From: $q
H?x?Full-Name: $x
HSubject:
# HPosted-Date: $a
# H?l?Received-Date: $b
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>

############################################################
############################################################
#####
#####		REWRITING RULES
#####

###########################
#  Name Canonicalization  #
###########################
S3

# basic textual canonicalization
R<>			$@@				turn into magic token
R$*<$+>$*		$2				basic RFC821/822 parsing
R$+ at $+		$1@$2				"at" -> "@" for RFC 822

# DECUAC -- additional for DECnet gateway
#R$=w::$-		$2@$j
#R$=w::$+		$2
#R$*::$+@$*.$*		$2@$3.$4
#R$-::$-		$2@$1.$D
#R$-%$-.DNET		$1@$2.$D
#R$-@$-.DNET		$1@$2.$D

# don't watch (local aliasing)

R$*!uunet.uu.net!$*	$1!uunet!$2
R$*!rutgers.edu!$*	$1!rutgers!$2
R$*!bpa.bell-atl.com!$*	$1!bpa!$2
R$*!udel.edu!$*		$1!udel!$2
R$*@uunet.uu.net$*	$1@uunet$2
R$*@rutgers.edu$*	$1@rutgers$2
R$*@udel.edu$*		$1@udel$2

R$*<$*>$*		$1$2$3				in case recursive

# This is moved up here to avoid other : confusion - who cares about priority?
# This chops paths that are in our local decnet lists

R$+::$=G::$+		$2::$3			Shorten to sites in show nodes
R$+::$=w::$+		$2::$3			Same as above for our site
R$*$=w.$=D$*::$+	$2::$5
R$+::$=w::$+		$2::$3

R$-::$+			$@$2<@$1.DNET>			resolve decnet names
R$+.::$+		$@$2<@$1>			domain.::host
R$+::$+			$@$2<@$1>			domain::host

# handle route-addr <@a,@b,@c:user@d> 
R@$+,$+			@$1:$2				change all "," to ":"
R@$+:$+			$@<@$1>:$2			handle <route-addr>
R$+:$*;@$+		$@$1:$2;@$3			list syntax

# Rewrite address into a domain-based address.  Any special mock domain names 
# (like UUX) should be defined on the CT line and removed (if necessary) 
# in S4.  You can use them in S0 for designated transport mechanisms.

# Delimiters with precendence over @.  Add yours here.

# The @ delimiter.  Leave this alone.
R$+@$+			$:$1<@$2>			focus on domain
R$+<$+@$+>		$1$2<@$3>			move gaze right
R$+<@$+>		$@$1<@$2>			already canonical

# Delimiters with precendece below @.  Add yours here.
R$+^$+			$1!$2				convert ^ to !
# try to correct \! inconsistancy between csh and mail
# turns out it has to be done in sendmail...
#R$+\!$+		$1!$2				doesn't work...

# This chops paths that are in our local L.sys

R$+!$=U!$+		$2!$3			Shorten to sites in L.sys
R$+!$=w!$+		$2!$3			Same as above for our site

# trim excess uucp domain stuff

R$*$=U.$=D$*!$+		$2!$5			
R$*$=U.$D$*!$+		$2!$4			
R$*$=U.$A$*!$+		$2!$4			
R$*$=w.$=D$*!$+		$5			
R$*$=w.$D$*!$+		$4			
R$*$=w.$A$*!$+		$4			

#R$+::$=w::$+		$2!$3			single hop decnet

R$-!$+			$@$2<@$1.UUX>			resolve uucp names
R$+.!$+			$@$2<@$1>			domain.!host
R$+!$+			$@$2<@$1>			domain!host

# % is a low precedence @.
R$*%$*			$@$>3$1@$2			%->@ and retry

############################################################
############################################################
#####
#####		RULESET ZERO PREAMBLE
#####
#####		UUCP Project 11/01/85
#####
############################################################
############################################################

S0

# first make canonical
R$*<$*>$*		$1$2$3				defocus
R$+			$:$>3$1				make canonical

# handle special cases.....
R@			$#local$:MAILER-DAEMON		handle <> form
R$*<@[$+]>$*		$#tcp$@[$2]$:$1@[$2]$3		numeric internet spec

# strip local stuff
R$*<$*$w.$D>$*		$1<$2>$3			thishost.mydom
R$*<$*$w.$=D>$*		$1<$2>$4			thishost.anydom
R$*<$*$w.$A>$*		$1<$2>$3			thishost.anotherdom
R$*<$*$w.$=T>$*		$1<$2>$4			thishost.mockdom
R$*<$*$w>$*		$1<$2>$3			thishost
R$*<$*.>$*		$1<$2>$3			drop trailing dot
R<@>:$+			$@$>0$1				strip null route, retry
R$+<@>			$@$>0$1				strip null addr, retry


###############################################
###  Machine dependent part of rulset zero  ###
###############################################

# Preemption: for a host on a known link turn the domain spec into a
# mock domain indicating the link.  One set of these rules for each of 
# the F classes listed in the local configuration options.

R$*<$*$=U.$D>$*			$:$1<$2$3.UUX>$4	uuxhost.mydomain
#R$*<$*$=U.$=D>$*		$:$1<$2$3.UUX>$5	uuxhost.anydomain
#R$*<$*$=U.$A>$*		$:$1<$2$3.UUX>$4	uuxhost.anotherdomain
#R$*<$*$=U.$=T>$*		$:$1<$2$3.UUX>$5	uuxhost.mock-domain
R$*<$*$=U>$*			$:$1<$2$3.UUX>$4	uuxhost

R$*<$*$=E.$D>$*			$:$1<$2$3.ETHER>$4	etherhost.mydomain
R$*<$*$=E.$=D>$*		$:$1<$2$3.ETHER>$5	etherhost.anydomain
R$*<$*$=E.$A>$*			$:$1<$2$3.ETHER>$4	etherhost.anotherdomain
R$*<$*$=E.$=T>$*		$:$1<$2$3.ETHER>$5	etherhost.mock-domain
R$*<$*$=E>$*			$:$1<$2$3.ETHER>$4	etherhost

R$*<$*$=G.$D>$*			$:$1<$2$3.DNET>$4	decnet.mydomain
R$*<$*$=G.$=D>$*		$:$1<$2$3.DNET>$5	decnet.anydomain
R$*<$*$=G.$A>$*			$:$1<$2$3.DNET>$4	decnet.anotherdomain
R$*<$*$=G.$=T>$*		$:$1<$2$3.DNET>$5	decnet.mock-domain
R$*<$*$=G>$*			$:$1<$2$3.DNET>$4	decnet

# Designated delivery: use the indicated transport mechanism.  One of
# these rules for each of the mock domains defined in $=T.  You can
# remove these if you just want general disposition.  HINTS.

# Designated delivery:

R$-::$+			$#Dmail$@$1$:$2				muti-hop decnet
R$+<@$+.DNET>		$#Dmail$@$2$:$1
R$+<@$+.DNET.$*>	$#Dmail$@$2$:$1

R$*<@$=U.UUX>$*		$#uux$@$2$:$1$3			known uucphost
R$*<@$+.ETHER>$*	$#ether$@$2$:$1@$2$3		etherhost

# throw out mock domain name now
R$*<$*.$=T>$*		$1<$2>$4

# General disposition of remote mail (comment out all but one).  You
# might add to this list, if you have other "smarter" mailers.  HINTS.

#R$*<@$*>$*		$#uux$@$2$:$1$3			hand to uucp
R$*<@$*.$*>$*		$#uux$@$R$:$1@$2.$3$4		hand to domain relay
R$*<@$*>$*		$#uux$@$R$:$2$3!$1		hand to uucp relay
#R$*<@$*>$*		$#ether$@$R$:$1@$2$3		hand to ether relay
#R$*<$*>$*		$#error$:unkown address $1$2$3	don't hand anywhere

# local delivery
R$+			$#local$:$1			user

############################################################
############################################################
#####
#####		Local and Program Mailer specification
#####
#####		@(#)localm.m4	4.1		7/25/83
#####
############################################################
############################################################

Mlocal,	P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u
Mprog,	P=/bin/sh,   F=lsDFMe,   S=10, R=20, A=sh -c $u

S10
R@			MAILER-DAEMON			errors to mailer-daemon

############################################################
############################################################
#####
#####		UUCP Mailer specification
#####
#####		UUCP Project 11/01/85
#####
############################################################
############################################################


# Top two lines use uux, bottom two use smail.  For UUCP to handle domain 
# style addressing, you must use smail.  HINTS.

Muux,	P=/usr/bin/uux, F=sDFMmuU, S=13, R=23, M=100000,
	A=uux - $h!rmail ($u)
#Muux,	P=/bin/smail, F=sDFMhum, S=14, R=24, M=100000,
#	A=smail -vrH$j $h!$u

MDmail, P=/usr/bin/mail11, F=mnsF, S=15, R=25, A=mail11 $f $x $h $u

# S13 rewrites return addresses for uux as smail would: turn "user" into 
# "host!user" and "user@domain" to "host!domain!user".  Unfortunately,
# this also affects the From: line (which is wrong).

S13
R$+<@$w.UUX>		$@$1<@$w.UUX>			intercept 2nd pass
R$+			$:$>4$1				externalize
R$*@$*			$2!$1				a@b -> b!a
R$+			$@$1<@$w.UUX>			tack on our name

S14
#R$+<@$=E>		$1			u@cbpavo->u/CBOSGD
R$*<@$+>$*		$@$1<@$2>$3		already ok
#R$+			$@$1<@$w>		tack on our hostname
R$+			$@$1<@$j>		tack on our full address

S15
#R$*<@$=G.$D>$*		$@$2::$:$1		decnetize it...
#R$*<@$+>$*		$@$1<@$2>$3		already ok


############################################################
############################################################
#####
#####		SMTP ethernet mailer
#####
#####		UUCP Project 11/01/85
#####
############################################################
############################################################

Mether,	P=[IPC], F=msDFMuXP, S=11, R=21, A=IPC $h

S11
R$*<@$+>$*		$@$1<@$2>$3		already ok
#R$+			$@$1<@$w>		tack on our hostname
#R$+			$@$1<@$j>		tack on our full address


#################################
#  Final Output Post-rewriting  #
#################################

# This rewrites the internal $=T mock domains into their external form.
# The default is to replace the mock domain name with $D.  The last
# two lines are stock.

S4
R@			$@				handle <> error addr
R$+<@$-.UUX>		$2!$1				u@host.UUX => host!u
R$*!$*%$*		$1!$3!$2			do %'s...
R$+<@$-.DNET>		$2::$1				u@host.DNET => host::u
R$*::$*%$*		$1::$3::$2			do %'s...
R$*<$*$=T>$*		$:$1<$2$D>$4			change local info
R$*<$+>$*		$1$2$3				defocus
R@$+:$+:$+		$@@$1,$2:$3			<route-addr> canonical




#! /bin/sh
# /usr/local/lib/hosts.extract
# this basically tries to find the names of local nodes so that the
# the sendmail.cf can cut any intermediate hops and get the stuff
# where it should go.
#
# the output is just files containing lists of names, one per line.
# if your configuration is simple and static, save work and just
# key them in and forget about this script.
#
# note that it could use more work - awk would be a lot less messy
# than sed, and you should add steps to delete things like terminal
# servers and bogus ethernet hosts from the lists, but I haven't
# had enough problems to get activated...

#
# find known decnet nodes, some of which might be mail hosts
#
/usr/bin/ncp show known nodes | \
 sed -n -e '/^[ 	]*[0-9][0-9]*\.[0-9][0-9]*/s/^[ 	]*[0-9][0-9]*\.[0-9][0-9]*[ 	]*(\([^ 	)]*\)).*$/\1/p' -e '/^$/d' \
   > /usr/local/lib/hosts.temp
mv /usr/local/lib/hosts.temp /usr/local/lib/hosts.dnet

#
# find uucp links, some of whom we really talk to, leaves duplicates...
#
uuname | sed -e '/^cbmvax$/d' -e '/^$/d' > /usr/local/lib/hosts.temp
mv /usr/local/lib/hosts.temp /usr/local/lib/hosts.uucp

#
# find known ethernet hosts, should exclude common aliases
#
sed -e '/^#/d' -e 's/^[0-9. 	]*//' -e 's/	/ /g' -e 's/  / /g' -e 's/ *$//' -e '/^$/d' /etc/hosts | \
 tr " " "\012" > /usr/local/lib/hosts.temp
mv /usr/local/lib/hosts.temp /usr/local/lib/hosts.tcp