diff options
author | Richard Nelson <cowboy@debian.org> | 1998-06-23 10:00:00 -0500 |
---|---|---|
committer | Andreas Beckmann <debian@abeckmann.de> | 2012-10-01 19:58:37 +0200 |
commit | 6202a816311c5e56f71ecd358850b1e6d8cd7065 (patch) | |
tree | de47ad4f657df101b6f36a07a6c6e19191be7de9 /checksendmail | |
parent | 6c193ce1dd1d07ebdc1372e38bc4908ab1c37705 (diff) | |
download | sendmail-debian/8.8.8-20.tar.gz |
Imported Debian patch 8.8.8-20debian/8.8.8-20
Diffstat (limited to 'checksendmail')
-rw-r--r-- | checksendmail/BSDI_CONTRIB | 18 | ||||
-rw-r--r-- | checksendmail/CVS/Entries | 5 | ||||
-rw-r--r-- | checksendmail/CVS/Repository | 1 | ||||
-rw-r--r-- | checksendmail/Makefile | 15 | ||||
-rw-r--r-- | checksendmail/address.resolve | 27 | ||||
-rw-r--r-- | checksendmail/checksendmail.8 | 223 | ||||
-rw-r--r-- | checksendmail/checksendmail.perl | 377 |
7 files changed, 666 insertions, 0 deletions
diff --git a/checksendmail/BSDI_CONTRIB b/checksendmail/BSDI_CONTRIB new file mode 100644 index 0000000..97871d5 --- /dev/null +++ b/checksendmail/BSDI_CONTRIB @@ -0,0 +1,18 @@ +Software Package: + checksendmail + +Release/Version: + Dated 7/11/90. + +Retrieved from: + N/A. + +Bug reports: + This software package is maintained by the software contributor, + not BSDI. Please send any bug reports to both support@BSDI.COM + and polk@bsdi.com. + +Comments: + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Modifications to this version made by BSDI: diff --git a/checksendmail/CVS/Entries b/checksendmail/CVS/Entries new file mode 100644 index 0000000..692e38d --- /dev/null +++ b/checksendmail/CVS/Entries @@ -0,0 +1,5 @@ +/BSDI_CONTRIB/1.1/Mon Jan 22 10:57:27 1996 Tue Oct 24 17:29:51 1995// +/Makefile/1.3/Mon Jan 22 10:57:28 1996 Fri Jan 6 22:34:35 1995// +/address.resolve/1.1.1.1/Mon Jan 22 10:57:28 1996 Thu Jan 13 14:15:30 1994// +/checksendmail.8/1.1.1.1/Mon Jan 22 10:57:28 1996 Thu Jan 13 14:15:31 1994// +/checksendmail.perl/1.1.1.1/Mon Jan 22 10:57:29 1996 Thu Jan 13 14:15:31 1994// diff --git a/checksendmail/CVS/Repository b/checksendmail/CVS/Repository new file mode 100644 index 0000000..b300606 --- /dev/null +++ b/checksendmail/CVS/Repository @@ -0,0 +1 @@ +/master/contrib/checksendmail diff --git a/checksendmail/Makefile b/checksendmail/Makefile new file mode 100644 index 0000000..101ba4e --- /dev/null +++ b/checksendmail/Makefile @@ -0,0 +1,15 @@ +# BSDI $Id: Makefile,v 1.3 1995/01/07 05:34:35 donn Exp $ + +MAN8= checksendmail.0 + +all checksendmail: ${MAN8} + +clean depend tags: + +install: maninstall + install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/checksendmail.perl ${DESTDIR}${BINDIR}/checksendmail + install -c -o ${BINOWN} -g ${BINGRP} -m 0444 \ + ${.CURDIR}/address.resolve ${DESTDIR}/usr/contrib/lib/ + +.include <bsd.prog.mk> diff --git a/checksendmail/address.resolve b/checksendmail/address.resolve new file mode 100644 index 0000000..01f3011 --- /dev/null +++ b/checksendmail/address.resolve @@ -0,0 +1,27 @@ + +# BSDI $Id: address.resolve,v 1.1.1.1 1994/01/13 21:15:30 polk Exp $ + +# Sample address resolution file for checksendmail(8) + +# local addresses +user +user@hilltop +user@hilltop.BSDI.COM +hilltop!polk + +# within-domain addresses +user@bsdi.com +user@ibapah +user@ibapah.bsdi.com +ibapah!user + +# faraway addresses +user@xxxxxxx.com +user@xxxxxxx.dom +site!user + +# addresses with routing, etc. +site1!site2!user +user@xxxxxxx.dom@bar.dom +site!user@xxxxxxx.dom +site!user@uunet.uu.net diff --git a/checksendmail/checksendmail.8 b/checksendmail/checksendmail.8 new file mode 100644 index 0000000..b129c35 --- /dev/null +++ b/checksendmail/checksendmail.8 @@ -0,0 +1,223 @@ +.\" BSDI $Id: checksendmail.8,v 1.1.1.1 1994/01/13 21:15:31 polk Exp $ +.Dd January 12, 1994 +.Dt CHECKSENDMAIL 8 +.Os +.Sh NAME +.Nm checksendmail +.Nd verify sendmail address transformations. +.Sh SYNOPSIS +.Nm checksendmail +.Op Fl C Ar file.cf +.Op Fl r Ar resolve +.Op Fl T Ar test.address +.Op Fl b Ar sendmail_binary +.Sh DESCRIPTION +.Pp +The +.Nm checksendmail +program is a +.Xr perl +script that aids the testing of +.Xr sendmail 8 's +various configuration files. +.Nm checksendmail +passes typical addresses (supplied in input files) through +.Xr sendmail +and prints the results of the resolution and transformation routines. +.Pp +The input files contain a list of addresses, one per line. +For example: +.Bd -literal -offset indent +user +user@site +user@site.com +.Ed +.Pp +The input file can contain comments started with a +.Em # +and blank lines. +.Sh OPTIONS +.Pp +.Bl -tag -width Fl -compact -offset left +.It Fl C Ar file.cf +Use the +.Xr sendmail +configuration file +.Ar file.cf +instead of the default +.Pa /etc/sendmail.cf +file. +.It Fl r Ar resolve +Use +.Ar resolve +as the input file for the addresses to be used for mail resolving. Defaults +to +.Ar address.resolve . +.It Fl T Ar test.address +Use +.Ar test.address +as the single address to test. Cannot be used in conjunction with +file setting flags. +.It Fl B Ar sendmail_binary +Use the specified +.Ar sendmail_binary +as the path to invoke sendmail (instead of +.Pa /usr/sbin/sendmail ) . +.El +.Sh EXAMPLES +.Pp +The following command will pass the addresses in +.Ar address.resolve +through +.Xr sendmail +using the configuration information in +.Ar myconfig.cf . +.Bd -literal -offset left +example% cat address.resolve +user +user@site +user@site.com +example% checksendmail \-C myconfig.cf +config file: myconfig.cf resolve file: address.resolve +towhom file: address.resolve fromwhom file: address.resolve +Mail address resolution +user --(ether )--> user[rmtc] +user@site --(ether )--> user@site[rmtc] +user@site.com --(ether )--> user@site.com[rmtc] +`To' address transformations for mailer ether: +user ----> user +user@site ----> user@site +user@site.com ----> user@site.com +`From' address transformations for mailer ether: +user ----> user +user@site ----> user +user@site.com ----> user +.Ed +.Pp +The first section of the output shows how the addresses in the input +files are resolved by +.Xr sendmail 8 . +Consider the following output line: +.Pp +.Dl user@site.com --(ether )--> user@site.com[rmtc] +.Pp +The input address +.Em user@site.com +resolves to use the +.Em ether +mailer. That mailer is directed to send the mail to +to the user +.Em user@site.com +at site +.Em rmtc +(as indicated in the square brackets). +.Pp +The two later sections of output show how the addresses specified as +the +.Em To +and +.Em From +address are transformed in the text of the +headers. In the example above, the +.Em To +addresses are untouched. +The +.Em From +addresses, however, all lose their machine information on +the way through the mailer: +.Pp +.Dl user@site ----> user +.Pp +This may be desirable when using a configuration file on a +workstation which is to be hidden as a mailhost from the rest of the +network. +.Pp +The following is a set of addresses used at one site for the purposes of +testing address resolution. Comments after the addresses detail why +particular addresses are present: +.Bl -tag -width "user@machine.com" -compact -offset indent +.It user +Standard trivial address +.It user@rmtc +qualified at one level +.It user@rmtc.central +qualified at two levels +.It user@rmtc.central.sun.com +qualified all the way +.It rmtc!user +local but specified as uucp +.It user@summit +a workstation (normally delivered locally, though) +.It user@summit.central +same but more qualified +.It user@summit.central.sun.com +same but fully qualified +.It summit!user +same but specified as uucp +.It user@prisma +Backward compatibility tests +.It user@prisma.com +.It prisma!user +.It user@central +Superior domain testing +.It user@machine.central +more qualified, but unknown +.It user@summit.central +more qualified and known +.It user@eng +name in faraway domain +.It user@machine.eng +unknown machine in faraway domain +.It user@summit.eng +local machine, far away domain +.It user@hoback +far away machine +.It user@machine +apparently local but unknown machine +.It user@sun.com +Standard trivial address +.It user@machine.dom.sun.com +fully qualified but unknown machine +.It user@foo.com +standard, known, really far away domain +.It user@foo.dom +standard, unknown, really far away domain +.It site!user +Single level uucp +.It site1!site2!user +Double level uucp +.It user@foo.dom@bar.dom +Trickier address +.It site!user@foo.dom +Mixed uucp/domain +.It site!user@uunet.uu.net +Mixed double uucp/domain +.El +.Sh NOTES +Note that +.Nm checksendmail +is a +.Xr perl +script. If your site does not have +.Xr perl 1 , +it can be obtained via anonymous +.Xr ftp +from +.Em ftp.uu.net . +.Pp +.Xr sendmail +requires that the user have access to directory specified by the +.Em OQ +parameter in the configuration file (normally +.Pa /usr/spool/mqueue ) . +.Nm checksendmail +verifies that the user has access to this directory before allowing the +test to continue. +.Sh AUTHORS +.Bd -literal +Gene Kim +Rob Kolstad +Jeff Polk +.Ed +.Sh "SEE ALSO" +.Xr sendmail 8 diff --git a/checksendmail/checksendmail.perl b/checksendmail/checksendmail.perl new file mode 100644 index 0000000..a8e9e11 --- /dev/null +++ b/checksendmail/checksendmail.perl @@ -0,0 +1,377 @@ +#!/usr/bin/perl + +# BSDI $Id: checksendmail.perl,v 1.1.1.1 1994/01/13 21:15:31 polk Exp $ + +# 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 + +# -- -C config file +# -- -r resolve_addresses_file +# -- -T test one address +# -- -b sendmail binary + +# XXX deficiencies: ``/etc/sendmail'' should be a parameter + +# defaults: + $resolve = "address.resolve"; + $cffile = "/etc/sendmail.cf"; + $sendmail = "/usr/sbin/sendmail"; + +sub usage { + die "Usage: checksendmail [-C cffile.cf] [-r resolve_addrs_file [-T one\@test.addr\n"; +} + +for (unshift (@ARGV, "XX"); $#ARGV > 0; shift ARGV) { + if ($ARGV[1] eq "-C") + { + shift @ARGV; + if ($#ARGV >= 1) {$cffile = $ARGV[1]; } + else { &usage(); } + } + elsif ($ARGV[1] eq "-r") + { + if ($setfile & 1) { die "Can only set `resolve' once"; } + shift @ARGV; + if ($#ARGV < 1) { &usage(); } + $resolve = $ARGV[1]; + $setfile += 1; + } + elsif ($ARGV[1] eq "-T") + { + if ($setfile) { die "Can't set other files and use -T"; } + shift @ARGV; + if ($#ARGV < 1) { &usage(); } + open (OUT, ">/tmp/csm.in$$") || + die "Can't open >/tmp/csm.in$$"; + $resolve = "/tmp/csm.in$$"; + print OUT "$ARGV[1]\n"; + close (OUT); + $setfile = 7; + } + elsif ($ARGV[1] eq "-b") + { + shift @ARGV; + if ($#ARGV >= 1) {$sendmail = $ARGV[1]; } + else { &usage(); } + } + else { &usage(); } +} + +if (!-e $cffile) { die "Can't find configuration file $cffile\n"; } +if (!-e $resolve) { die "Can't find name file $resolve\n"; } + +# make sure the user can access the ../mqueue directory + +$maildir = `grep ^OQ $cffile`; +chop $maildir; +$maildir =~ s/^OQ//; +if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { + warn "checksendmail: can't access $maildir! trying anyway...\n"; +} + +chop($hostname = `hostname`); +chop($pwd = `pwd`); +print "system: $hostname\t\tcurrent dir: $pwd\n"; +print "config file: $cffile\t\tresolve file: $resolve\n"; + +sub handler { # 1st argument is signal name + local($sig) = @_; + print STDERR "Caught a SIG$sig--shutting down\n"; + unlink("/tmp/csm$$") || die "Can't unlink /tmp/csm$$"; + unlink("/tmp/csm.in$$"); + exit(0); +} + +$SIG{'INT'} = 'handler'; +$SIG{'QUIT'} = 'handler'; + + +# glean the mailers used from the rule 0 tests + +sub parseresolve +{ + while (<MAIL>) + { + if (/^ADDRESS TEST MODE/) { next; } + if (/^Enter <ruleset>/) { next; } + if (/^>/) # INPUT LINE! (and last output is done) + { + chop; + if ($prevline) { # OUTPUT LINE! + &printparseresolve; + } + s/> *[0-9,]* *//g; + s/.*input: *//; + s/ //g; + s/"//g; + $input = $_; + } + else { chop; } + $prevline = $_; + } + &printparseresolve; +} + +sub printparseresolve { + $prevline =~ s/.*returns: *//; + $prevline =~ s/"//g; + $prevline =~ s/ //g; + # Don't strip spaces off error messages + $prevline =~ s/ *([.!%<>]) */$1/g; + $prevline =~ s/ +([;?\$])/$1/g; + $prevline =~ s/([#\@:]) +/$1/g; + +# non-Sun test mode delimiters -> easily-readable style +# Mark Sausville, MIT Media Laboratory, saus@media-lab.media.mit.edu + $prevline =~ s/\^V/\$#/; + $prevline =~ s/\^W/\$@/; + $prevline =~ s/\^X/\$:/; + + #### $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET + @t = split( '\$', $prevline); + $address = "XXX"; + $remote = "XXX"; + $mailer = "XXX"; + for ($i = 1; $i <= $#t; $i++) + { + if (substr($t[$i], 0, 1) eq ":") + { $address = substr($t[$i], 1,999); } + if (substr($t[$i], 0, 1) eq "@") + { $remote = substr($t[$i], 1,999); } + if (substr($t[$i], 0, 1) eq "#") + { $mailer = substr($t[$i], 1,999); + $mailer =~ tr/A-Z/a-z/; } + } + printf("%-27.27s --(%-6.6s)--> %s[%s]\n", $input, $mailer, + $address, $remote); + if ($mailer ne "XXX") { $themailers{$mailer}.="$input ";} +} + +# Parse output of sendmail name resolution + +sub parseaddress +{ +## ADDRESS TEST MODE +## Enter <ruleset> <address> +## > rewrite: ruleset 3 input: "user" + + open(MAIL, $_[0]) || die "Can't open $_[0]...\n"; + local ($k, $address, $prevline, $mailer, $remote, $input); + print $_[1]; # the title + + $done = 0; + while (<MAIL>) + { + if (/^> *$/) { $done = 1; } + if (/^ADDRESS TEST MODE/) { next; } + if (/^Enter <ruleset>/) { next; } + chop; + if (/^>/) # INPUT LINE! (and last output is done) + { + if ($prevline) { # OUTPUT LINE! + $prevline =~ s/.*returns: *//; + $prevline =~ s/"//g; + $prevline =~ s/ //g; +#> rewrite: ruleset 3 input: "site" "!" "user" "@" "uunet" "." "uu" "." "net" +#rewrite: ruleset 8 input: "site" "!" "user" "@" "uunet" "." "uu" "." "net" +#> + printf("%-27.27s ----> %s\n", $input, $prevline); + } + s/> *[0-9,]* *//g; + s/.*input: *//; + s/ //g; + s/"//g; + $input = $_; + } + last if $done; + $prevline = $_; + } + close(MAIL); +} + + +# pass names from resolve files to sendmail + +open(IN, $resolve) || die "can't open $resolve\n"; +open(OUT, ">/tmp/csm$$") || die "can't open >/tmp/csm$$\n"; +while (<IN>) +{ + /^$/ && next; + /^#/ && next; + print OUT "3,0 $_"; + chop; + $allinput .= " $_"; +} +close(OUT); +close(IN); +$sendmailprog = "$sendmail -bt -C$cffile < /tmp/csm$$|"; +open(MAIL, $sendmailprog) || die "can't exec $sendmailprog...\n"; +print "Mail address resolution (rule 0)\n\n"; +&parseresolve(); + +# calculate $f + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + open (OUT, $sendmailprog); + open (IN, $resolve); + $rules = "3,1,4"; + while (<IN>) { + chop; + /^$/ && next; + /^#/ && next; + $address = $_; + print OUT "$rules $address\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(IN); + close(OUT); + &parseaddress ("/tmp/csm$$", "\n\n\$f address header transformations\n\n"); + +# Get the R= and S= special rulesets from the configuration + +open(FID, "grep ^M $cffile|"); +while (<FID>) +{ +# Mether, P=[IPC], F=msDFMueCX, S=11, R=21, A=IPC $h + chop; + $thisline = $_; $thisline =~ s/M//; $thisline =~ s/,.*//; + $thisline =~ tr/A-Z/a-z/; + $sendrule = $_; $sendrule =~ s/.*S=//; $sendrule =~ s/,.*//; + if ($sendrule=~q!/!) { + ($esendrule, $hsendrule) = split (q!/!, $sendrule); + } + else { $esendrule = $hsendrule = $sendrule; } + $recvrule = $_; $recvrule =~ s/.*R=//; $recvrule =~ s/,.*//; + if ($recvrule=~q!/!) { + ($erecvrule, $hrecvrule) = split (q!/!, $recvrule); + } + else { $erecvrule = $hrecvrule = $recvrule; } + $esendrules{$thisline} = $esendrule; + $hsendrules{$thisline} = $hsendrule; + $erecvrules{$thisline} = $erecvrule; + $hrecvrules{$thisline} = $hrecvrule; +} +close(FID); + +# pass names from various mailers through sendmail + +foreach $i (keys %themailers) +{ + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + if ($erecvrules{$i} == 0) { + print "\n\nCan't find recv rule for `$i', skipping this mailer <-------------------\n"; + next; + } + open (OUT, $sendmailprog); + @namelist = split(/ /, $allinput); + $rules = "3,2,$erecvrules{$i},4"; + foreach (@namelist) { + print OUT "$rules $_\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(OUT); + $note = ""; + if ($erecvrules{$i} eq $hrecvrules{$i}) { $note = "and header "; } + &parseaddress ("/tmp/csm$$", "\n\n`To' envelope ${note}address transformations for mailer $i [$rules]:\n\n"); +} +foreach $i (keys %themailers) +{ + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + if ($hrecvrules{$i} == 0) { + print "\n\nCan't find recv rule for `$i', skipping this mailer <-------------------\n"; + next; + } + if ($hrecvrules{$i} ne $erecvrules{$i}) { + open (OUT, $sendmailprog); + @namelist = split(/ /, $allinput); + $rules = "3,2,$hrecvrules{$i},4"; + foreach (@namelist) { + print OUT "$rules $_\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(OUT); + &parseaddress ("/tmp/csm$$", "\n\n`To' header address transformations for mailer $i [$rules]:\n\n"); + } +} + +# pass names from various mailers through sendmail +foreach $i (keys %themailers) +{ + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + if ($esendrules{$i} == 0) { + print "\n\nCan't find send rule for `$i', skipping this mailer <-------------------\n"; + next; + } + open (OUT, $sendmailprog); + open (IN, $resolve); + $rules = "3,1,$esendrules{$i},4"; + while (<IN>) { + chop; + /^$/ && next; + /^#/ && next; + $address = $_; + print OUT "$rules $address\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(IN); + close(OUT); + $note = ""; + if ($esendrules{$i} eq $hsendrles{$i}) {$note = "and header ";} + &parseaddress ("/tmp/csm$$", "\n\n`From' envelope ${note}address transformations for mailer $i [$rules]:\n\n"); +} +foreach $i (keys %themailers) +{ + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + if ($hsendrules{$i} == 0) { + print "\n\nCan't find send rule for `$i', skipping this mailer <-------------------\n"; + next; + } + open (OUT, $sendmailprog); + open (IN, $resolve); + $rules = "3,1,$hsendrules{$i},4"; + while (<IN>) { + chop; + /^$/ && next; + /^#/ && next; + $address = $_; + print OUT "$rules $address\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(IN); + close(OUT); + &parseaddress ("/tmp/csm$$", "\n\n`From' address header transformations for mailer $i [$rules]:\n\n"); +} +foreach $i (keys %themailers) +{ + $sendmailprog = "|$sendmail -bt -C$cffile > /tmp/csm$$"; + if ($esendrules{$i} == 0) { + print "\n\nCan't find send rule for `$i', skipping this mailer <-------------------\n"; + next; + } + open (OUT, $sendmailprog); + open (IN, $resolve); + $rules = "3,1,4,3,1,$hsendrules{$i},4"; # XXX esendrules? book p. 431??? + while (<IN>) { + chop; + /^$/ && next; + /^#/ && next; + $address = $_; + print OUT "$rules $address\n"; + } + print OUT "\n"; # stuff last line into sendmail + close(IN); + close(OUT); + $note = ""; + if ($esendrules{$i} eq $hsendrles{$i}) {$note = "and header ";} + &parseaddress ("/tmp/csm$$", "\n\n\$g address transformations for mailer $i [$rules]:\n\n"); +} + +unlink("/tmp/csm$$") || die "Can't unlink /tmp/csm$$"; +unlink("/tmp/csm.in$$"); + |