#**********************************************************************
#         Copyright IBM Corporation 1988,1991 - All Rights Reserved
#         For full copyright information see: 'andrew/config/COPYRITE'
#**********************************************************************
# IBM, CARNEGIE MELLON UNIVERSITY, 
# AND THE OTHER COPYRIGHT HOLDERS
#  DISCLAIM ALL WARRANTIES WITH 
# REGARD TO THIS SOFTWARE, INCLUDING 
# ALL IMPLIED WARRANTIES OF MERCHANT-
# ABILITY AND FITNESS. IN 
# NO EVENT SHALL  IBM, CARNEGIE 
# MELLON UNIVERSITY, OR ANY OTHER 
# COPYRIGHT HOLDER BE LIABLE FOR 
# ANY SPECIAL, INDIRECT OR CONSE-
# QUENTIAL DAMAGES OR ANY DAMAGES 
# WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT 
# OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#  $
# ?[POBBRunWarning]
# ?[POBBRunNotice]

%include pobbconfig.defs

%ifdef pobb_RunAMSDelivery

######################
#   general Macros   #
######################

# Postmaster name
DP?[PostmasterName]

# Name of our mail domain
DR?[WorkstationCell]

%ifdef pobbenv_CMU
# Hosts important to the ITC that don't know much about mail
# Class I is for names with no suffixes
CIvm1 pghvm1 cmuplum cmuflamingo
# Class J is for names with the .ITC.CMU.EDU suffix
CJplum vm1 pghvm1
# Class K is for names with the .ANDREW.CMU.EDU suffix
CKplum
%endif pobbenv_CMU

# Class for known-local abbreviations.
CL?[arrlist(SendmailLocalAbbrevs, " ")]

# List of authorized ARPAnet users
######################################################
# WARNING: do not change the name of this class!!!!!
# The name is hard-wired into code in the file conf.c
######################################################
FN?[SendmailConfigDir]/ARPAnet.inhibit

DV3.15

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

# my name
DnMAILER-DAEMON
# UNIX header format
DlFrom $$g  $$d
# delimiter (operator) characters
Do.:%@!^=/[]#
# format of a total name
Dq$$g$$??x ($$x)$$.
# my official hostname
# Dj$$w.$$D.$$U
Dj$$w
# 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 rebuild the alias file automagically
#OD
# Mail back errors
Oem
# temporary file mode -- 0600 for secure mail, 0644 for permissive
OF0600
# default GID
Og1
# location of help file
OH/usr/lib/sendmail.hf
# log level
OL9
# send to me too - experimental
Om
# default messages to old style
#Oo
# queue directory
OQ?[SendmailQueueDir]
# read timeout -- violates protocols
Or20m
# status file
#OS/etc/sendmail.st
# queue up everything before starting transmission
Os
# default timeout interval
OT4d
# default UID
Ou1
# Rule set to use to validate destination addresses in queueing
OV5
# Threshold load average for not starting a new queue processor
OX11
# Threshold load average for queueing requests (instead of sending)
Ox5

###############################
###   Message precedences   ###
###############################

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

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

Tdaemon network ?[arrlist(UsersToAllow)]

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

#H??P??Return-Path: <$$g>
#HReceived: $$??sfrom $$s $$.by $$j ($$v/$$V) id <$$i>; $$b
HReceived: $$??sfrom $$s $$.by $$j ($$v/$$V) id <$$i>$$??u for $$u$$.; $$b
#H??D??Resent-Date: $$a
H??D??Date: $$a
#H??F??Resent-From: $$q
H??F??From: $$q
##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   ###
###########################

################################
#  Sender Field Pre-rewriting  #
################################
S1

###################################
#  Recipient Field Pre-rewriting  #
###################################
S2

###################################
#  ITC: Recipient validation at enqueue time (CFE 19 Mar 87) #
###################################
S5
R$$*<@?[WorkstationCell]>$$*	$$@$$1<@?[WorkstationCell]>$$2	fast pass-through
R$$*<@$$=L>$$*		$$@$$1<@?[WorkstationCell]>$$3	some special-case hosts
%ifdef pobbenv_CMU
R$$*<@$$+.BITNET>$$*	$$@$$1<@$$2.BITNET>$$3	leave Bitnet addresses alone
R$$*<@cmpsya>$$*		$$@$$1<@a.psy.cmu.edu>$$2	some special-case hosts
R$$*<@cmpsyb>$$*		$$@$$1<@b.psy.cmu.edu>$$2	some special-case hosts
R$$*<@cmpsyd>$$*		$$@$$1<@d.psy.cmu.edu>$$2	some special-case hosts
R$$*<@cmuccvma>$$*	$$@$$1<@vma.cc.cmu.edu>$$2	some special-case hosts
R$$*<@vma.cc.cmu.edu>$$*	$$@$$1<@vma.cc.cmu.edu>$$2	some special-case hosts
R$$*<@vb.cc.cmu.edu>$$*	$$@$$1<@vb.cc.cmu.edu>$$2	some special-case hosts
R$$*<@cmccvb>$$*	$$@$$1<@vb.cc.cmu.edu>$$2		some special-case hosts
R$$*<@drycas>$$*		$$@$$1<@drycas.club.cc.cmu.edu>$$2	some special-case hosts
R$$*<@vm1>$$*		$$@$$1<@vm1.itc.cmu.edu>$$2	some special-case hosts
R$$*<@pghvm1>$$*	$$@$$1<@pghvm1.itc.cmu.edu>$$2	some special-case hosts
R$$*<@cmuplum>$$*	$$@$$1<@plum.andrew.cmu.edu>$$2	some special-case hosts
R$$*<@cmuflamingo>$$*	$$@$$1<@plum.andrew.cmu.edu>$$2	some special-case hosts
R$$*<@milvm1>$$*		$$@$$1<@milvm1>$$2		some special-case hosts
%endif pobbenv_CMU
R$$*<@$$+>$$*		$$@$$1<@$$[$$2$$]>$$3	but Validate non-dotted names

###################################
#  Stripping and checking local names  #
#  S8--strip all local names, assuming canonicalization   #
#  S18--canonicalize and call S8   #
#  S19--handle percent signs, canonicalize, and call S8   #
#  S9--add local name if needed, assuming canonicalization #
###################################
S18
# First, make it canonical
R$$*<$$*>$$*		$$1$$2$$3		defocus
R$$+			$$:$$>3$$1		make canonical (find outer host name)
R$$*			$$@$$>8$$1	and return the result of S8

S19
R$$*%$$*			$$:$$1@%@$$2	tag one of the percent signs
R$$*@%@$$+%$$*		$$1%$$2@%@$$3	move tag to the rightmost percent sign
R$$*@%@$$*		$$1@$$2		and replace it with an at-sign.
R$$+			$$:$$>3$$1		make canonical (find outer host name)
R$$*			$$@$$>8$$1	and return the result of S8

S8
# Mail explicitly addressed locally
# foo<@localname> => foo
R$$+<@?[arrlist(PossiblePOs, ">\t$$@$$>18$$1\nR$$+<@")]>	$$@$$>18$$1
R$$+<@$$=L>			$$@$$>18$$1
R$$+<@[?[arrlist(PossiblePOAddrs, "\C>\t$$@$$>18$$1\nR$$+<@\O")]]>	$$@$$>18$$1
# <@localname>:foo => foo
R<@?[arrlist(PossiblePOs, ">:$$+\t$$@$$>18$$1\nR<@")]>:$$+	$$@$$>18$$1
R<@$$=L>:$$+			$$@$$>18$$2
R<@[?[arrlist(PossiblePOAddrs, "\C>:$$+\t$$@$$>18$$1\nR<@\O")]]>:$$+	$$@$$>18$$1

R$$*@$$*			$$@$$1@$$2	Return anything with an at-sign
# Interpret multiple percent signs.
R$$+%$$+			$$@$$>19$$1%$$2	foo%bar%baz => foo%bar@baz
# Now (hack hack) remove UUCP names for local mail, too
# localname!foo => foo
R$$=L!$$+			$$@$$>18$$2
R?[arrlist(PossiblePOs, "!$$+\t$$@$$>18$$1\nR")]!$$+	$$@$$>18$$1

S9
# Check for an outermost local name.
R@				$$@@		leave this as it was, too
R@@$$*			$$@$$1		leave it as it was
R$$+<@?[arrlist(PossiblePOs, ">\t$$@$$1<@$$R>\nR$$+<@")]>	$$@$$1<@$$R>
R$$+<@$$=L>			$$@$$1<@$$R>
R$$+<@[?[arrlist(PossiblePOAddrs, "\C>\t$$@$$1<@$$R>\nR$$+<@\O")]]>	$$@$$1<@$$R>
R<@?[arrlist(PossiblePOs, ">:$$+\t$$@<@$$R>:$$1\nR<@")]>:$$+	$$@<$$R>:$$1
R<@$$=L>:$$+			$$@<@$$R>:$$2
R<@[?[arrlist(PossiblePOAddrs, "\C>:$$+\t$$@<@$$R>:$$1\nR<@\O")]]>:$$+	$$@<@$$R>:$$1

# None there; have to add one.
R$$*<$$*>$$*			$$1$$2$$3			defocus
R$$+@$$+			$$@<@$$R>:$$1@$$2		use source routing
R$$*				$$@$$1<@$$R>		else just append our host name

##################
# S11: strip all local names, canonicalize any host names, add @localname if there's no host.
##################
S11
R@			$$P			errors to postmaster
R$$*			$$:$$>8$$1		Strip all @localname names
R$$*@$$+		$$:$$>5$$1@$$2		canonicalize any host name
R$$*<@$$+>$$*		$$@$$1<@$$2>$$3	return if there's any host name
R$$*			$$@$$1<@$$R>		else append our own.

##################
# S12: strip all local names, canonicalize any host names,
#	add @localname if it's a bitnet host, add @localname if there's no host.
##################
S12
R@			$$P			errors to postmaster
R$$*			$$:$$>8$$1		Strip all @localname names
R$$*<@$$+.BITNET>$$*	$$@<@$$R>:$$1@$$2.BITNET$$3	route replies through us
R$$*@$$+		$$:$$>5$$1@$$2		canonicalize any host name
R$$*<@$$+>$$*		$$@$$1<@$$2>$$3	return if there's any host name
R$$*			$$@$$1<@$$R>		else append our own.

##################
# S22: strip all local names, canonicalize any host names,
#	add @localname if it's a bitnet or itcether host, add @localname if there's no host.
##################
S22
R@			$$P			errors to postmaster
R$$*			$$:$$>8$$1		Strip all @localname names
R$$*@$$+		$$:$$>5$$1@$$2		canonicalize any host name
R$$*<@$$+.BITNET>$$*	$$@<@$$R>:$$1@$$2.BITNET$$3	route replies through us
%ifdef pobbenv_CMU
R$$*<@$$=I>$$*		$$@<@$$R>:$$1@$$2$$3		the three itcether cases
R$$*<@$$=J.itc.cmu.edu>$$*	$$@<@$$R>:$$1@$$2.itc.cmu.edu$$3	the three itcether cases
R$$*<@$$=K.andrew.cmu.edu>$$*	$$@<@$$R>:$$1@$$2.andrew.cmu.edu$$3		the three itcether cases
%endif pobbenv_CMU
R$$*<@$$+>$$*		$$@$$1<@$$2>$$3	return if there's any host name
R$$*			$$@$$1<@$$R>		else append our own.

%ifdef pobbenv_CMU
##################
# S23: strip all local names, canonicalize any host names,
#	add @localname if it's NOT an itcether host, add @localname if there's no host.
##################
S23
R@			$$P			errors to postmaster
R$$*			$$:$$>8$$1		Strip all @localname names
R$$*@$$+		$$:$$>5$$1@$$2		canonicalize any host name
R$$*<@$$=I>$$*		$$@$$1<@$$2>$$3	itcether without domains
R$$*<@$$=J.itc.cmu.edu>$$*	$$@$$1<@$$2.itc.cmu.edu>$$3	itcether with domains
R$$*<@$$=K.andrew.cmu.edu>$$*	$$@$$1<@$$2.andrew.cmu.edu>$$3	itcether with domains
R$$*<@$$+>$$*		$$@<@$$R>:$$1@$$2$$3	Append us: source-route...
R$$*			$$@$$1<@$$R>		...or just add us to end.
%endif pobbenv_CMU

#################################
#  Final Output Post-rewriting  #
#################################
S4
R@			$$@<>		handle <> error addr
R@@$$*		$$@$$1		leave it as it was

# externalize local domain info
R$$*<$$+>$$*		$$1$$2$$3			defocus
R@$$+:@$$+:$$+		@$$1,@$$2:$$3			<route-addr> re-canonical
R@$$+:$$+@$$+		<@$$1:$$2@$$3>			need brackets

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

# handle "from:<>" special case
R<>			$$@@			turn into magic token

# Handle @@ hack (means earlier syntax error)
R@@$$*		$$@@@$$1		just return it

# Look for bogus multiple <>'s
R$$*<$$*<$$*>$$*>$$*	$$@@@$$1<$$2<$$3>$$4>$$5	Stick @@ at front

# basic textual canonicalization
R$$*<$$+>$$*		$$2			basic RFC821/822 parsing
R$$*<>$$*		$$1$$2			drop the bracketed null address
#R$$+ at $$+		$$1@$$2			"at" -> "@" for RFC 822

# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone
# later (in rule S4)
R@$$+,@$$+		@$$1:@$$2			change all "," to ":"

# more miscellaneous cleanup
R$$+:$$*;@$$+		$$@$$1:$$2;@$$3		list syntax is bogus here...
R@$$+:$$+@$$+		$$:<@$$1>:$$2@$$3	source-routing??
R<@$$+:@$$+>:$$+@$$+	<@$$1>:@$$2:$$3@$$4	(use leftmost only)
R<@$$+>:$$+@$$+	$$@<@$$1>:$$2@$$3	done with source routes.
R$$+@$$+		$$:$$1<@$$2>		Else, focus on domain
R$$+<$$+@$$+>		$$1$$2<@$$3>		Rightmost name
R$$+<@$$+>		$$@$$1<@$$2>		already canonical

############################################################
############################################################
#####
#####		Local and Program Mailer specification
#####
############################################################
############################################################

#Mlocal, P=?[vicemail], F=nls, S=10, R=20, A=vicemail -r$$g $$u
Mlocal,	P=?[queuemail], F=nlmuFD, S=10, R=20, A=queuemail -r $$g -i -s -T -A ?[NetworkAuthentication] -a $$u

Mprog,	P=/bin/csh,  F=lsneFD,   S=10, R=20, A=csh -fc $$u

#MXlocal,	P=?[queuemail], F=nlmu, S=11, R=11, A=queuemail -r $$g -i -s -T -a $$u
# Doing host validation of the To: list is taking too long; do a null ruleset rather than
#   validate host names in To: fields as mail comes in for an Andrew recipient.
#MXlocal,	P=?[queuemail], F=nlmu, S=10, R=20, A=queuemail -r $$g -i -s -T -a $$u
# 27 Oct 87 CFE: stop using -s option; leave remote forwarding for other machines.
MXlocal,	P=?[queuemail], F=nlmuFD, S=10, R=20, A=queuemail -r $$g -i -s -T -A ?[NetworkAuthentication] -a $$u
S10
R@			$$P				errors to postmaster

############################################################
############################################################
#####
#####		Ethernet Mailer specifications
#####
############################################################
############################################################

# The ``ether'' mailer is used for CMU SMTP hosts, i.e. ones that aren't restricted.
#Mether,	P=[IPC], F=nmuCXjDF, E=\r\n, S=9, R=26, A=IPC $$h
Mether,	P=[IPC], F=nmuCXjDF, E=\r\n, S=11, R=12, A=IPC $$h

%ifdef pobbenv_CMU
# The ``itcether'' mailer is used for some CMU SMTP hosts that aren't
# restricted (by us), but that don't themselves know about getting mail to general
# Internet hosts.  For these machines, we add our own domain name to many
# source and destination addresses; they know how to get to us.
Mitcether,	P=[IPC], F=nmuCXjDF, E=\r\n, S=23, R=23, A=IPC $$h
%endif pobbenv_CMU

# S21--add a default destination of our local host if it's needed
S21
R$$+			$$:$$>5$$1		go validate host addresses
R$$*<@$$+>$$*		$$@$$1<@$$2>$$3	there's already a host
R$$*			$$@$$1<@$$R>	make reasonable return address

# S26--alter BitNet addresses so they can be replied to on Internet, in addition to adding default
# 18 Mar 87 CFE: canonicalize host names that have no dots in them.
S26
R$$+			$$:$$>5$$1		go validate host addresses
R$$*<@$$+.BITNET>$$*	$$@<@$$R>:$$1@$$2.BITNET$$3	route replies through us
R$$*<@$$+>$$*		$$@$$1<@$$2>$$3	there's already a host
R$$*			$$@$$1<@$$R>	make reasonable return address

# Mailer for sending to BITNET (hack hack)
#Mbitnet,	P=[IPC], F=nmsuCXjDF, E=\r\n, S=9, R=21, A=IPC $$h
Mbitnet,	P=[IPC], F=nmsuCXjDF, E=\r\n, S=11, R=11, A=IPC $$h

%ifdef pobbenv_CMU
# Ether mailer for sending to ARPA net
#####################################################
# WARNING: do not change the name of this mailer!!!!
# It is hard-wired into code in conf.c
#####################################################
#Mexternal, P=[IPC], F=nmuCXjDF, E=\r\n, S=9, R=26, A=IPC $$h
Mexternal, P=[IPC], F=nmuCXjDF, E=\r\n, S=22, R=12, A=IPC $$h
%endif pobbenv_CMU

############################################################
############################################################
#####
#####		RULESET ZERO
#####
############################################################
############################################################

S0

# Look for bad @@ syntax indicator
R@@$$*		$$#error$$@65$$:Illegal syntax: $$1

# handle special case.....
R@			$$#local$$:$$P		handle <> form

# Canonicalize further by stripping off all local host names
R$$*			$$:$$>8$$1

# Special-case host name pattern recognition
# route VNET names throug IBM-SJ
R$$*<@$$+.VNET>	$$1%$$2<@ibm.com>	user@host.vnet

# Now choose a mailer.
# Make a little non-canonical: make extra colons revert to commas
#R<@$$+>$$*:@$$+:$$+	<@$$1>$$2,@$$3:$$4		if brackets on left
#R@$$+:@$$+:$$+	@$$1,@$$2:$$3			if no brackets on left

%ifdef pobbenv_CMU
# Send to special (limited) hosts
R$$*<@$$=I>$$*		$$#itcether$$@$$2$$:$$1<@$$2>$$3
R$$*<@$$=J.itc.cmu.edu>$$*	$$#itcether$$@$$2.itc.cmu.edu$$:$$1<@$$2.itc.cmu.edu>$$3
R$$*<@$$=K.andrew.cmu.edu>$$*	$$#itcether$$@$$2.andrew.cmu.edu$$:$$1<@$$2.andrew.cmu.edu>$$3
%endif pobbenv_CMU

%ifdef pobbenv_CMU
# Hack for BitNet. Send *.BITNET host names to bitnet.cc.cmu.edu instead of VMA.
R$$*<@$$+.BITNET>$$*	$$#bitnet$$@BITNET.CC.CMU.EDU$$:$$1<@$$2.BITNET>$$3
%endif pobbenv_CMU

%ifdef pobbenv_CMU
# Send to local hosts directly.  Official names are in domain .CMU.EDU; addresses are 128.2.*.* .
R$$*<@$$+.CMU.EDU>$$*	$$#ether$$@$$2.CMU.EDU$$:$$1<@$$2.CMU.EDU>$$3
# Numeric Internet spec for CMU-Net
R$$*<@[128.2.$$-.$$-]>$$*	$$#ether$$@[128.2.$$2.$$3]$$:$$1<@[128.2.$$2.$$3]>$$4

# If there's just one host name, it must be local.
R$$*<@$$->$$*		$$#ether$$@$$2$$:$$1<@$$2>$$3

# Pass all other names to #external for the access check.
R$$*<@$$+>$$*		$$#external$$@$$2$$:$$1<@$$2>$$3

%else pobbenv_CMU

# Just send everything non-local to the Ether mailer.
R$$*<@$$+>$$*		$$#ether$$@$$2$$:$$1<@$$2>$$3
%endif pobbenv_CMU

# Everything else (no at-signs) is a local name
R$$+			$$#Xlocal$$:$$1			local names

# Must have fallen through...
R$$*			$$#local$$:$$P

%endif pobb_RunAMSDelivery
