[comp.sys.sequent] Fix for Mail & domain addresses

kai@uicsrd.csrd.uiuc.edu (Kuck And Associates) (06/10/90)

I found the enclosed bug report about Mail sometimes munging domain based email
addresses, and it rang a bell.  This problem was the reason that we started
using the "Mush" mail user agent program instead of the "Mail" program that
Sequent (and BSD) ships.  Of course, if you have source code to Mail, it's a
very simple fix, but those of us with only binary distribution need something
else.

I enclose a short Perl script that I wrote to patch the Mail program on our
Balance (Dynix 3.0.14) and Symmetry (3.0.17) to fix this problem.  You may
use this if you want, and then your users need never have problems replying
to messages coming from hosts with domains based addresses.  If you don't
have Perl (and you should!!!), it should be easy to convert to C.

To use:
	# su or login as root
	cd /usr/ucb
	cp Mail Mail.new		# Only work on a copy!
	bMailpatch			# run this script
	mv Mail Mail.orig		# save the original version
	mv Mail.new Mail		# install the new version
	rm mail				# re-link the other name for this pgm
	ln Mail mail


Patrick Wolfe   (pat@kai.com, kailand!pat)
System Programmer/Operations Manager, Kuck & Associates

First, the bug report and the patch for lucky people with source.
==============================================================================
~Subject: /usr/ucb/mail botches some return addresses 
Index: ucb 4.3BSD-tahoe

Description:
	Given a message with a mix of relative and fully-qualified addresses,
	/usr/ucb/mail will apply parts of the fully-qualified domain name to
	the relative recipients.
Repeat-By:
	Given a message like the following:

	From bscheid Wed Jun  6 16:13:06 1990
	Date: Wed, 6 Jun 90 16:12:58 -0500
	From: Beth Scheid <bscheid@ux1.cso.uiuc.edu>
	To: krol
	Subject: TCP Product
	Cc: andys, bscheid, german

	(text deleted)

	Using the 'r' (reply) command creates the following:

	To: ux1.uiuc:krol@edu bscheid@ux1.cso.uiuc.edu
	Subject: TCP Product
	Cc: ux1.uiuc:andys@edu ux1.uiuc:bscheid@edu ux1.uiuc:german@edu
Fix:
	The cause is that "." is being used as one of the address separators.
	My guess that this is a holdover from the BerkNet days.  The fix is
	to eliminate "." from the list of separators in config.c.  Apply the
	following patch and re-compile:

	*** /tmp/,RCSt1014232	Thu Jun  7 10:41:16 1990
	--- config.c	Thu Jun  7 10:38:50 1990
	***************
	*** 29,35 ****
	  /*
	   * Set of network separator characters.
	   */
	! char	*metanet = "!^:%@.";
	  
	  /*
	   * Host table of "known" hosts.  See the comment in configdefs.h;
	--- 29,35 ----
	  /*
	   * Set of network separator characters.
	   */
	! char	*metanet = "!^:%@";
	  
	  /*
	   * Host table of "known" hosts.  See the comment in configdefs.h;


==============================================================================
#!/usr/local/bin/perl3
#	patch a copy of Mail to eliminate period (.) from the list of
#	valid user/host separators by replacing it with a NULL.
#
#	To use:
#		cd /usr/ucb
#		cp Mail Mail.new
#		run this script (requires Perl, but you can write a C version
#				fairly easily)
#		mv Mail Mail.old
#		mv Mail.new Mail
#		rm mail
#		ln Mail mail

#	Balance (Dynix 3.0.14) uses 52215 and 52220
#	$check_offset = 52215;
#	$replace_offset = 52220;
#	Symmetry (Dynix 3.0.17, maybe 3.0.12) uses 55023 and 55028
$check_offset = 55023;
$replace_offset = 55028;

$file = "Mail.new";
$check_pattern = "!^:%@.";
$null = "\0";

open (FILE, "+< $file") || die "open $file failed: $!";

#	first check to see if the patch has already been applied
#	or if the numbers are wrong
seek (FILE, $check_offset, 0) || die "seek $file offset $offset failed: $!";
$chars = read (FILE, $line, 6);
die "read error $!" if ($chars < 1);
if ($line ne $check_pattern) {
	printf STDERR "error - incorrect offset or already patched!\n";
	print "read ", $chars, " characters\n";
	@line = split ('', $line);
	for ($i = 0; $i < $chars; $i++) {
		printf "char %d = %s\n", $i, $line[$i];
		}
	exit (1);
	}

seek (FILE, $replace_offset, 0) || die "seek $file offset $offset failed: $!";
# replace the period with a null
print FILE $null;
close (FILE);

print "patch applied\n";
exit (0);