[comp.mail.sendmail] UMIST patches

jf@ap.co.umist.ac.uk (John Forrest) (11/22/90)

Dear All,
   This is the second part of the sendmail patches - see the comment at
the top of part 1, as well as below. Any problems? Well.....

John





These patches to sendmail/src and ida/cf fullfil the following:

	Accept Addresses in Reverse (UK) format - partly due to
		Neil Rickert.
	OPtion to not send to RELAY_HOST if unknown domain.
	Support for built-in top domain class `t'.
		- used to determine if name is full, and thus to
		  reset RES_DNSRCH and RES_DEFNAMES.
	Support for incomplete BIND tables 
		- not really for use with internet.
	Support for resolving names that contain more than one CNAME
		element (eg. apollo.computation.umist.ac.uk ->
		ap.co.umist.ac.uk) as BINDv4.6 does not do this.
	Fixes for apollo - OS10.1 at least.
	Fix for putline bug (apollo and others).
	Fix to allow Apollo's to update aliases - up to the system
		manager to ensure each node has its own /usr/lib/mail
		directory.
	Make "no .fc found" syslog message optional.
	Fixes in case NAMED_FIND is false (not tested).
	Calling gethostbyname before getcanonname is optional -
		will only do if there are problems with the server.
	Allow the datafile names, eg. .cf, .fc etc, to be overridden
		in conf.h.

To Install:
	The patches in the file relate to sendmail/ida/cf - so first
	go to your ida/cf directory. The patches were created
	with ``diff -b'', so you will need to use the -l flag with
	patch:
		patch -l < "thisfile"

	When you have installed things, you will need to check
	through Sendmail.mc, and decide if the new options apply to 
	your system. I have distributed our current config,
	ap.co.m4, for information. The problems of setting things
	up in the UK are described in README.uk. However, it should
	be noted there are some other changes - the new default
	top domain class is ``t'' not ``T'', and if you make the
	src patches accompanying this, you will need to install
	a cf file based on these patches. NB. If anyone needs the
	ac.uk.domain file, and can't otherwise generate it, we
	can provide one - although I wont vouch for its accuracy.

John Forrest
Dept of Computation
UMIST
11/90.

*** README.uk	Mon Nov 19 22:02:18 1990
--- README.uk	Mon Nov 19 17:49:36 1990
***************
*** 0 ****
--- 1,85 ----
+ IDA and UK Grey-Book Addresses
+ ========================
+ 
+ This version of the IDA contains limited capability for coping
+ with reversed (Grey-Book) UK style addresses. For example, the
+ address "ap.co.umist.ac.uk" is, in traditional UK terms,
+ "uk.ac.umist.co.ap". There are several options, but it is
+ suggested you don't use any unless your circumstances require
+ them. The options cope with the following levels:
+ 
+ Level 1  Allow incomming addresses in Grey-Book format.
+ -------
+ 
+         If, after all other canonical lookups, a name starts with a top
+         domain, but does not finish with one, eg:
+ 
+                 uk.ac.umist
+ 
+         reverse and try again. This is enabled with:
+ 
+                 define(UKORDER)dnl
+ 
+         in the .m4 file. It should be noted that the thinking behind
+         this is that all addresses will have been fully expanded by the
+         previous mailer.
+ 
+ Level 2  Allow local users to give incomplete mail specifications.
+ -------
+         In addition to the above:
+ 
+         Provide a mail prefix and contents of class K, such
+         that if the last element is not a top domain, and the
+         first is in class K, we prepend the prefix and try
+         again. It is intended that the prefix is uk.ac, and the
+         class the contents of ac.uk, but you could use others.
+         For example,
+                 umist.ee -> uk.ac.umist.ee
+         the latter is then manipulated by level 1:
+                 uk.ac.umist.ee -> ee.umist.ac.uk
+ 
+         This level is enabled by defining:
+ 
+                 define(UK_RETRY_PREFIX, uk.ac)dnl
+                 define(UK_RETRY_CLASS, LIBDIR/ac.uk.names)
+ 
+         Level 1 must also be enabled.
+ 
+ Note that no provision is made for sending mail in UK format -
+ if any UK mailer will really not accept RFC format, then a
+ special mailer and delivery rules will be required!
+ 
+ A further problem is that neither of these levels can cope with
+ a set of problem cases where the local element happens to be
+ in the top domain list. For example:
+ 
+         uk.ac.man.cs
+         umist.ch
+         uk.ac.ox.ph
+         ucl.cs
+ 
+ To get around these, you will need to add them as synonyms in
+ the domaintable. For level 1, add:
+ 
+ cs.man.ac.uk          uk.ac.man.cs
+ ch.umist.ac.uk        uk.ac.umist.ch
+ etc.
+ 
+ For level 2, add:
+ 
+ cs.man.ac.uk          uk.ac.man.cs man.cs
+ ch.umist.ac.uk        uk.ac.umist.ch umist.ch
+ etc.
+ 
+ You have to hope that these arn't real synonyms, which gets us
+ to the crux of the problem. It is recommended that level 2 is
+ only used for a transitional period, and even level 1 is best
+ left out if and when you know the mailers that contact you
+ always use RFC format.
+ 
+ John Forrest
+ Dept of Computation
+ UMIST
+ 18/11/90
+ 
+ UKORDER due to Neil Rickert.
*** Sendmail.mc	Sun Oct 14 00:54:40 1990
--- Sendmail.mc	Sun Nov 18 16:00:21 1990
***************
*** 190,199 ****
--- 190,206 ----
  #		be needed in ALTERNATENAMES to strip source routes.
  #	DOMAINTABLE
  #		Dbm database used for hostname canonicalization, ie.
  #		to find the official domain name for local or otherwise
  #		unqualified hosts.
+ #	DONT_RELAY_UNKOWNS
+ #		Normally if RELAY_HOST is given, any unknown adddress
+ #		is sent there. Defining this option will not relay addresses
+ #		whose last element is not in the TOP_DOMAIN_CLASS. This
+ #		saves unnecessary traffic, but it does put the burden
+ #		on this host of resolving any reasonable partial address.
+ #		-- John.Forrest@umist.ac.uk
  })dnl ### End of M4COMMENTS ###
  ifdef({M4COMMENTS},{dnl  -Divided this to avoid overflowing m4 buffer.
  #	FORCE_NAMED
  #		Set the I flag to force host name lookups to go through the
  #		domain name server.  Otherwise if the nameserver isn't
***************
*** 301,316 ****
--- 308,349 ----
  #		precedence of !/@.  It former function is now the default
  #		except for UUCP nodes identified in UUCPPRECEDENCE.
  #	TCPMAILER
  #		The default TCP mailer to use for SMTP/TCP deliveries.
  #		Defaults to TCP (as opposed to TCP-D or TCP-U, qv).
+ #	TOP_DOMAIN_CLASS
+ #		This is the name of the top domain class. The new
+ #		default for this is "t" - which is required if
+ #		sendmail has been compiled with TOP_DOMAIN_CLASS
+ #		set to that. Otherwise, you may prefer to use T
+ #		if you have a modified sendmail that uses class t
+ #		for something else. -- John.Forrest@umist.ac.uk
+ })dnl ### End of M4COMMENTS ###
+ ifdef({M4COMMENTS},{dnl  -Divided this to avoid overflowing m4 buffer.
  #	TRUSTEDUSERS
  #		Trusted users to be added to users root daemon uucp.
  #	UIUC
  #		Site specific parts for the University of Illinois at
  #		Urbana-Champaign.  Replaces UUCP mailer with one one that
  #		accumulates statistics.
+ #	UKORDER
+ #		Some mailers, particularly in the UK, send out
+ #		addresses in reverse order. With the option defined,
+ #		if initial host lookup fails, it tries reversing
+ #		the name before trying again. It currently only
+ #		does this if the last name is not a top domain and
+ #		the first one is. You are advised not to use this
+ #		option unless you really need to.
+ #	UK_RETRY_CLASS
+ #	UK_RETRY_PREFIX
+ #		Slight mod to the above, if that fails, check to
+ #		see if the first element is in UK_RETRY_CLASS and
+ #		the last element of the address is
+ #		in TOP_DOMAIN_CLASS. If so, put this string on the
+ #		front and try again. For UK universities etc. use uk.ac
+ #		To avoid infinite recursion, the first element of this
+ #		string MUST be in TOP_DOMAIN_CLASS.
  #	UUCPMAILER
  #		The default UUCP mailer to use for UUCP deliveries.
  #		Defaults to UUCP (as opposed to UUCP-A or UUCP-B, qv).
  #	UUCPNAME
  #		This node's UUCP host name.
***************
*** 368,377 ****
--- 401,413 ----
  #	CH	Node names that should be hidden by $w
  })dnl
  ifdef({ISOLATED_DOMAINS},{dnl
  #	CI	Isolated net names
  })dnl
+ ifdef({UK_RETRY_CLASS},{dnl
+ #	CK	List of known sites within UK_RETRY_PREFIX
+ })dnl
  ifdef({ALTERNATENAMES},{dnl
  #	CM	A list of alternate mail names for which we make final delivery.
  })dnl
  ifdef({PSEUDODOMAINS},{dnl
  #	CP	Known top level pseudo domains
***************
*** 429,438 ****
--- 465,475 ----
  ifelse(len(UUCPPRECEDENCE),0,
  	{errprint({Note: UUCPPRECEDENCE requires a list. See Sendmail.mc})
  	undefine({UUCPPRECEDENCE})})dnl
  define(CLASS_TYPE,{ifelse(index($1,|),0,{F},index($1,/),0,{F},{C})})
  define(SET_CLASS,{CLASS_TYPE($2)}{$1$2})
+ ifdef({TOP_DOMAIN_CLASS},,{define(TOP_DOMAIN_CLASS, t)})dnl
  
  #
  ##########################################################################
  ## Domain Definitions ####################################################
  ##########################################################################
***************
*** 439,455 ****
  
  ##########################################################################
  #	Universally known top-level domains
  
  #					Organizational domains
! CTarpa com edu gov int mil nato net org
  #					National domains
! CTar at au be br ca ch cl de dk es fi fr gr hk ie il in is it
! CTjp kr kw lk mx my ni nl no nz pl pr pt se sg th tw uk us yu
  #					Network based domains
  # NS records don't exist for these
! CTbitnet csnet uucp
  
  ##########################################################################
  #	Well-known pseudo domains
  #	(that the resolver shouldn't be bothered with)
  ifdef({PSEUDODOMAINS},{dnl
--- 476,492 ----
  
  ##########################################################################
  #	Universally known top-level domains
  
  #					Organizational domains
! {C}TOP_DOMAIN_CLASS{}arpa com edu gov int mil nato net org
  #					National domains
! {C}TOP_DOMAIN_CLASS{}ar at au be br ca ch cl de dk es fi fr gr hk ie il in is it
! {C}TOP_DOMAIN_CLASS{}jp kr kw lk mx my ni nl no nz pl pr pt se sg th tw uk us yu
  #					Network based domains
  # NS records don't exist for these
! {C}TOP_DOMAIN_CLASS{}bitnet csnet uucp
  
  ##########################################################################
  #	Well-known pseudo domains
  #	(that the resolver shouldn't be bothered with)
  ifdef({PSEUDODOMAINS},{dnl
***************
*** 487,496 ****
--- 524,538 ----
  # This node's official domain name
  ifdef({DEFAULT_DOMAIN},
  {Dj$w.}DEFAULT_DOMAIN,
  Dj$w)
  
+ ifdef({UK_RETRY_CLASS},{dnl
+ # Known members of reversed UK_RETRY_PREFIX
+ SET_CLASS({K}, UK_RETRY_CLASS)
+ })dnl
+ 
  # Name of the grandparent domain
  ifdef({ALTERNATENAMES},{
  {CM}ALTERNATENAMES
  },{dnl
  ifdef({DOMAINMASTER},{dnl
***************
*** 905,915 ****
  R<@$+>$+?$+		$@<@$1>$2			Yes - return.
  R<@$+>$+?		$:<@$1>$2?$&h			Add recipient host.
  },{dnl ### Not UUCPXTABLE ###
  R<@$+>$+		$:<@$1>$2?$&h			Add recipient host.
  })dnl ### End UUCPXTABLE ###
! R<@$+.$=T>$+?$-		$@<@$4>!@$1.$2$3		Add route to domain.
  R<@$+>$+?$*		<@$1>$2				Remove mark.
  
  # Define a quote macro.  This is the only way to put '"' into an address.
  # and even then we must use $&Q, not $Q
  DQ\"
--- 947,957 ----
  R<@$+>$+?$+		$@<@$1>$2			Yes - return.
  R<@$+>$+?		$:<@$1>$2?$&h			Add recipient host.
  },{dnl ### Not UUCPXTABLE ###
  R<@$+>$+		$:<@$1>$2?$&h			Add recipient host.
  })dnl ### End UUCPXTABLE ###
! R<@$+.$=TOP_DOMAIN_CLASS>$+?$-		$@<@$4>!@$1.$2$3		Add route to domain.
  R<@$+>$+?$*		<@$1>$2				Remove mark.
  
  # Define a quote macro.  This is the only way to put '"' into an address.
  # and even then we must use $&Q, not $Q
  DQ\"
***************
*** 998,1017 ****
  R<$*>$+			$:$>26 <$1>$2			now look for mailer
  R$#$+			$# $1				success, return it
  })dnl ### End of PATHTABLE ###
  
  ifdef({RELAY_HOST}, {# If we have a RELAY_HOST/RELAY_MAILER, use it
  R<@$+>$+		${#}RELAY_MAILER $@RELAY_HOST $:<@$1>$2
  })dnl
  
  # Try TCP/IP otherwise, there might be an MX record for it
  # (I wish I had a $[..$] for MX records)
  R<@$+.$~P>$+		{$#}TCPMAILER $@$1.$2 $:<@$1.$2>$3
  
  # Undeliverable recipients--complain loudly & return to sender
  R<@$->$+	$#ERROR $:Host $1 not known--please specify domain
! R<@$-.$*$=T>$+	$#ERROR $:Host $1 not known within the $2$3 domain
  R<@$+.$->$+	$#ERROR $:Domain $2 not known--please try to route manually
  R@$+		$#ERROR $:"Incomplete Source Route--use <...> format"
  R$*		$#ERROR $:Could not parse $1
  
  
--- 1040,1062 ----
  R<$*>$+			$:$>26 <$1>$2			now look for mailer
  R$#$+			$# $1				success, return it
  })dnl ### End of PATHTABLE ###
  
  ifdef({RELAY_HOST}, {# If we have a RELAY_HOST/RELAY_MAILER, use it
+ ifdef({DONT_RELAY_UNKNOWNS}, {# but don't relay unknown top domains
+ R<@$+.$~TOP_DOMAIN_CLASS>$+		${#}ERROR $:Domain $2 unknown for address $1.$2
+ })dnl
  R<@$+>$+		${#}RELAY_MAILER $@RELAY_HOST $:<@$1>$2
  })dnl
  
  # Try TCP/IP otherwise, there might be an MX record for it
  # (I wish I had a $[..$] for MX records)
  R<@$+.$~P>$+		{$#}TCPMAILER $@$1.$2 $:<@$1.$2>$3
  
  # Undeliverable recipients--complain loudly & return to sender
  R<@$->$+	$#ERROR $:Host $1 not known--please specify domain
! R<@$-.$*$=TOP_DOMAIN_CLASS>$+	$#ERROR $:Host $1 not known within the $2$3 domain
  R<@$+.$->$+	$#ERROR $:Domain $2 not known--please try to route manually
  R@$+		$#ERROR $:"Incomplete Source Route--use <...> format"
  R$*		$#ERROR $:Could not parse $1
  
  
***************
*** 1106,1116 ****
  ifdef({LIUIDA},{
  Renea!$+!!$+,!$+	enea!$1!!$2,@$3		brutally beaten src route
  Renea!$+!!$+:$+!$+	$: enea!$1!$2!$4!$3	seriously smashed src route
  Renea!$+!!$+		$: enea!@$2@$1		maddenly messy src route
  })
! R$+@$+.$=T.UUCP		$1@$2.$3		strip UUCP off foo@bar.EDU.UUCP
  
  # Fix %-kludgified RFC822 source routes (double sigh)
  R$+!%$+:$+%$+		$1!%$2:$3@$4		change all %'s into @'s
  R$+!%$+,%$+		$1!%$2,@$3
  R$+!%$+			$1!@$2
--- 1151,1161 ----
  ifdef({LIUIDA},{
  Renea!$+!!$+,!$+	enea!$1!!$2,@$3		brutally beaten src route
  Renea!$+!!$+:$+!$+	$: enea!$1!$2!$4!$3	seriously smashed src route
  Renea!$+!!$+		$: enea!@$2@$1		maddenly messy src route
  })
! R$+@$+.$=TOP_DOMAIN_CLASS.UUCP		$1@$2.$3		strip UUCP off foo@bar.EDU.UUCP
  
  # Fix %-kludgified RFC822 source routes (double sigh)
  R$+!%$+:$+%$+		$1!%$2:$3@$4		change all %'s into @'s
  R$+!%$+,%$+		$1!%$2,@$3
  R$+!%$+			$1!@$2
***************
*** 1436,1445 ****
--- 1481,1498 ----
  R<$+?$+>$+		<$1.UUCP>$3			Add .UUCP if known
  },{ifdef({PATHTABLE},{dnl ### PATHTABLE and MAILERTABLE ###
  R<$+?$+>$+		<$1.UUCP>$3			Add .UUCP if known
  })})dnl ### End of PATHTABLE/MAILERTABLE ###
  })dnl ### End Not BANGONLYUUCP ###
+ ifdef({UKORDER},{dnl ### Deal with broken reversed addresses ###
+ R<$=X$=TOP_DOMAIN_CLASS.$*$~TOP_DOMAIN_CLASS?>$+	<$1$3$4?.$2>$5			Possible UK order - Move Top domain to end.
+ R<$=X$+.$+?.$+>$+	<$1$3?.$2.$4>$5			Reverse levels
+ R<$=X$+?.$+>$+		$@$>8<$1$2.$3>$4		Canonicalize
+ ifdef({UK_RETRY_PREFIX},{dnl ### Try putting UK_RETRY_PREFIX on front
+ R<$=X$=K.$*$~TOP_DOMAIN_CLASS?>$+	$@$>8<$1UK_RETRY_PREFIX.$2.$3$4>$5		Possible non-full UK order, try full equivalent
+ })dnl ### End UK_RETRY_PREFIX ###
+ })dnl ### End UKORDER ###
  R<$*?$*>$*		<$1$2>$3			Remove marker
  
  #########################################################################
  #									#
  #	Rule Set #9:    Isolate the user portion of an address		#
***************
*** 1600,1610 ****
  #									#
  #########################################################################
  S23
  
  R<$+>$*$=Y$~A$*		$:<$1>$2$3?$4$5		Mark user portion of address
! R<$+>$+.$=T$=Y$*?$+	<$1$2.$3>$4$5?$6	Find last top level domain.
  ifdef({UUCPRELAYS},{dnl
  R<$+>$+@$=R!$*?$+	<$1$2@$3>!$4?$5		Find last well known UUCP relay
  })dnl ### End UUCPRELAYS ###
  R$*<$+@$+>$+		$1$2<@$3>$4		Find start of that domain.
  R$=X$+<@$+>$+?$+	$:$>8<$1$3>$4?$5	Trim leading part, requalify.
--- 1653,1663 ----
  #									#
  #########################################################################
  S23
  
  R<$+>$*$=Y$~A$*		$:<$1>$2$3?$4$5		Mark user portion of address
! R<$+>$+.$=TOP_DOMAIN_CLASS$=Y$*?$+	<$1$2.$3>$4$5?$6	Find last top level domain.
  ifdef({UUCPRELAYS},{dnl
  R<$+>$+@$=R!$*?$+	<$1$2@$3>!$4?$5		Find last well known UUCP relay
  })dnl ### End UUCPRELAYS ###
  R$*<$+@$+>$+		$1$2<@$3>$4		Find start of that domain.
  R$=X$+<@$+>$+?$+	$:$>8<$1$3>$4?$5	Trim leading part, requalify.
*** ap.co.m4	Mon Nov 19 22:21:02 1990
--- ap.co.m4	Mon Nov 19 17:42:48 1990
***************
*** 0 ****
--- 1,34 ----
+ dnl # Sendmail configuration file for ap.co.umist.ac.ukdefine(ALIASES, LIBDIR/aliases)dnl
+ dnl #
+ dnl # This file is an m4 specification for generating sendmail config
+ dnl # files.
+ dnl #
+ dnl # Note that one way to create m4 comments which are not reflected in
+ dnl # the m4 output files is to use dnl - d(elete to) n(ew) l(ine).
+ dnl #
+ dnl # 
+ define(ALIASES, LIBDIR/aliases)dnl
+ define(FORCE_NAMED)dnl
+ define(UUCPNAME, umaida)dnl
+ define(BANGIMPLIESUUCP)dnl
+ define(BANGONLYUUCP)dnl
+ define(POSTMASTERBOUNCE)dnl
+ define(PSEUDODOMAINS, uucp bitnet csnet)
+ dnl # All hosts on network are equal
+ define(DEFAULT_HOST, ap.co.umist.ac.uk)dnl
+ dnl # Get non manchester machines to route through our host
+ define(RELAY_HOST, sun.cns.umist.ac.uk)dnl
+ define(RELAY_MAILER, TCPMAILER)dnl
+ define(ISOLATED_DOMAINS, umist.ac.uk man.ac.uk mcc.ac.uk)dnl
+ # define(DONT_RELAY_UNKNOWNS)dnl
+ dnl # Accept UK ordering
+ define(UKORDER)dnl
+ define(UK_RETRY_PREFIX, uk.ac)dnl
+ define(UK_RETRY_CLASS, LIBDIR/ac.uk.domains)dnl
+ define(DOMAINTABLE, LIBDIR/domaintable)dnl # includes problem cases.
+ dnl #
+ include(Sendmail.mc)
+ # some misc additions - have to put somewhere
+ # rebuild alias file as necessary
+ OD
+