From: karl@grebyn.com (Karl A. Nyberg)
Subject: Results-of: Re: Perl Package to test Sendmail.cf?
Organization: Grebyn Timesharing
Date: Thu, 13 Aug 1992 20:30:31 GMT

I asked about sendmail testing with perl.  Here's the results.
Thanks to everybody for the help.

================================================================

Date: Wed, 12 Aug 92 08:59:44 EDT
From: barnett@alydar.crd.ge.com (Bruce Barnett)
To: karl@grebyn.com (Karl A. Nyberg)
Subject: Perl Package to test Sendmail.cf?

I wrote a shell script to do this, and said I wanted to use perl.
It was in the Ease distribution.

================================================================

Date: Wed, 12 Aug 92 10:44:25 MDT
From: kolstad@BSDI.COM (Rob Kolstad)
To: karl@grebyn.com
Subject: sendmail test suite

Here's the test suite:

#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 07/28/1992 05:43 UTC by kolstad@ace
# Source directory /home/ace/kolstad/src/sendmail
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   3984 -rw-r--r-- FIXTHIS
#    331 -rw-r--r-- README
#    266 -rw-r--r-- address.resolve
#   7140 -rwxrwxr-x checksendmail
#   5314 -rw-r--r-- checksendmail.8
#   2973 -rw-r--r-- error.mail.fix
#
# ============= FIXTHIS ==============
if test -f 'FIXTHIS' -a X"$1" != X"-c"; then
	echo 'x - skipping FIXTHIS (File already exists)'
else
echo 'x - extracting FIXTHIS (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'FIXTHIS' &&
XFrom msirota@ee.rochester.edu Sun Mar 31 14:37:11 1991
Return-Path: <msirota@ee.rochester.edu>
XFrom: Mark Sirota  <msirota@ee.rochester.edu>
Date: Sun, 31 Mar 91 16:36:04 EST
X       kolstad@Central.Sun.COM (Rob Kolstad) (Mar 26,  5:51pm)
XX-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: kolstad@Central (Rob Kolstad)
Subject: Re:  checksendmail recommendations
X
On Mar 26,  5:51pm, Rob Kolstad writes:
> I got out the sendmail manual and I looked at it and tried to reconcile
> it with your comments.
X
Sun's sendmail documentation does say so, but the Berkeley documentation
doesn't.  It does happen in Berkeley sendmail as well.
X
> I don't know if your checksendmail is working as mine is, as mine
> includes extensive from and to address transformations -- just
> as you described.
> 
> Here's the (i know, it's AFU) output from my checksendmail; note
> carefully the last hundreds of lines.
X
Ahh, maybe that's our source of confusion.  Mine does all this too.  The
problem is that the first section ("Mail address resolution (rule 0)") is
incomplete.  Addresses here are only being passed through 3 and 0.  But at
the end of 0, the $: section is then passed through S and 4 before being
passed to the mailer as $u.  That's what checksendmail isn't doing.
X
Do you read comp.mail.sendmail?  There has been a bit of discussion about
this in the last couple of weeks (since I asked the question).  Some people
say it's passed through 1 or 2 before S and 4, but I haven't been able to
confirm that.
X
To clarify further, this is what happens to the envelope address:
X
X		     /  $# mailer ->
address -> 3 -> 0 -> -- $@ host -> $h
X		     \  $: user -> S -> 4 -> $u
X
Mark
X
-- 
Mark Sirota - Department of Electrical Engineering Systems Staff
University of Rochester, Rochester NY
X Internet: msirota@ee.rochester.edu
X UUCP:     {decvax,garp,harvard,hombre,rutgers}!rochester!ur-valhalla!msirota
X
>From msirota@ee.rochester.edu Tue Apr  2 10:11:58 1991
Return-Path: <msirota@ee.rochester.edu>
Received: from Central.Sun.COM (texsun.Central.Sun.COM) by rmtc.Central.Sun.COM (4.1/SMI-4.1-900117)
X	id AA24601; Tue, 2 Apr 91 10:11:56 MST
Received: from Sun.COM (sun-barr.EBay.Sun.COM) by Central.Sun.COM (4.1/SMI-4.1)
X	id AA29918; Tue, 2 Apr 91 11:11:50 CST
Received: from valhalla.ee.rochester.edu by Sun.COM (4.1/SMI-4.1)
X	id AA29164; Tue, 2 Apr 91 09:11:41 PST
Received: from socrates.ee.rochester.edu 
X	by valhalla.ee.rochester.edu (4.1/cf1.38ee) 
X	id AA26694; Tue, 2 Apr 91 12:11:23 EST
Received: by socrates.ee.rochester.edu (4.1/cf1.1client)
X	id AA15428; Tue, 2 Apr 91 12:10:55 EST
Message-Id: <9104021710.AA15428@socrates.ee.rochester.edu>
XFrom: msirota@socrates.ee.rochester.edu
Date: Tue, 2 Apr 1991 12:10:53 -0500
X       kolstad@Central.Sun.COM (Rob Kolstad) (Mar 31,  2:38pm)
XX-Mailer: Mail User's Shell (7.2.2 3/26/90)
To: kolstad@Central (Rob Kolstad)
Subject: Re:  checksendmail recommendations
Status: RO
X
On Mar 31,  2:38pm, Rob Kolstad writes:
> hey -- why not send me your phone number so we can talk about this.
> I think the secondary sections show the transformations you want.
> You don't.
X
Right.  I'll explain it here in e-mail since you can look over it in text,
but feel free to call if you want - (716) 275-8265.
X
The problem is that the lower transformations move the address through, say
X
X	3 -> 1 -> S -> 4
X
So it doesn't pass through 0.  Furthermore, the transformations I'm talking
about, the ones that are missing, are not the entire address - it's only the
local-part as determined by 0.
X
> I'm sure you're right -- I just need to talk about it to be sure.
X
If you have a SunOS 4.x manual set, check out the sendmail guide.  It's not
well explained in there, but it *is* in there.  Or ask on
comp.mail.sendmail; maybe someone else can explain it better.  I wish I had
sources...
X
Anyway, I expect to be in my office all afternoon (east coast).
X
Mark
X
X
SHAR_EOF
chmod 0644 FIXTHIS ||
echo 'restore of FIXTHIS failed'
Wc_c="`wc -c < 'FIXTHIS'`"
test 3984 -eq "$Wc_c" ||
	echo 'FIXTHIS: original size 3984, current size' "$Wc_c"
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
	echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
If you have any questions or any feedback, please feel free to mail me at:
X		kolstad@rmtc.Central.Sun.COM
X
Thanks to Gene Kim for his assistance in creating the PERL script.
X
There is still a slight, almost never noticeable bug in the way the
from address is set up while still parsing rule 0.  I'll try to fix it
by the 9/91...RK
SHAR_EOF
chmod 0644 README ||
echo 'restore of README failed'
Wc_c="`wc -c < 'README'`"
test 331 -eq "$Wc_c" ||
	echo 'README: original size 331, current size' "$Wc_c"
fi
# ============= address.resolve ==============
if test -f 'address.resolve' -a X"$1" != X"-c"; then
	echo 'x - skipping address.resolve (File already exists)'
else
echo 'x - extracting address.resolve (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'address.resolve' &&
user
user@ace
user@ibapah
user@ibapah.bsdi.com
user@ace.bsdi.com
ace!user
ibapah!user
xxx!user
user@bsdi.com
user@xxxxxxx.dom.bsdi.com
user@xxxxxxx.com
user@xxxxxxx.dom
site!user
site1!site2!user
user@xxxxxxx.dom@bar.dom
site!user@xxxxxxx.dom
site!user@uunet.uu.net
SHAR_EOF
chmod 0644 address.resolve ||
echo 'restore of address.resolve failed'
Wc_c="`wc -c < 'address.resolve'`"
test 266 -eq "$Wc_c" ||
	echo 'address.resolve: original size 266, current size' "$Wc_c"
fi
# ============= checksendmail ==============
if test -f 'checksendmail' -a X"$1" != X"-c"; then
	echo 'x - skipping checksendmail (File already exists)'
else
echo 'x - extracting checksendmail (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'checksendmail' &&
#!/usr/bin/perl
X
# checksendmail
#
# 	The checksendmail program is a perl script that aids the testing
#	of sendmail's various configuration filse.  checksendmail 
#	passes typical addresses (supplied in input files) through
#	sendmail and prints the result of the resolution and 
#	transformation routines. 
#
#			Gene Kim & Rob Kolstad & Jeff Polk, 7/11/90
X
# --    -C config file
# --    -r resolve file
# --    -t towhom file
# --    -f fromwhom file
X
# XXX deficiencies:  ``/etc/sendmail'' should be a parameter
X
X
# defaults:
X	$resolve  = "address.resolve";
X	$towhom   = "address.resolve";
X	$fromwhom = "address.resolve";
X	$cffile   = "./sendmail.cf";
X
sub usage {
X	die "Usage: checksendmail [-C configfile.cf] [-r resolve file] [-f fromwhom file] 
X		     [-t towhomfile] \n";
}
X
for (unshift (@ARGV, "XX"); $#ARGV > 0; shift ARGV) {
X	if ($ARGV[1] eq "-C") 
X	{
X		shift @ARGV;
X		if ($#ARGV >= 1) {$cffile = $ARGV[1]; }
X		else { &usage(); }
X	} elsif ($ARGV[1] eq "-f")
X	{
X		shift @ARGV;
X		if ($#ARGV >= 1) {$fromwhom = $ARGV[1]; }
X		else { &usage(); }
X	}
X	elsif ($ARGV[1] eq "-t")
X	{
X		shift @ARGV;
X		if ($#ARGV >= 1) {$towhom = $ARGV[1]; }
X		else { &usage(); }
X	}
X	elsif ($ARGV[1] eq "-r")
X	{
X		shift @ARGV;
X		if ($#ARGV >= 1) {$resolve = $ARGV[1]; }
X		else { &usage(); }
X	}
X	else { &usage(); }
}
X
if (!-e $cffile)   { die "Can't find configuration file $cffile\n"; }
if (!-e $fromwhom) { die "Can't find name file $fromwhom\n"; }
if (!-e $towhom)   { die "Can't find name file $towhom\n"; }
if (!-e $resolve)  { die "Can't find name file $resolve\n"; }
X
# make sure the user can access the ../mqueue directory
X
$maildir = `grep ^OQ $cffile`;
chop $maildir;
$maildir =~ s/^OQ//;
if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
X	die "checksendmail: can't access $maildir!  aborting...\n";
}
X
chop($hostname = `hostname`);
chop($pwd = `pwd`);
print "system: $hostname\t\tcurrent dir: $pwd\n";
print "config file: $cffile\t\tresolve file: $resolve\n";
print "towhom file: $towhom\t\tfromwhom file: $fromwhom\n\n\n";
X
sub handler {  # 1st argument is signal name
X     local($sig) = @_;
X     print STDERR "Caught a SIG$sig--shutting down\n";
X     system("rm -f tmp");
X     exit(0);
}
X
$SIG{'INT'} = 'handler';
$SIG{'QUIT'} = 'handler';
X
X
# glean the mailers used from the rule 0 tests
X
sub parseresolve
{
X     $firstline = 1;
X     while (<MAIL>)
X     {
X	if ($firstline == 1) { $firstline = 0; }
X        chop;
X        if (/^ADDRESS TEST MODE/) { next; }
X        if (/^Enter <ruleset>/) { next; }
X        if (/^>/) 			# INPUT LINE! (and last output is done)
X        {
X     	if ($prevline) {	# OUTPUT LINE!
X     	    $prevline =~ s/.*returns:  *//;
X     	    $prevline =~ s/"//g;
X     	    $prevline =~ s/ //g;
X
# These three lines turn the non-Sun test mode delimiters
# into easily-readable style. Should be okay to include though because
# the matches will fail on a Sun.
# Mark Sausville, MIT Media Laboratory, saus@media-lab.media.mit.edu
X     	    $prevline =~ s/\^V/\$#/;
X     	    $prevline =~ s/\^W/\$@/;
X     	    $prevline =~ s/\^X/\$:/;
X
X     ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
X     	    @t = split( '\$', $prevline);
X     	    $address = "XXX";
X     	    $remote = "XXX";
X     	    $mailer = "XXX";
X     	    for ($i = 1; $i <= $#t; $i++)
X     	    {
X     		if (substr($t[$i], 0, 1) eq ":")
X     		{ $address = substr($t[$i], 1,999); }
X     		if (substr($t[$i], 0, 1) eq "@")
X     		{ $remote = substr($t[$i], 1,999); }
X     		if (substr($t[$i], 0, 1) eq "#")
X     		{ $mailer =  substr($t[$i], 1,999); }
X     	    }
X	    printf("%-27.27s --(%-6.6s)-->  %s[%s]\n", $input, $mailer,
X     			$address, $remote);
X	    if ($mailer ne "XXX") { $themailers{$mailer}=1;}
X     	}
X     	s/> *//g;
X     	s/.*input: *//;
X     	s/ //g;
X     	s/"//g;
X     	$input = $_;
X        }
X        $prevline = $_;
X     }
}
X
# Parse output of sendmail name resolution 
X
sub parseaddress
{
##   ADDRESS TEST MODE
##   Enter <ruleset> <address>
##   > rewrite: ruleset  3   input: "user"
X
X     open(MAIL, $_[0]) || die "Can't open $_[0]...\n";
X     local ($k, $address, $prevline, $mailer, $remote, $input);
X     print $_[1];			# the title
X
X     while (<MAIL>)
X     {
X	if (/^> *$/) { last; }
X        if (/^ADDRESS TEST MODE/) { next; }
X        if (/^Enter <ruleset>/) { next; }
X        chop;
X        if (/^>/) 			# INPUT LINE! (and last output is done)
X        {
X         	if ($prevline) {	# OUTPUT LINE!
X         	    $prevline =~ s/.*returns:  *//;
X         	    $prevline =~ s/"//g;
X         	    $prevline =~ s/ //g;
#> rewrite: ruleset  3   input: "site" "!" "user" "@" "uunet" "." "uu" "." "net"
#rewrite: ruleset  8   input: "site" "!" "user" "@" "uunet" "." "uu" "." "net"
#> 
X    	            printf("%-27.27s ---->  %s\n", $input, $prevline);
X         	}
X     	    s/> *//g;
X     	    s/.*input: *//;
X     	    s/ //g;
X     	    s/"//g;
X     	    $input = $_;
X        }
X        $prevline = $_;
X     }
X    close(MAIL);
}
X
X
# pass names from resolve files to sendmail
X
open(IN, $resolve) || die "can't open $resolve\n";
open(OUT, ">tmp") || die "can't open tmp\n";
while (<IN>) 
{
X    if ($_ ne "\n") { print OUT "0 $_"; }
}
close(OUT);
close(IN);
X
$sendmailprog = "/usr/lib/sendmail -bt -C$cffile < tmp|";
open(MAIL, $sendmailprog) || die "can't exec $sendmailprog...\n";
print "Mail address resolution (rule 0)\n\n";
&parseresolve();
close(SENDMAIL);
X
# Get the R= and S= special rulesets from the configuration
X
open(FID, "grep ^M $cffile|");
while (<FID>)
{
#    Mether,	P=[IPC], F=msDFMueCX, S=11, R=21, A=IPC $h
X    chop;
X    $thisline = $_; $thisline =~ s/M//; $thisline =~ s/,.*//;
X    $sendrule = $_; $sendrule =~ s/.*S=//; $sendrule =~ s/,.*//;
X    $recvrule = $_; $recvrule =~ s/.*R=//; $recvrule =~ s/,.*//;
X    $sendrules{$thisline} = $sendrule;
X    $recvrules{$thisline} = $recvrule;
}
close(FID);
X
# pass names from fromwhom file through sendmail
X
foreach $i (keys %themailers)
{
X    $sendmailprog = "|/usr/lib/sendmail -bt -C$cffile > tmp";
X    if ($recvrules{$i} == 0) {
X	print "\n\nCan't find recv rule for `$i', skipping this mailer <-------------------\n";
X	next;
X    }
X    open (OUT, $sendmailprog);
X    open (IN, $fromwhom);
X    while (<IN>) {
X        chop;
X        if (/^$/) { next; }
X	$address = $_;
X        print OUT "2,$recvrules{$i},4, $address\n";
X    }
X    print OUT "\n";			# stuff last line into sendmail
X    close(IN);
X    close(OUT);
X    &parseaddress ("tmp", "\n\n`To' address transformations for mailer $i:\n\n");
}
X
# pass names from towhom file through sendmail 
X
foreach $i (keys %themailers)
{
X    $sendmailprog = "|/usr/lib/sendmail -bt -C$cffile > tmp";
X    if ($sendrules{$i} == 0) {
X	print "\n\nCan't find send rule for `$i', skipping this mailer <-------------------\n";
X	next;
X    }
X    open (OUT, $sendmailprog);
X    open (IN, $towhom);
X    while (<IN>) {
X        chop;
X        if (/^$/) { next; }
X	$address = $_;
X        print OUT "1,$sendrules{$i},4, $address\n";
X    }
X    print OUT "\n";			# stuff last line into sendmail
X    close(IN);
X    close(OUT);
X    &parseaddress ("tmp", "\n\n`From' address transformations for mailer $i:\n\n");
}
X
system("rm -f tmp");
SHAR_EOF
chmod 0775 checksendmail ||
echo 'restore of checksendmail failed'
Wc_c="`wc -c < 'checksendmail'`"
test 7140 -eq "$Wc_c" ||
	echo 'checksendmail: original size 7140, current size' "$Wc_c"
fi
# ============= checksendmail.8 ==============
if test -f 'checksendmail.8' -a X"$1" != X"-c"; then
	echo 'x - skipping checksendmail.8 (File already exists)'
else
echo 'x - extracting checksendmail.8 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'checksendmail.8' &&
.TH CHECKSENDMAIL 8 LOCAL
.CX
.SH NAME
checksendmail \- verify 
.B sendmail 
address transformations
.SH SYNOPSIS
.B checksendmail
[
.B \-C
.I file.cf 
] [
.B \-r
.I resolve 
] [
.B \-t
.I towhom 
] [
.B \-f
.I fromwhom 
]
.SH DESCRIPTION
.LP
The 
.B checksendmail
program is a 
.B perl
script that aids the testing of 
.B sendmail's 
various configuration files.
.B checksendmail 
passes typical addresses (supplied in input files) through
.B sendmail
and prints the results of the resolution and transformation routines.
.LP
The input files contain a list of addresses, one per line.  
Here is an example:
.RS
.nf
user
user@site
user@site.com
.fi
.RE
.SH OPTIONS
.TP 16
.BI \-C " file.cf"
Use the 
.B sendmail
configuration file 
.I file.cf
instead of the default 
.B "/etc/sendmail.cf"
file.
.TP
.BI \-r " resolve"
Use
.I resolve
as the input file for the addresses to be used for mail resolving.  Defaults
to
.BR address.resolve \|.
.TP
.BI \-t " towhom"
Use 
.I towhom
as the input file for the ``from whom'' addresses.
.I towhom
defaults to 
.BR address.resolve \|.
.TP
.BI \-f " fromwhom"
Use
.I fromwhom
as the input file for the ``to whom'' addresses.
.I fromwhom
defaults to
.BR address.resolve \|.
.SH EXAMPLES
The following command will pass the addresses in `address.resolve' through 
.B sendmail 
using the configuration information in 
.I myconfig.cf \|.  
.LP
.RS
.ft CW
.ft CB
example% 
.ft CW
cat address.resolve
.nf
user
user@site
user@site.com
.ft P
.fi
example% 
.ft P
checksendmail \-C myconfig.cf
.nf
config file: myconfig.cf		resolve file: address.resolve
towhom file: address.resolve		fromwhom file: address.resolve
.sp 0.5
Mail address resolution
.sp 0.5
user                        --(ether )-->  user[rmtc]
user@site                   --(ether )-->  user@site[rmtc]
user@site.com               --(ether )-->  user@site.com[rmtc]
.sp 0.5
`To' address transformations for mailer ether:
.sp 0.5
user                        ---->  user
user@site                   ---->  user@site
user@site.com               ---->  user@site.com
.sp 0.5
`From' address transformations for mailer ether:
.sp 0.5
user                        ---->  user
user@site                   ---->  user
user@site.com               ---->  user
.sp
.fi
.ft R
.RE
.LP
The first section of the output shows how the addresses in the input
files are resolved by 
.BR sendmail \|.
Consider the following output line:
.nf
.RS
.ft CW
user@site.com               --(ether )-->  user@site.com[rmtc]
.ft
.RE
.fi
The input address \f(CWuser@site.com\fP resolves to use the 
\f(CWether\fP mailer.  That mailer is directed to send the mail to
to the user \f(CWuser@site.com\fP
at site \f(CWrmtc\fP (as indicated in the square brackets)
.LP
The two later sections of output show how the addresses specified as
the `To' and `From' address are transformed in the text of the
headers.  In the example above, the `To' addresses are untouched.
The `From' addresses, however, all lose their machine information on
the way through the mailer:
.nf
.RS
.ft CW
user@site                   ---->  user
.ft
.RE
.fi
This may be the result when using this configuration file on a
workstation which is to be hidden as a mailhost from the rest of the
network.
.LP
Here is a set of addresses used at one site for the purposes of
testing address resolution.  Italics are comments detailing why
particular addresses are present:
.nf
.ta 2.25i
.in +0.6i
user	\f2Standard trivial address\fP
user@rmtc	\f2qualified at one level\fP
user@rmtc.central	\f2qualified at two levels\fP
user@rmtc.central.sun.com	\f2qualified all the way\fP
rmtc!user	\f2local but specified as uucp\fP
.sp 0.3
user@summit	\f2a workstation (normally delivered locally, though)\fP
user@summit.central	\f2same but more qualified\fP
user@summit.central.sun.com	\f2same but fully qualified\fP
summit!user	\f2same but specified as uucp\fP
.sp 0.3
user@prisma	\f2Backward compatibility tests\fP
user@prisma.com	
prisma!user	
.sp 0.3
user@central	\f2Superior domain testing\fP
user@machine.central	\f2more qualified, but unknown\fP
user@summit.central	\f2more qualified and known\fP
user@eng	\f2name in faraway domain\fP
user@machine.eng	\f2unknown machine in faraway domain\fP
user@summit.eng	\f2local machine, far away domain\fP
user@hoback	\f2far away machine\fP
.sp 0.3
user@machine	\f2apparently local but unknown machine\fP
user@sun.com	\f2Standard trivial address\fP
user@machine.dom.sun.com	\f2fully qualified but unknown machine\fP
.sp 0.3
user@foo.com	\f2standard, known, really far away domain \fP
user@foo.dom	\f2standard, unknown, really far away domain\fP
.sp 0.3
site!user	\f2Single level uucp\fP
site1!site2!user	\f2Double level uucp\fP
.sp 0.3
user@foo.dom@bar.dom	\f2Trickier address\fP
site!user@foo.dom	\f2Mixed uucp/domain\fP
site!user@uunet.uu.net	\f2Mixed double uucp/domain\fP
.fi
.in
.SH NOTES
Note that 
.B checksendmail
is a 
.B perl 
script.  If your site does not have
.BR perl ,
it can be obtained via anonymous
.B ftp
at uunet.uu.net\|.
.LP
.B sendmail
requires that the user have access to directory specified by the `OQ'
parameter in the configuration file (normally 
.BR /usr/spool/mqueue ).
.B checksendmail
verifies that the user has access to this directory before allowing the 
test to continue.
X
.SH "SEE ALSO"
.BR sendmail (8),
.BR sendmail.cf (8),
SHAR_EOF
chmod 0644 checksendmail.8 ||
echo 'restore of checksendmail.8 failed'
Wc_c="`wc -c < 'checksendmail.8'`"
test 5314 -eq "$Wc_c" ||
	echo 'checksendmail.8: original size 5314, current size' "$Wc_c"
fi
# ============= error.mail.fix ==============
if test -f 'error.mail.fix' -a X"$1" != X"-c"; then
	echo 'x - skipping error.mail.fix (File already exists)'
else
echo 'x - extracting error.mail.fix (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'error.mail.fix' &&
XFrom gamin@ireq-robot.hydro.qc.ca Fri Aug 16 11:28:23 1991
Return-Path: <gamin@ireq-robot.hydro.qc.ca>
Received: from Central.Sun.COM (central.Central.Sun.COM) by rmtc.Central.Sun.COM (4.1/SMI-4.1-900117)
X	id AA05534; Fri, 16 Aug 91 11:28:21 MDT
Received: from Sun.COM (sun-barr.EBay.Sun.COM) by Central.Sun.COM (4.1/SMI-4.1)
X	id AA11276; Fri, 16 Aug 91 12:28:20 CDT
Received: from clouso.crim.ca by Sun.COM (4.1/SMI-4.1)
X	id AA24128; Fri, 16 Aug 91 10:28:16 PDT
Received: by clouso.crim.ca (5.57/Ultrix3.0-C)
X	id AA05679; Fri, 16 Aug 91 13:21:52 EDT
Received: from pellan.ireq-robot by ireq-robot.hydro.qc.ca (4.1/IRBT-2.2)
X	id AA06086; Fri, 16 Aug 91 13:32:53 EDT
Date: Fri, 16 Aug 91 13:32:53 EDT
XFrom: Martin Boyer <gamin@ireq-robot.hydro.qc.ca>
Message-Id: <9108161732.AA06086@ireq-robot.hydro.qc.ca>
To: kolstad@rmtc.Central.Sun.COM
Subject: checksendmail
Status: RO
X
Hi,
X
I think your program is great.  I had a little shell script of my own,
but yours is much better.  I have made two changes that are useful:
X
1. I never had any need to access the /var/spool/queue directory in
X   test mode.  I changed the 'die' for a 'warn'
X
2. The 'error' mailer outputs error messages instead of addresses.
X   I modified the parsing to keep the spaces in those messages.
X
Here's the diff file:
X
*** checksendmail.orig	Fri Aug 16 11:02:52 1991
--- checksendmail	Fri Aug 16 13:24:10 1991
***************
*** 65,71 ****
X  chop $maildir;
X  $maildir =~ s/^OQ//;
X  if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
! 	die "checksendmail: can't access $maildir!  aborting...\n";
X  }
X  
X  chop($hostname = `hostname`);
--- 65,72 ----
X  chop $maildir;
X  $maildir =~ s/^OQ//;
X  if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
! #	die "checksendmail: can't access $maildir!  aborting...\n";
! 	warn "checksendmail: can't access $maildir! trying anyway...\n";
X  }
X  
X  chop($hostname = `hostname`);
***************
*** 103,109 ****
X       	if ($prevline) {	# OUTPUT LINE!
X       	    $prevline =~ s/.*returns:  *//;
X       	    $prevline =~ s/"//g;
!      	    $prevline =~ s/ //g;
X       ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
X       	    @t = split( '\$', $prevline);
X       	    $address = "XXX";
--- 104,114 ----
X       	if ($prevline) {	# OUTPUT LINE!
X       	    $prevline =~ s/.*returns:  *//;
X       	    $prevline =~ s/"//g;
! 	    # Don't strip spaces off error messages
! #     	    $prevline =~ s/ //g;
! 	    $prevline =~ s/ *([.!%<>]) */$1/g;
! 	    $prevline =~ s/ +([;?\$])/$1/g;
! 	    $prevline =~ s/([#@:]) +/$1/g;
X       ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
X       	    @t = split( '\$', $prevline);
X       	    $address = "XXX";
X
X
You can do what you want with these changes, their yours if you want
them.
X
X
Martin
X
--
Martin Boyer                            mboyer@ireq-robot.hydro.qc.ca
Institut de recherche d'Hydro-Quebec    mboyer@ireq-robot.uucp
Varennes, QC, Canada   J3X 1S1
+1 514 652-8412
X
SHAR_EOF
chmod 0644 error.mail.fix ||
echo 'restore of error.mail.fix failed'
Wc_c="`wc -c < 'error.mail.fix'`"
test 2973 -eq "$Wc_c" ||
	echo 'error.mail.fix: original size 2973, current size' "$Wc_c"
fi
exit 0

================================================================

To: karl@grebyn.com (Karl A. Nyberg)
Subject: Re: Perl Package to test Sendmail.cf?
Date: Thu, 13 Aug 1992 09:06:55 +1200
From: Andy Linton <andy.linton@comp.vuw.ac.nz>

#! /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 1 (of 1)."
# Contents:  cfdebug cftest debug.in
# Wrapped by post@imagine.pawl.rpi.edu on Fri Sep 15 11:44:26 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'cfdebug' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cfdebug'\"
else
echo shar: Extracting \"'cfdebug'\" \(1343 characters\)
sed "s/^X//" >'cfdebug' <<'END_OF_FILE'
X#! /bin/sh
X#
X# This shell script runs sendmail in address test mode and converts the
X# debugging output to something more intelligible for helping debug sendmail.cf
X# files.
X# 
X# Pass the config file to use as $1  - /usr/lib/sendmail.cf by default
X#
X# Enter input of the form (same as for "sendmail -bt"):
X# 
X#       0 address1
X#       0 address2
X#       ...
X#       (eof)
X# 
X#
Xif [ $# -eq 0 ]
Xthen 
X	cf="/usr/lib/sendmail.cf" 
Xelse
X	cf=$1
Xfi
Xif [ ! -r $cf ]
Xthen
X	echo "File '$cf' not readable, exiting..."
X	exit
Xfi
Xsudo /usr/lib/sendmail -bt -C$cf -d21.12 |\
Xgrep -v -e '----- rule fails' |\
Xsed -e 's/-----trying rule:/R/' \
X    -e 's/"^P"/$*/g' \
X    -e 's/"^Q"/$+/g' \
X    -e 's/"^R"/$-/g' \
X    -e 's/"^S\([A-Za-z]\)"/$=\1/g' \
X    -e 's/"^T\([0-9]\)"/$\1/g' \
X    -e 's/"^U"/$#/' \
X    -e 's/"^V"/$\&/g' \
X    -e 's/"^W"/$:/g' \
X    -e 's/"^X"/$>/g' \
X    -e 's/"//g' |\
Xsed -e '/^R/s/[ 	]//g' \
X    -e '/matches:/s/[ 	]//g' -e 's/rulematches:/rule matches: /' \
X    -e '/rewritten as:/s/[ 	]//g' -e 's/rewrittenas:/rewritten as: /' \
X    -e '/returns:/s/[ 	]//g' \
X    -e 's/.*ruleset\([0-9]\)returns:/ruleset \1 returns: /' \
X    -e '/input:/s/[ 	]//g' \
X    -e 's/.*ruleset\(.*\)input:/ruleset \1 input: /'
X#
X# Compliments of the author:  Dan Long
X#                             CSNET Technical Staff
X#         		      long@sh.cs.net
END_OF_FILE
if test 1343 -ne `wc -c <'cfdebug'`; then
    echo shar: \"'cfdebug'\" unpacked with wrong size!
fi
chmod +x 'cfdebug'
# end of 'cfdebug'
fi
if test -f 'cftest' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cftest'\"
else
echo shar: Extracting \"'cftest'\" \(293 characters\)
sed "s/^X//" >'cftest' <<'END_OF_FILE'
X#!/bin/sh
X# A script to put debug input a line at a time through cfdebug.  JRA 05/10/89
X# call like this (with the file sendmail.cf in the current directory):
X#  cftest < debug.in > debug.out &
Xwhile read line ; do
X  echo $line 
X  echo $line | cfdebug sendmail.cf | grep '0 returns: $#' 
Xdone
END_OF_FILE
if test 293 -ne `wc -c <'cftest'`; then
    echo shar: \"'cftest'\" unpacked with wrong size!
fi
chmod +x 'cftest'
# end of 'cftest'
fi
if test -f 'debug.in' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'debug.in'\"
else
echo shar: Extracting \"'debug.in'\" \(573 characters\)
sed "s/^X//" >'debug.in' <<'END_OF_FILE'
X0 user@bit.BITNET
X0 bit.BITNET!user
X0 some.random.domain!user
X0 user@LOCAL
X0 site!user@uunet.uu.net
X0 <@host1,@host2,@host3:a@b.com>
X0 uunet!site1!site2
X0 user@itsgw.rpi.edu
X0 user@blah.its.rpi.edu
X0 user@rpi.edu
X0 user@pawl.rpi.edu
X0 userxxxx@mts.rpi.edu
X0 blah!nyser!user
X0 uunet!itsgw!user
X0 uunet!rpi!postmaster
X0 uunet!itsgw!mts!userfred@some.where.edu
X0 itsgw!user@uunet.uu.net
X0 adobe!someone@decwrl.dec.com
END_OF_FILE
if test 573 -ne `wc -c <'debug.in'`; then
    echo shar: \"'debug.in'\" unpacked with wrong size!
fi
# end of 'debug.in'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    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
--------------end of shar file --------------
--
---Jim Ault, ITS Postmaster, Rensselaer Polytechnic Inst, Troy NY, 12180
   Postmaster@rpi.edu    Jim_Ault@rpitsmts.BITNET   Jim_Ault@mts.rpi.edu
   518-276-2750 (voice)     ...uunet!rpi.edu!ault     518-276-2809 (fax)


================================================================
-- 
Karl A. Nyberg				karl@grebyn.com
Post Office Box 497			Grebyn Corporation
Vienna, VA 22183-0497 USA		+1-703-281-2194
Newsgroups: comp.mail.sendmail