home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / mail / sendmail / 2075 < prev    next >
Encoding:
Text File  |  1992-08-13  |  28.7 KB  |  988 lines

  1. Newsgroups: comp.mail.sendmail
  2. Path: sparky!uunet!grebyn!daily!karl
  3. From: karl@grebyn.com (Karl A. Nyberg)
  4. Subject: Results-of: Re: Perl Package to test Sendmail.cf?
  5. Message-ID: <1992Aug13.203031.7231@grebyn.com>
  6. Organization: Grebyn Timesharing
  7. References: <1992Aug12.120807.3834@grebyn.com>
  8. Date: Thu, 13 Aug 1992 20:30:31 GMT
  9. Lines: 977
  10.  
  11. I asked about sendmail testing with perl.  Here's the results.
  12. Thanks to everybody for the help.
  13.  
  14. ================================================================
  15.  
  16. Date: Wed, 12 Aug 92 08:59:44 EDT
  17. From: barnett@alydar.crd.ge.com (Bruce Barnett)
  18. To: karl@grebyn.com (Karl A. Nyberg)
  19. Subject: Perl Package to test Sendmail.cf?
  20.  
  21. I wrote a shell script to do this, and said I wanted to use perl.
  22. It was in the Ease distribution.
  23.  
  24. ================================================================
  25.  
  26. Date: Wed, 12 Aug 92 10:44:25 MDT
  27. From: kolstad@BSDI.COM (Rob Kolstad)
  28. To: karl@grebyn.com
  29. Subject: sendmail test suite
  30.  
  31. Here's the test suite:
  32.  
  33. #!/bin/sh
  34. # This is a shell archive (produced by shar 3.49)
  35. # To extract the files from this archive, save it to a file, remove
  36. # everything above the "!/bin/sh" line above, and type "sh file_name".
  37. #
  38. # made 07/28/1992 05:43 UTC by kolstad@ace
  39. # Source directory /home/ace/kolstad/src/sendmail
  40. #
  41. # existing files will NOT be overwritten unless -c is specified
  42. #
  43. # This shar contains:
  44. # length  mode       name
  45. # ------ ---------- ------------------------------------------
  46. #   3984 -rw-r--r-- FIXTHIS
  47. #    331 -rw-r--r-- README
  48. #    266 -rw-r--r-- address.resolve
  49. #   7140 -rwxrwxr-x checksendmail
  50. #   5314 -rw-r--r-- checksendmail.8
  51. #   2973 -rw-r--r-- error.mail.fix
  52. #
  53. # ============= FIXTHIS ==============
  54. if test -f 'FIXTHIS' -a X"$1" != X"-c"; then
  55.     echo 'x - skipping FIXTHIS (File already exists)'
  56. else
  57. echo 'x - extracting FIXTHIS (Text)'
  58. sed 's/^X//' << 'SHAR_EOF' > 'FIXTHIS' &&
  59. XFrom msirota@ee.rochester.edu Sun Mar 31 14:37:11 1991
  60. Return-Path: <msirota@ee.rochester.edu>
  61. XFrom: Mark Sirota  <msirota@ee.rochester.edu>
  62. Date: Sun, 31 Mar 91 16:36:04 EST
  63. In-Reply-To: <9103270051.AA17529@rmtc.Central.Sun.COM>
  64. X       kolstad@Central.Sun.COM (Rob Kolstad) (Mar 26,  5:51pm)
  65. XX-Mailer: Mail User's Shell (7.2.0 10/31/90)
  66. To: kolstad@Central (Rob Kolstad)
  67. Subject: Re:  checksendmail recommendations
  68. X
  69. On Mar 26,  5:51pm, Rob Kolstad writes:
  70. > I got out the sendmail manual and I looked at it and tried to reconcile
  71. > it with your comments.
  72. X
  73. Sun's sendmail documentation does say so, but the Berkeley documentation
  74. doesn't.  It does happen in Berkeley sendmail as well.
  75. X
  76. > I don't know if your checksendmail is working as mine is, as mine
  77. > includes extensive from and to address transformations -- just
  78. > as you described.
  79. > Here's the (i know, it's AFU) output from my checksendmail; note
  80. > carefully the last hundreds of lines.
  81. X
  82. Ahh, maybe that's our source of confusion.  Mine does all this too.  The
  83. problem is that the first section ("Mail address resolution (rule 0)") is
  84. incomplete.  Addresses here are only being passed through 3 and 0.  But at
  85. the end of 0, the $: section is then passed through S and 4 before being
  86. passed to the mailer as $u.  That's what checksendmail isn't doing.
  87. X
  88. Do you read comp.mail.sendmail?  There has been a bit of discussion about
  89. this in the last couple of weeks (since I asked the question).  Some people
  90. say it's passed through 1 or 2 before S and 4, but I haven't been able to
  91. confirm that.
  92. X
  93. To clarify further, this is what happens to the envelope address:
  94. X
  95. X             /  $# mailer ->
  96. address -> 3 -> 0 -> -- $@ host -> $h
  97. X             \  $: user -> S -> 4 -> $u
  98. X
  99. Mark
  100. X
  101. -- 
  102. Mark Sirota - Department of Electrical Engineering Systems Staff
  103. University of Rochester, Rochester NY
  104. X Internet: msirota@ee.rochester.edu
  105. X UUCP:     {decvax,garp,harvard,hombre,rutgers}!rochester!ur-valhalla!msirota
  106. X
  107. >From msirota@ee.rochester.edu Tue Apr  2 10:11:58 1991
  108. Return-Path: <msirota@ee.rochester.edu>
  109. Received: from Central.Sun.COM (texsun.Central.Sun.COM) by rmtc.Central.Sun.COM (4.1/SMI-4.1-900117)
  110. X    id AA24601; Tue, 2 Apr 91 10:11:56 MST
  111. Received: from Sun.COM (sun-barr.EBay.Sun.COM) by Central.Sun.COM (4.1/SMI-4.1)
  112. X    id AA29918; Tue, 2 Apr 91 11:11:50 CST
  113. Received: from valhalla.ee.rochester.edu by Sun.COM (4.1/SMI-4.1)
  114. X    id AA29164; Tue, 2 Apr 91 09:11:41 PST
  115. Received: from socrates.ee.rochester.edu 
  116. X    by valhalla.ee.rochester.edu (4.1/cf1.38ee) 
  117. X    id AA26694; Tue, 2 Apr 91 12:11:23 EST
  118. Received: by socrates.ee.rochester.edu (4.1/cf1.1client)
  119. X    id AA15428; Tue, 2 Apr 91 12:10:55 EST
  120. Message-Id: <9104021710.AA15428@socrates.ee.rochester.edu>
  121. XFrom: msirota@socrates.ee.rochester.edu
  122. Date: Tue, 2 Apr 1991 12:10:53 -0500
  123. In-Reply-To: <9103312138.AA09713@rmtc.Central.Sun.COM>
  124. X       kolstad@Central.Sun.COM (Rob Kolstad) (Mar 31,  2:38pm)
  125. XX-Mailer: Mail User's Shell (7.2.2 3/26/90)
  126. To: kolstad@Central (Rob Kolstad)
  127. Subject: Re:  checksendmail recommendations
  128. Status: RO
  129. X
  130. On Mar 31,  2:38pm, Rob Kolstad writes:
  131. > hey -- why not send me your phone number so we can talk about this.
  132. > I think the secondary sections show the transformations you want.
  133. > You don't.
  134. X
  135. Right.  I'll explain it here in e-mail since you can look over it in text,
  136. but feel free to call if you want - (716) 275-8265.
  137. X
  138. The problem is that the lower transformations move the address through, say
  139. X
  140. X    3 -> 1 -> S -> 4
  141. X
  142. So it doesn't pass through 0.  Furthermore, the transformations I'm talking
  143. about, the ones that are missing, are not the entire address - it's only the
  144. local-part as determined by 0.
  145. X
  146. > I'm sure you're right -- I just need to talk about it to be sure.
  147. X
  148. If you have a SunOS 4.x manual set, check out the sendmail guide.  It's not
  149. well explained in there, but it *is* in there.  Or ask on
  150. comp.mail.sendmail; maybe someone else can explain it better.  I wish I had
  151. sources...
  152. X
  153. Anyway, I expect to be in my office all afternoon (east coast).
  154. X
  155. Mark
  156. X
  157. X
  158. SHAR_EOF
  159. chmod 0644 FIXTHIS ||
  160. echo 'restore of FIXTHIS failed'
  161. Wc_c="`wc -c < 'FIXTHIS'`"
  162. test 3984 -eq "$Wc_c" ||
  163.     echo 'FIXTHIS: original size 3984, current size' "$Wc_c"
  164. fi
  165. # ============= README ==============
  166. if test -f 'README' -a X"$1" != X"-c"; then
  167.     echo 'x - skipping README (File already exists)'
  168. else
  169. echo 'x - extracting README (Text)'
  170. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  171. If you have any questions or any feedback, please feel free to mail me at:
  172. X        kolstad@rmtc.Central.Sun.COM
  173. X
  174. Thanks to Gene Kim for his assistance in creating the PERL script.
  175. X
  176. There is still a slight, almost never noticeable bug in the way the
  177. from address is set up while still parsing rule 0.  I'll try to fix it
  178. by the 9/91...RK
  179. SHAR_EOF
  180. chmod 0644 README ||
  181. echo 'restore of README failed'
  182. Wc_c="`wc -c < 'README'`"
  183. test 331 -eq "$Wc_c" ||
  184.     echo 'README: original size 331, current size' "$Wc_c"
  185. fi
  186. # ============= address.resolve ==============
  187. if test -f 'address.resolve' -a X"$1" != X"-c"; then
  188.     echo 'x - skipping address.resolve (File already exists)'
  189. else
  190. echo 'x - extracting address.resolve (Text)'
  191. sed 's/^X//' << 'SHAR_EOF' > 'address.resolve' &&
  192. user
  193. user@ace
  194. user@ibapah
  195. user@ibapah.bsdi.com
  196. user@ace.bsdi.com
  197. ace!user
  198. ibapah!user
  199. xxx!user
  200. user@bsdi.com
  201. user@xxxxxxx.dom.bsdi.com
  202. user@xxxxxxx.com
  203. user@xxxxxxx.dom
  204. site!user
  205. site1!site2!user
  206. user@xxxxxxx.dom@bar.dom
  207. site!user@xxxxxxx.dom
  208. site!user@uunet.uu.net
  209. SHAR_EOF
  210. chmod 0644 address.resolve ||
  211. echo 'restore of address.resolve failed'
  212. Wc_c="`wc -c < 'address.resolve'`"
  213. test 266 -eq "$Wc_c" ||
  214.     echo 'address.resolve: original size 266, current size' "$Wc_c"
  215. fi
  216. # ============= checksendmail ==============
  217. if test -f 'checksendmail' -a X"$1" != X"-c"; then
  218.     echo 'x - skipping checksendmail (File already exists)'
  219. else
  220. echo 'x - extracting checksendmail (Text)'
  221. sed 's/^X//' << 'SHAR_EOF' > 'checksendmail' &&
  222. #!/usr/bin/perl
  223. X
  224. # checksendmail
  225. #
  226. #     The checksendmail program is a perl script that aids the testing
  227. #    of sendmail's various configuration filse.  checksendmail 
  228. #    passes typical addresses (supplied in input files) through
  229. #    sendmail and prints the result of the resolution and 
  230. #    transformation routines. 
  231. #
  232. #            Gene Kim & Rob Kolstad & Jeff Polk, 7/11/90
  233. X
  234. # --    -C config file
  235. # --    -r resolve file
  236. # --    -t towhom file
  237. # --    -f fromwhom file
  238. X
  239. # XXX deficiencies:  ``/etc/sendmail'' should be a parameter
  240. X
  241. X
  242. # defaults:
  243. X    $resolve  = "address.resolve";
  244. X    $towhom   = "address.resolve";
  245. X    $fromwhom = "address.resolve";
  246. X    $cffile   = "./sendmail.cf";
  247. X
  248. sub usage {
  249. X    die "Usage: checksendmail [-C configfile.cf] [-r resolve file] [-f fromwhom file] 
  250. X             [-t towhomfile] \n";
  251. }
  252. X
  253. for (unshift (@ARGV, "XX"); $#ARGV > 0; shift ARGV) {
  254. X    if ($ARGV[1] eq "-C") 
  255. X    {
  256. X        shift @ARGV;
  257. X        if ($#ARGV >= 1) {$cffile = $ARGV[1]; }
  258. X        else { &usage(); }
  259. X    } elsif ($ARGV[1] eq "-f")
  260. X    {
  261. X        shift @ARGV;
  262. X        if ($#ARGV >= 1) {$fromwhom = $ARGV[1]; }
  263. X        else { &usage(); }
  264. X    }
  265. X    elsif ($ARGV[1] eq "-t")
  266. X    {
  267. X        shift @ARGV;
  268. X        if ($#ARGV >= 1) {$towhom = $ARGV[1]; }
  269. X        else { &usage(); }
  270. X    }
  271. X    elsif ($ARGV[1] eq "-r")
  272. X    {
  273. X        shift @ARGV;
  274. X        if ($#ARGV >= 1) {$resolve = $ARGV[1]; }
  275. X        else { &usage(); }
  276. X    }
  277. X    else { &usage(); }
  278. }
  279. X
  280. if (!-e $cffile)   { die "Can't find configuration file $cffile\n"; }
  281. if (!-e $fromwhom) { die "Can't find name file $fromwhom\n"; }
  282. if (!-e $towhom)   { die "Can't find name file $towhom\n"; }
  283. if (!-e $resolve)  { die "Can't find name file $resolve\n"; }
  284. X
  285. # make sure the user can access the ../mqueue directory
  286. X
  287. $maildir = `grep ^OQ $cffile`;
  288. chop $maildir;
  289. $maildir =~ s/^OQ//;
  290. if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
  291. X    die "checksendmail: can't access $maildir!  aborting...\n";
  292. }
  293. X
  294. chop($hostname = `hostname`);
  295. chop($pwd = `pwd`);
  296. print "system: $hostname\t\tcurrent dir: $pwd\n";
  297. print "config file: $cffile\t\tresolve file: $resolve\n";
  298. print "towhom file: $towhom\t\tfromwhom file: $fromwhom\n\n\n";
  299. X
  300. sub handler {  # 1st argument is signal name
  301. X     local($sig) = @_;
  302. X     print STDERR "Caught a SIG$sig--shutting down\n";
  303. X     system("rm -f tmp");
  304. X     exit(0);
  305. }
  306. X
  307. $SIG{'INT'} = 'handler';
  308. $SIG{'QUIT'} = 'handler';
  309. X
  310. X
  311. # glean the mailers used from the rule 0 tests
  312. X
  313. sub parseresolve
  314. {
  315. X     $firstline = 1;
  316. X     while (<MAIL>)
  317. X     {
  318. X    if ($firstline == 1) { $firstline = 0; }
  319. X        chop;
  320. X        if (/^ADDRESS TEST MODE/) { next; }
  321. X        if (/^Enter <ruleset>/) { next; }
  322. X        if (/^>/)             # INPUT LINE! (and last output is done)
  323. X        {
  324. X         if ($prevline) {    # OUTPUT LINE!
  325. X             $prevline =~ s/.*returns:  *//;
  326. X             $prevline =~ s/"//g;
  327. X             $prevline =~ s/ //g;
  328. X
  329. # These three lines turn the non-Sun test mode delimiters
  330. # into easily-readable style. Should be okay to include though because
  331. # the matches will fail on a Sun.
  332. # Mark Sausville, MIT Media Laboratory, saus@media-lab.media.mit.edu
  333. X             $prevline =~ s/\^V/\$#/;
  334. X             $prevline =~ s/\^W/\$@/;
  335. X             $prevline =~ s/\^X/\$:/;
  336. X
  337. X     ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
  338. X             @t = split( '\$', $prevline);
  339. X             $address = "XXX";
  340. X             $remote = "XXX";
  341. X             $mailer = "XXX";
  342. X             for ($i = 1; $i <= $#t; $i++)
  343. X             {
  344. X             if (substr($t[$i], 0, 1) eq ":")
  345. X             { $address = substr($t[$i], 1,999); }
  346. X             if (substr($t[$i], 0, 1) eq "@")
  347. X             { $remote = substr($t[$i], 1,999); }
  348. X             if (substr($t[$i], 0, 1) eq "#")
  349. X             { $mailer =  substr($t[$i], 1,999); }
  350. X             }
  351. X        printf("%-27.27s --(%-6.6s)-->  %s[%s]\n", $input, $mailer,
  352. X                 $address, $remote);
  353. X        if ($mailer ne "XXX") { $themailers{$mailer}=1;}
  354. X         }
  355. X         s/> *//g;
  356. X         s/.*input: *//;
  357. X         s/ //g;
  358. X         s/"//g;
  359. X         $input = $_;
  360. X        }
  361. X        $prevline = $_;
  362. X     }
  363. }
  364. X
  365. # Parse output of sendmail name resolution 
  366. X
  367. sub parseaddress
  368. {
  369. ##   ADDRESS TEST MODE
  370. ##   Enter <ruleset> <address>
  371. ##   > rewrite: ruleset  3   input: "user"
  372. X
  373. X     open(MAIL, $_[0]) || die "Can't open $_[0]...\n";
  374. X     local ($k, $address, $prevline, $mailer, $remote, $input);
  375. X     print $_[1];            # the title
  376. X
  377. X     while (<MAIL>)
  378. X     {
  379. X    if (/^> *$/) { last; }
  380. X        if (/^ADDRESS TEST MODE/) { next; }
  381. X        if (/^Enter <ruleset>/) { next; }
  382. X        chop;
  383. X        if (/^>/)             # INPUT LINE! (and last output is done)
  384. X        {
  385. X             if ($prevline) {    # OUTPUT LINE!
  386. X                 $prevline =~ s/.*returns:  *//;
  387. X                 $prevline =~ s/"//g;
  388. X                 $prevline =~ s/ //g;
  389. #> rewrite: ruleset  3   input: "site" "!" "user" "@" "uunet" "." "uu" "." "net"
  390. #rewrite: ruleset  8   input: "site" "!" "user" "@" "uunet" "." "uu" "." "net"
  391. #> 
  392. X                    printf("%-27.27s ---->  %s\n", $input, $prevline);
  393. X             }
  394. X             s/> *//g;
  395. X             s/.*input: *//;
  396. X             s/ //g;
  397. X             s/"//g;
  398. X             $input = $_;
  399. X        }
  400. X        $prevline = $_;
  401. X     }
  402. X    close(MAIL);
  403. }
  404. X
  405. X
  406. # pass names from resolve files to sendmail
  407. X
  408. open(IN, $resolve) || die "can't open $resolve\n";
  409. open(OUT, ">tmp") || die "can't open tmp\n";
  410. while (<IN>) 
  411. {
  412. X    if ($_ ne "\n") { print OUT "0 $_"; }
  413. }
  414. close(OUT);
  415. close(IN);
  416. X
  417. $sendmailprog = "/usr/lib/sendmail -bt -C$cffile < tmp|";
  418. open(MAIL, $sendmailprog) || die "can't exec $sendmailprog...\n";
  419. print "Mail address resolution (rule 0)\n\n";
  420. &parseresolve();
  421. close(SENDMAIL);
  422. X
  423. # Get the R= and S= special rulesets from the configuration
  424. X
  425. open(FID, "grep ^M $cffile|");
  426. while (<FID>)
  427. {
  428. #    Mether,    P=[IPC], F=msDFMueCX, S=11, R=21, A=IPC $h
  429. X    chop;
  430. X    $thisline = $_; $thisline =~ s/M//; $thisline =~ s/,.*//;
  431. X    $sendrule = $_; $sendrule =~ s/.*S=//; $sendrule =~ s/,.*//;
  432. X    $recvrule = $_; $recvrule =~ s/.*R=//; $recvrule =~ s/,.*//;
  433. X    $sendrules{$thisline} = $sendrule;
  434. X    $recvrules{$thisline} = $recvrule;
  435. }
  436. close(FID);
  437. X
  438. # pass names from fromwhom file through sendmail
  439. X
  440. foreach $i (keys %themailers)
  441. {
  442. X    $sendmailprog = "|/usr/lib/sendmail -bt -C$cffile > tmp";
  443. X    if ($recvrules{$i} == 0) {
  444. X    print "\n\nCan't find recv rule for `$i', skipping this mailer <-------------------\n";
  445. X    next;
  446. X    }
  447. X    open (OUT, $sendmailprog);
  448. X    open (IN, $fromwhom);
  449. X    while (<IN>) {
  450. X        chop;
  451. X        if (/^$/) { next; }
  452. X    $address = $_;
  453. X        print OUT "2,$recvrules{$i},4, $address\n";
  454. X    }
  455. X    print OUT "\n";            # stuff last line into sendmail
  456. X    close(IN);
  457. X    close(OUT);
  458. X    &parseaddress ("tmp", "\n\n`To' address transformations for mailer $i:\n\n");
  459. }
  460. X
  461. # pass names from towhom file through sendmail 
  462. X
  463. foreach $i (keys %themailers)
  464. {
  465. X    $sendmailprog = "|/usr/lib/sendmail -bt -C$cffile > tmp";
  466. X    if ($sendrules{$i} == 0) {
  467. X    print "\n\nCan't find send rule for `$i', skipping this mailer <-------------------\n";
  468. X    next;
  469. X    }
  470. X    open (OUT, $sendmailprog);
  471. X    open (IN, $towhom);
  472. X    while (<IN>) {
  473. X        chop;
  474. X        if (/^$/) { next; }
  475. X    $address = $_;
  476. X        print OUT "1,$sendrules{$i},4, $address\n";
  477. X    }
  478. X    print OUT "\n";            # stuff last line into sendmail
  479. X    close(IN);
  480. X    close(OUT);
  481. X    &parseaddress ("tmp", "\n\n`From' address transformations for mailer $i:\n\n");
  482. }
  483. X
  484. system("rm -f tmp");
  485. SHAR_EOF
  486. chmod 0775 checksendmail ||
  487. echo 'restore of checksendmail failed'
  488. Wc_c="`wc -c < 'checksendmail'`"
  489. test 7140 -eq "$Wc_c" ||
  490.     echo 'checksendmail: original size 7140, current size' "$Wc_c"
  491. fi
  492. # ============= checksendmail.8 ==============
  493. if test -f 'checksendmail.8' -a X"$1" != X"-c"; then
  494.     echo 'x - skipping checksendmail.8 (File already exists)'
  495. else
  496. echo 'x - extracting checksendmail.8 (Text)'
  497. sed 's/^X//' << 'SHAR_EOF' > 'checksendmail.8' &&
  498. .TH CHECKSENDMAIL 8 LOCAL
  499. .CX
  500. .SH NAME
  501. checksendmail \- verify 
  502. .B sendmail 
  503. address transformations
  504. .SH SYNOPSIS
  505. .B checksendmail
  506. [
  507. .B \-C
  508. .I file.cf 
  509. ] [
  510. .B \-r
  511. .I resolve 
  512. ] [
  513. .B \-t
  514. .I towhom 
  515. ] [
  516. .B \-f
  517. .I fromwhom 
  518. ]
  519. .SH DESCRIPTION
  520. .LP
  521. The 
  522. .B checksendmail
  523. program is a 
  524. .B perl
  525. script that aids the testing of 
  526. .B sendmail's 
  527. various configuration files.
  528. .B checksendmail 
  529. passes typical addresses (supplied in input files) through
  530. .B sendmail
  531. and prints the results of the resolution and transformation routines.
  532. .LP
  533. The input files contain a list of addresses, one per line.  
  534. Here is an example:
  535. .RS
  536. .nf
  537. user
  538. user@site
  539. user@site.com
  540. .fi
  541. .RE
  542. .SH OPTIONS
  543. .TP 16
  544. .BI \-C " file.cf"
  545. Use the 
  546. .B sendmail
  547. configuration file 
  548. .I file.cf
  549. instead of the default 
  550. .B "/etc/sendmail.cf"
  551. file.
  552. .TP
  553. .BI \-r " resolve"
  554. Use
  555. .I resolve
  556. as the input file for the addresses to be used for mail resolving.  Defaults
  557. to
  558. .BR address.resolve \|.
  559. .TP
  560. .BI \-t " towhom"
  561. Use 
  562. .I towhom
  563. as the input file for the ``from whom'' addresses.
  564. .I towhom
  565. defaults to 
  566. .BR address.resolve \|.
  567. .TP
  568. .BI \-f " fromwhom"
  569. Use
  570. .I fromwhom
  571. as the input file for the ``to whom'' addresses.
  572. .I fromwhom
  573. defaults to
  574. .BR address.resolve \|.
  575. .SH EXAMPLES
  576. The following command will pass the addresses in `address.resolve' through 
  577. .B sendmail 
  578. using the configuration information in 
  579. .I myconfig.cf \|.  
  580. .LP
  581. .RS
  582. .ft CW
  583. .ft CB
  584. example% 
  585. .ft CW
  586. cat address.resolve
  587. .nf
  588. user
  589. user@site
  590. user@site.com
  591. .ft P
  592. .fi
  593. example% 
  594. .ft P
  595. checksendmail \-C myconfig.cf
  596. .nf
  597. config file: myconfig.cf        resolve file: address.resolve
  598. towhom file: address.resolve        fromwhom file: address.resolve
  599. .sp 0.5
  600. Mail address resolution
  601. .sp 0.5
  602. user                        --(ether )-->  user[rmtc]
  603. user@site                   --(ether )-->  user@site[rmtc]
  604. user@site.com               --(ether )-->  user@site.com[rmtc]
  605. .sp 0.5
  606. `To' address transformations for mailer ether:
  607. .sp 0.5
  608. user                        ---->  user
  609. user@site                   ---->  user@site
  610. user@site.com               ---->  user@site.com
  611. .sp 0.5
  612. `From' address transformations for mailer ether:
  613. .sp 0.5
  614. user                        ---->  user
  615. user@site                   ---->  user
  616. user@site.com               ---->  user
  617. .sp
  618. .fi
  619. .ft R
  620. .RE
  621. .LP
  622. The first section of the output shows how the addresses in the input
  623. files are resolved by 
  624. .BR sendmail \|.
  625. Consider the following output line:
  626. .nf
  627. .RS
  628. .ft CW
  629. user@site.com               --(ether )-->  user@site.com[rmtc]
  630. .ft
  631. .RE
  632. .fi
  633. The input address \f(CWuser@site.com\fP resolves to use the 
  634. \f(CWether\fP mailer.  That mailer is directed to send the mail to
  635. to the user \f(CWuser@site.com\fP
  636. at site \f(CWrmtc\fP (as indicated in the square brackets)
  637. .LP
  638. The two later sections of output show how the addresses specified as
  639. the `To' and `From' address are transformed in the text of the
  640. headers.  In the example above, the `To' addresses are untouched.
  641. The `From' addresses, however, all lose their machine information on
  642. the way through the mailer:
  643. .nf
  644. .RS
  645. .ft CW
  646. user@site                   ---->  user
  647. .ft
  648. .RE
  649. .fi
  650. This may be the result when using this configuration file on a
  651. workstation which is to be hidden as a mailhost from the rest of the
  652. network.
  653. .LP
  654. Here is a set of addresses used at one site for the purposes of
  655. testing address resolution.  Italics are comments detailing why
  656. particular addresses are present:
  657. .nf
  658. .ta 2.25i
  659. .in +0.6i
  660. user    \f2Standard trivial address\fP
  661. user@rmtc    \f2qualified at one level\fP
  662. user@rmtc.central    \f2qualified at two levels\fP
  663. user@rmtc.central.sun.com    \f2qualified all the way\fP
  664. rmtc!user    \f2local but specified as uucp\fP
  665. .sp 0.3
  666. user@summit    \f2a workstation (normally delivered locally, though)\fP
  667. user@summit.central    \f2same but more qualified\fP
  668. user@summit.central.sun.com    \f2same but fully qualified\fP
  669. summit!user    \f2same but specified as uucp\fP
  670. .sp 0.3
  671. user@prisma    \f2Backward compatibility tests\fP
  672. user@prisma.com    
  673. prisma!user    
  674. .sp 0.3
  675. user@central    \f2Superior domain testing\fP
  676. user@machine.central    \f2more qualified, but unknown\fP
  677. user@summit.central    \f2more qualified and known\fP
  678. user@eng    \f2name in faraway domain\fP
  679. user@machine.eng    \f2unknown machine in faraway domain\fP
  680. user@summit.eng    \f2local machine, far away domain\fP
  681. user@hoback    \f2far away machine\fP
  682. .sp 0.3
  683. user@machine    \f2apparently local but unknown machine\fP
  684. user@sun.com    \f2Standard trivial address\fP
  685. user@machine.dom.sun.com    \f2fully qualified but unknown machine\fP
  686. .sp 0.3
  687. user@foo.com    \f2standard, known, really far away domain \fP
  688. user@foo.dom    \f2standard, unknown, really far away domain\fP
  689. .sp 0.3
  690. site!user    \f2Single level uucp\fP
  691. site1!site2!user    \f2Double level uucp\fP
  692. .sp 0.3
  693. user@foo.dom@bar.dom    \f2Trickier address\fP
  694. site!user@foo.dom    \f2Mixed uucp/domain\fP
  695. site!user@uunet.uu.net    \f2Mixed double uucp/domain\fP
  696. .fi
  697. .in
  698. .SH NOTES
  699. Note that 
  700. .B checksendmail
  701. is a 
  702. .B perl 
  703. script.  If your site does not have
  704. .BR perl ,
  705. it can be obtained via anonymous
  706. .B ftp
  707. at uunet.uu.net\|.
  708. .LP
  709. .B sendmail
  710. requires that the user have access to directory specified by the `OQ'
  711. parameter in the configuration file (normally 
  712. .BR /usr/spool/mqueue ).
  713. .B checksendmail
  714. verifies that the user has access to this directory before allowing the 
  715. test to continue.
  716. X
  717. .SH "SEE ALSO"
  718. .BR sendmail (8),
  719. .BR sendmail.cf (8),
  720. SHAR_EOF
  721. chmod 0644 checksendmail.8 ||
  722. echo 'restore of checksendmail.8 failed'
  723. Wc_c="`wc -c < 'checksendmail.8'`"
  724. test 5314 -eq "$Wc_c" ||
  725.     echo 'checksendmail.8: original size 5314, current size' "$Wc_c"
  726. fi
  727. # ============= error.mail.fix ==============
  728. if test -f 'error.mail.fix' -a X"$1" != X"-c"; then
  729.     echo 'x - skipping error.mail.fix (File already exists)'
  730. else
  731. echo 'x - extracting error.mail.fix (Text)'
  732. sed 's/^X//' << 'SHAR_EOF' > 'error.mail.fix' &&
  733. XFrom gamin@ireq-robot.hydro.qc.ca Fri Aug 16 11:28:23 1991
  734. Return-Path: <gamin@ireq-robot.hydro.qc.ca>
  735. Received: from Central.Sun.COM (central.Central.Sun.COM) by rmtc.Central.Sun.COM (4.1/SMI-4.1-900117)
  736. X    id AA05534; Fri, 16 Aug 91 11:28:21 MDT
  737. Received: from Sun.COM (sun-barr.EBay.Sun.COM) by Central.Sun.COM (4.1/SMI-4.1)
  738. X    id AA11276; Fri, 16 Aug 91 12:28:20 CDT
  739. Received: from clouso.crim.ca by Sun.COM (4.1/SMI-4.1)
  740. X    id AA24128; Fri, 16 Aug 91 10:28:16 PDT
  741. Received: by clouso.crim.ca (5.57/Ultrix3.0-C)
  742. X    id AA05679; Fri, 16 Aug 91 13:21:52 EDT
  743. Received: from pellan.ireq-robot by ireq-robot.hydro.qc.ca (4.1/IRBT-2.2)
  744. X    id AA06086; Fri, 16 Aug 91 13:32:53 EDT
  745. Date: Fri, 16 Aug 91 13:32:53 EDT
  746. XFrom: Martin Boyer <gamin@ireq-robot.hydro.qc.ca>
  747. Message-Id: <9108161732.AA06086@ireq-robot.hydro.qc.ca>
  748. To: kolstad@rmtc.Central.Sun.COM
  749. Subject: checksendmail
  750. Status: RO
  751. X
  752. Hi,
  753. X
  754. I think your program is great.  I had a little shell script of my own,
  755. but yours is much better.  I have made two changes that are useful:
  756. X
  757. 1. I never had any need to access the /var/spool/queue directory in
  758. X   test mode.  I changed the 'die' for a 'warn'
  759. X
  760. 2. The 'error' mailer outputs error messages instead of addresses.
  761. X   I modified the parsing to keep the spaces in those messages.
  762. X
  763. Here's the diff file:
  764. X
  765. *** checksendmail.orig    Fri Aug 16 11:02:52 1991
  766. --- checksendmail    Fri Aug 16 13:24:10 1991
  767. ***************
  768. *** 65,71 ****
  769. X  chop $maildir;
  770. X  $maildir =~ s/^OQ//;
  771. X  if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
  772. !     die "checksendmail: can't access $maildir!  aborting...\n";
  773. X  }
  774. X  
  775. X  chop($hostname = `hostname`);
  776. --- 65,72 ----
  777. X  chop $maildir;
  778. X  $maildir =~ s/^OQ//;
  779. X  if ((!-r $maildir) || (!-x $maildir) || (!-w $maildir)) { 
  780. ! #    die "checksendmail: can't access $maildir!  aborting...\n";
  781. !     warn "checksendmail: can't access $maildir! trying anyway...\n";
  782. X  }
  783. X  
  784. X  chop($hostname = `hostname`);
  785. ***************
  786. *** 103,109 ****
  787. X           if ($prevline) {    # OUTPUT LINE!
  788. X               $prevline =~ s/.*returns:  *//;
  789. X               $prevline =~ s/"//g;
  790. !              $prevline =~ s/ //g;
  791. X       ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
  792. X               @t = split( '\$', $prevline);
  793. X               $address = "XXX";
  794. --- 104,114 ----
  795. X           if ($prevline) {    # OUTPUT LINE!
  796. X               $prevline =~ s/.*returns:  *//;
  797. X               $prevline =~ s/"//g;
  798. !         # Don't strip spaces off error messages
  799. ! #             $prevline =~ s/ //g;
  800. !         $prevline =~ s/ *([.!%<>]) */$1/g;
  801. !         $prevline =~ s/ +([;?\$])/$1/g;
  802. !         $prevline =~ s/([#@:]) +/$1/g;
  803. X       ####   $#ether$@sun-barr.Ebay.Sun.COM$:site!user@uunet.uu.NET
  804. X               @t = split( '\$', $prevline);
  805. X               $address = "XXX";
  806. X
  807. X
  808. You can do what you want with these changes, their yours if you want
  809. them.
  810. X
  811. X
  812. Martin
  813. X
  814. --
  815. Martin Boyer                            mboyer@ireq-robot.hydro.qc.ca
  816. Institut de recherche d'Hydro-Quebec    mboyer@ireq-robot.uucp
  817. Varennes, QC, Canada   J3X 1S1
  818. +1 514 652-8412
  819. X
  820. SHAR_EOF
  821. chmod 0644 error.mail.fix ||
  822. echo 'restore of error.mail.fix failed'
  823. Wc_c="`wc -c < 'error.mail.fix'`"
  824. test 2973 -eq "$Wc_c" ||
  825.     echo 'error.mail.fix: original size 2973, current size' "$Wc_c"
  826. fi
  827. exit 0
  828.  
  829. ================================================================
  830.  
  831. To: karl@grebyn.com (Karl A. Nyberg)
  832. Subject: Re: Perl Package to test Sendmail.cf?
  833. Date: Thu, 13 Aug 1992 09:06:55 +1200
  834. From: Andy Linton <andy.linton@comp.vuw.ac.nz>
  835.  
  836. #! /bin/sh
  837. # This is a shell archive.  Remove anything before this line, then unpack
  838. # it by saving it into a file and typing "sh file".  To overwrite existing
  839. # files, type "sh file -c".  You can also feed this as standard input via
  840. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  841. # will see the following message at the end:
  842. #        "End of archive 1 (of 1)."
  843. # Contents:  cfdebug cftest debug.in
  844. # Wrapped by post@imagine.pawl.rpi.edu on Fri Sep 15 11:44:26 1989
  845. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  846. if test -f 'cfdebug' -a "${1}" != "-c" ; then 
  847.   echo shar: Will not clobber existing file \"'cfdebug'\"
  848. else
  849. echo shar: Extracting \"'cfdebug'\" \(1343 characters\)
  850. sed "s/^X//" >'cfdebug' <<'END_OF_FILE'
  851. X#! /bin/sh
  852. X#
  853. X# This shell script runs sendmail in address test mode and converts the
  854. X# debugging output to something more intelligible for helping debug sendmail.cf
  855. X# files.
  856. X# 
  857. X# Pass the config file to use as $1  - /usr/lib/sendmail.cf by default
  858. X#
  859. X# Enter input of the form (same as for "sendmail -bt"):
  860. X# 
  861. X#       0 address1
  862. X#       0 address2
  863. X#       ...
  864. X#       (eof)
  865. X# 
  866. X#
  867. Xif [ $# -eq 0 ]
  868. Xthen 
  869. X    cf="/usr/lib/sendmail.cf" 
  870. Xelse
  871. X    cf=$1
  872. Xfi
  873. Xif [ ! -r $cf ]
  874. Xthen
  875. X    echo "File '$cf' not readable, exiting..."
  876. X    exit
  877. Xfi
  878. Xsudo /usr/lib/sendmail -bt -C$cf -d21.12 |\
  879. Xgrep -v -e '----- rule fails' |\
  880. Xsed -e 's/-----trying rule:/R/' \
  881. X    -e 's/"^P"/$*/g' \
  882. X    -e 's/"^Q"/$+/g' \
  883. X    -e 's/"^R"/$-/g' \
  884. X    -e 's/"^S\([A-Za-z]\)"/$=\1/g' \
  885. X    -e 's/"^T\([0-9]\)"/$\1/g' \
  886. X    -e 's/"^U"/$#/' \
  887. X    -e 's/"^V"/$\&/g' \
  888. X    -e 's/"^W"/$:/g' \
  889. X    -e 's/"^X"/$>/g' \
  890. X    -e 's/"//g' |\
  891. Xsed -e '/^R/s/[     ]//g' \
  892. X    -e '/matches:/s/[     ]//g' -e 's/rulematches:/rule matches: /' \
  893. X    -e '/rewritten as:/s/[     ]//g' -e 's/rewrittenas:/rewritten as: /' \
  894. X    -e '/returns:/s/[     ]//g' \
  895. X    -e 's/.*ruleset\([0-9]\)returns:/ruleset \1 returns: /' \
  896. X    -e '/input:/s/[     ]//g' \
  897. X    -e 's/.*ruleset\(.*\)input:/ruleset \1 input: /'
  898. X#
  899. X# Compliments of the author:  Dan Long
  900. X#                             CSNET Technical Staff
  901. X#                       long@sh.cs.net
  902. END_OF_FILE
  903. if test 1343 -ne `wc -c <'cfdebug'`; then
  904.     echo shar: \"'cfdebug'\" unpacked with wrong size!
  905. fi
  906. chmod +x 'cfdebug'
  907. # end of 'cfdebug'
  908. fi
  909. if test -f 'cftest' -a "${1}" != "-c" ; then 
  910.   echo shar: Will not clobber existing file \"'cftest'\"
  911. else
  912. echo shar: Extracting \"'cftest'\" \(293 characters\)
  913. sed "s/^X//" >'cftest' <<'END_OF_FILE'
  914. X#!/bin/sh
  915. X# A script to put debug input a line at a time through cfdebug.  JRA 05/10/89
  916. X# call like this (with the file sendmail.cf in the current directory):
  917. X#  cftest < debug.in > debug.out &
  918. Xwhile read line ; do
  919. X  echo $line 
  920. X  echo $line | cfdebug sendmail.cf | grep '0 returns: $#' 
  921. Xdone
  922. END_OF_FILE
  923. if test 293 -ne `wc -c <'cftest'`; then
  924.     echo shar: \"'cftest'\" unpacked with wrong size!
  925. fi
  926. chmod +x 'cftest'
  927. # end of 'cftest'
  928. fi
  929. if test -f 'debug.in' -a "${1}" != "-c" ; then 
  930.   echo shar: Will not clobber existing file \"'debug.in'\"
  931. else
  932. echo shar: Extracting \"'debug.in'\" \(573 characters\)
  933. sed "s/^X//" >'debug.in' <<'END_OF_FILE'
  934. X0 user@bit.BITNET
  935. X0 bit.BITNET!user
  936. X0 some.random.domain!user
  937. X0 user@LOCAL
  938. X0 site!user@uunet.uu.net
  939. X0 <@host1,@host2,@host3:a@b.com>
  940. X0 uunet!site1!site2
  941. X0 user@itsgw.rpi.edu
  942. X0 user@blah.its.rpi.edu
  943. X0 user@rpi.edu
  944. X0 user@pawl.rpi.edu
  945. X0 userxxxx@mts.rpi.edu
  946. X0 blah!nyser!user
  947. X0 uunet!itsgw!user
  948. X0 uunet!rpi!postmaster
  949. X0 uunet!itsgw!mts!userfred@some.where.edu
  950. X0 itsgw!user@uunet.uu.net
  951. X0 adobe!someone@decwrl.dec.com
  952. END_OF_FILE
  953. if test 573 -ne `wc -c <'debug.in'`; then
  954.     echo shar: \"'debug.in'\" unpacked with wrong size!
  955. fi
  956. # end of 'debug.in'
  957. fi
  958. echo shar: End of archive 1 \(of 1\).
  959. cp /dev/null ark1isdone
  960. MISSING=""
  961. for I in 1 ; do
  962.     if test ! -f ark${I}isdone ; then
  963.     MISSING="${MISSING} ${I}"
  964.     fi
  965. done
  966. if test "${MISSING}" = "" ; then
  967.     echo You have the archive.
  968.     rm -f ark[1-9]isdone
  969. else
  970.     echo You still need to unpack the following archives:
  971.     echo "        " ${MISSING}
  972. fi
  973. ##  End of shell archive.
  974. exit 0
  975. --------------end of shar file --------------
  976. --
  977. ---Jim Ault, ITS Postmaster, Rensselaer Polytechnic Inst, Troy NY, 12180
  978.    Postmaster@rpi.edu    Jim_Ault@rpitsmts.BITNET   Jim_Ault@mts.rpi.edu
  979.    518-276-2750 (voice)     ...uunet!rpi.edu!ault     518-276-2809 (fax)
  980.  
  981.  
  982. ================================================================
  983. -- 
  984. Karl A. Nyberg                karl@grebyn.com
  985. Post Office Box 497            Grebyn Corporation
  986. Vienna, VA 22183-0497 USA        +1-703-281-2194
  987.