home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / dnswalk / patch02 next >
Internet Message Format  |  1994-08-10  |  11KB

  1. From: barr@pop.psu.edu (David Barr)
  2. Newsgroups: comp.sources.misc
  3. Subject: v44i018:  dnswalk - A DNS database debugger, Patch02
  4. Date: 10 Aug 1994 15:57:46 -0500
  5. Organization: Penn State Population Research Institute
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <32bf0a$dqj@sparky.sterling.com>
  9. X-Md4-Signature: e0e0496dbded9722447a31281c375391
  10.  
  11. Submitted-by: barr@pop.psu.edu (David Barr)
  12. Posting-number: Volume 44, Issue 18
  13. Archive-name: dnswalk/patch02
  14. Environment: Perl, Dig, DNS
  15. Patch-To: dnswalk: Volume 43, Issue 50
  16.  
  17. This will give you dnswalk 1.8.2.
  18.  
  19. This release accounts for Solaris 2.x's unfriendly gethostbyname(),
  20. spelling errors, and some fixes in lame delegation checking.
  21. Of note is that I'm now sure that dnswalk works with Perl 5.
  22.  
  23. dnswalk is a DNS debugger.  It performs zone transfers of specified
  24. domains, and checks the database in numerous ways for internal
  25. consistency, as well as accuracy.
  26.  
  27.     This program may be freely distributed, as long as this notice
  28. and documentation are distributed with the program.  This program is
  29. released as-is, with no warranty expressed or implied.  Some assembly
  30. required, contents may settle during shipment.  This program can be
  31. found in:
  32.  
  33. ftp.pop.psu.edu:/pub/src/dnswalk/  or the mirrors:
  34. ftp.uu.net:/networking/ip/dns/dnswalk/*
  35. ftp.edu.tw:/UNIX/networking/dns/dnswalk/*
  36. ftp.univ-lyon1.fr:/pub/unix/network/tcpip/dns/dnswalk/*
  37.  
  38.  
  39. *** dnswalk.1.8.1/README    Sun Jul 24 16:33:15 1994
  40. --- README    Sun Jul 24 16:33:57 1994
  41. ***************
  42. *** 1,7 ****
  43. !         dnswalk 1.8 - June 1994
  44.   
  45.   Author: David Barr <barr@pop.psu.edu>
  46. ! $Id: README,v 1.3 1994/06/27 14:13:44 barr Exp barr $
  47.   
  48.   INTRO
  49.   
  50. --- 1,7 ----
  51. !         dnswalk 1.8.2 - June 1994
  52.   
  53.   Author: David Barr <barr@pop.psu.edu>
  54. ! $Id: README,v 1.4 1994/07/24 20:33:54 barr Exp barr $
  55.   
  56.   INTRO
  57.   
  58. *** dnswalk.1.8.1/CHANGES    Sun Jul 24 16:33:23 1994
  59. --- CHANGES    Sun Jul 24 16:33:50 1994
  60. ***************
  61. *** 1,4 ****
  62. ! $Id: CHANGES,v 1.4 1994/06/27 14:13:38 barr Exp barr $
  63.   Version 1.8.1
  64.   One-line fix to remove reference to non-existent parameter to getmaster().
  65.   Reported by petri@ibr.cs.tu-bs.de (Stefan Petri).
  66. --- 1,13 ----
  67. ! $Id: CHANGES,v 1.7 1994/07/24 20:33:43 barr Exp barr $
  68. ! Version 1.8.2
  69. ! Fixed spelling errors and shoddy syntax in getauthservers(), from
  70. ! Jost Krieger <Jost.Krieger@rz.ruhr-uni-bochum.de>
  71. ! Accounted for Solaris's broken gethostbyname() which includes trailing
  72. ! dots in retuned name.
  73. ! Minor fixes in lame delegation checking, and getauthservers().
  74.   Version 1.8.1
  75.   One-line fix to remove reference to non-existent parameter to getmaster().
  76.   Reported by petri@ibr.cs.tu-bs.de (Stefan Petri).
  77. *** dnswalk.1.8.1/dnswalk    Sun Jul 24 16:33:23 1994
  78. --- dnswalk    Sun Jul 24 16:34:18 1994
  79. ***************
  80. *** 2,8 ****
  81.   # dnswalk    Walk through a DNS tree, pulling out zone data and
  82.   # dumping it in a directory tree
  83.   #
  84. ! # $Id: dnswalk,v 1.9 1994/06/27 14:13:24 barr Exp barr $
  85.   #
  86.   # check data collected for legality using standard resolver
  87.   #
  88. --- 2,8 ----
  89.   # dnswalk    Walk through a DNS tree, pulling out zone data and
  90.   # dumping it in a directory tree
  91.   #
  92. ! # $Id: dnswalk,v 1.11 1994/07/24 20:34:14 barr Exp barr $
  93.   #
  94.   # check data collected for legality using standard resolver
  95.   #
  96. ***************
  97. *** 65,71 ****
  98.           }
  99.       }
  100.   }
  101. ! # try to get a zone transfer, trying each listed authoratative server if
  102.   # if fails.
  103.   sub doaxfr {
  104.       local ($domain)=@_[0];
  105. --- 65,71 ----
  106.           }
  107.       }
  108.   }
  109. ! # try to get a zone transfer, trying each listed authoritative server if
  110.   # if fails.
  111.   sub doaxfr {
  112.       local ($domain)=@_[0];
  113. ***************
  114. *** 75,81 ****
  115.                   # error handling
  116.       ($path=&host2path($domain)) =~ tr/A-Z/a-z/;
  117.       local(@servers) = &getauthservers($domain);
  118. !     &printerr("warning: $domain has only one authoratative nameserver\n") if (scalar(@servers) == 1);
  119.       &printerr("warning: $domain has NO authoritative nameservers!\n") if (scalar(@servers) == 0);
  120.       if ((-f "$basedir/$path/axfr") && (!$main'opt_f)) {
  121.           open(DIG,"<$basedir/$path/axfr") || die "cannot open $basedir/$path/axfr: $!\n";
  122. --- 75,81 ----
  123.                   # error handling
  124.       ($path=&host2path($domain)) =~ tr/A-Z/a-z/;
  125.       local(@servers) = &getauthservers($domain);
  126. !     &printerr("warning: $domain has only one authoritative nameserver\n") if (scalar(@servers) == 1);
  127.       &printerr("warning: $domain has NO authoritative nameservers!\n") if (scalar(@servers) == 0);
  128.       if ((-f "$basedir/$path/axfr") && (!$main'opt_f)) {
  129.           open(DIG,"<$basedir/$path/axfr") || die "cannot open $basedir/$path/axfr: $!\n";
  130. ***************
  131. *** 197,209 ****
  132.       local ($s);
  133.       open(DIG,"dig +noau ns $_[0] 2>/dev/null|");
  134.       local(@servers)=();
  135. !     local(@servhash)=();
  136.       while (<DIG>) {
  137.           chop;
  138.       tr/A-Z/a-z/;
  139.           if (/\S+\s+\d+\s+ns\s+(\S+)/) {
  140.           $s=$1;
  141. !         if ($s eq $master) {
  142.           $foundmaster=1;   # make sure the master is at the top
  143.           } else {
  144.                   push(@servers,$s) if ($servhash{$s}++<1);
  145. --- 197,209 ----
  146.       local ($s);
  147.       open(DIG,"dig +noau ns $_[0] 2>/dev/null|");
  148.       local(@servers)=();
  149. !     local(%servhash)=();
  150.       while (<DIG>) {
  151.           chop;
  152.       tr/A-Z/a-z/;
  153.           if (/\S+\s+\d+\s+ns\s+(\S+)/) {
  154.           $s=$1;
  155. !         if (&equal($s,$master)) {
  156.           $foundmaster=1;   # make sure the master is at the top
  157.           } else {
  158.                   push(@servers,$s) if ($servhash{$s}++<1);
  159. ***************
  160. *** 212,218 ****
  161.       }
  162.       close(DIG);
  163.       if ($foundmaster) {
  164. !     unshift(servers,$master);
  165.       }
  166.       return @servers;
  167.   }
  168. --- 212,218 ----
  169.       }
  170.       close(DIG);
  171.       if ($foundmaster) {
  172. !     unshift(@servers,$master);
  173.       }
  174.       return @servers;
  175.   }
  176. ***************
  177. *** 288,294 ****
  178.                           if (!$name) {
  179.                               &printerr(" $_[0] PTR $_[3]: unknown host\n");
  180.                           }
  181. !                         elsif (!&equal(($name.'.'),$_[3])) {
  182.                               &printerr(" $_[0] PTR $_[3]: CNAME (to $name)\n");
  183.                           }    
  184.                           elsif (!&matchaddrlist($_[0])) {
  185. --- 288,294 ----
  186.                           if (!$name) {
  187.                               &printerr(" $_[0] PTR $_[3]: unknown host\n");
  188.                           }
  189. !                         elsif (!&equal($name,$_[3])) {
  190.                               &printerr(" $_[0] PTR $_[3]: CNAME (to $name)\n");
  191.                           }    
  192.                           elsif (!&matchaddrlist($_[0])) {
  193. ***************
  194. *** 307,313 ****
  195.                   if (!$name) {
  196.                       &printerr(" $_[0] A $_[3]: no PTR record\n");
  197.                   }
  198. !                 elsif ($opt_F && !&equal($name.".",$_[0])) {
  199.                       &printerr(" $_[0] A $_[3]: points to $name\n") if ((split(/\./,$name,1))[0] ne "localhost");
  200.                   }
  201.                   if ($main'opt_a) {
  202. --- 307,313 ----
  203.                   if (!$name) {
  204.                       &printerr(" $_[0] A $_[3]: no PTR record\n");
  205.                   }
  206. !                 elsif ($opt_F && !&equal($name,$_[0])) {
  207.                       &printerr(" $_[0] A $_[3]: points to $name\n") if ((split(/\./,$name,1))[0] ne "localhost");
  208.                   }
  209.                   if ($main'opt_a) {
  210. ***************
  211. *** 331,337 ****
  212.               else {
  213.                   if (!$name) {
  214.                       &printerr(" $_[0] NS $_[3]: unknown host\n");
  215. !                 } elsif (!&equal(($name.'.'),$_[3])) {
  216.                       &printerr(" $_[0] NS $_[3]: CNAME (to $name)\n");
  217.                   }
  218.               }
  219. --- 331,337 ----
  220.               else {
  221.                   if (!$name) {
  222.                       &printerr(" $_[0] NS $_[3]: unknown host\n");
  223. !                 } elsif (!&equal($name,$_[3])) {
  224.                       &printerr(" $_[0] NS $_[3]: CNAME (to $name)\n");
  225.                   }
  226.               }
  227. ***************
  228. *** 346,352 ****
  229.                   if (!$name) {
  230.                       &printerr(" $_[0] MX $_[3]: unknown host\n");
  231.                   }
  232. !                 elsif (!&equal(($name.'.'),$mx)) {
  233.                       &printerr(" $_[0] MX $_[3]: CNAME (to $name)\n");
  234.                   }
  235.               }
  236. --- 346,352 ----
  237.                   if (!$name) {
  238.                       &printerr(" $_[0] MX $_[3]: unknown host\n");
  239.                   }
  240. !                 elsif (!&equal($name,$mx)) {
  241.                       &printerr(" $_[0] MX $_[3]: CNAME (to $name)\n");
  242.                   }
  243.               }
  244. ***************
  245. *** 358,364 ****
  246.               else {
  247.                   if (!$name) {
  248.                       &printerr(" $_[0] CNAME $_[3]: unknown host\n");
  249. !                 } elsif (!&equal(($name.'.'),$_[3])) {
  250.                       &printerr(" $_[0] CNAME $_[3]: CNAME (to $name)\n");
  251.                   }
  252.               }
  253. --- 358,364 ----
  254.               else {
  255.                   if (!$name) {
  256.                       &printerr(" $_[0] CNAME $_[3]: unknown host\n");
  257. !                 } elsif (!&equal($name,$_[3])) {
  258.                       &printerr(" $_[0] CNAME $_[3]: CNAME (to $name)\n");
  259.                   }
  260.               }
  261. ***************
  262. *** 384,389 ****
  263. --- 384,397 ----
  264.       # Do case-insensitive string comparisons
  265.       local ($one)= $_[0];
  266.       local ($two)= $_[1];
  267. +     $stripone=$one;
  268. +     if (chop($stripone) eq '.') {
  269. +     $one=$stripone;
  270. +     }
  271. +     $striptwo=$two;
  272. +     if (chop($striptwo) eq '.') {
  273. +     $two=$striptwo;
  274. +     }
  275.       $one =~ tr/A-Z/a-z/;
  276.       $two =~ tr/A-Z/a-z/;
  277.       return ($one eq $two);
  278. ***************
  279. *** 422,428 ****
  280.   sub checklamer {
  281.       local ($isauth)=0;
  282.       local ($error)=0;
  283. !     # must check twice, since first query may be authoratative
  284.       # trap stderr here and print if non-empty
  285.       open(DIG,"dig soa +noaa $_[0] \@$_[1] 2>&1 1>/dev/null |");
  286.       while (<DIG>) {
  287. --- 430,436 ----
  288.   sub checklamer {
  289.       local ($isauth)=0;
  290.       local ($error)=0;
  291. !     # must check twice, since first query may be authoritative
  292.       # trap stderr here and print if non-empty
  293.       open(DIG,"dig soa +noaa $_[0] \@$_[1] 2>&1 1>/dev/null |");
  294.       while (<DIG>) {
  295. ***************
  296. *** 434,439 ****
  297. --- 442,455 ----
  298.       return if $error;
  299.       open(DIG,"dig soa +noaa $_[0] \@$_[1] 2>/dev/null|");
  300.       while (<DIG>) {
  301. +         if (/status: NXDOMAIN/) { 
  302. +             $isauth=0;
  303. +         last;
  304. +         }
  305. +         if (/status: SERVFAIL/) { 
  306. +             $isauth=0;
  307. +         last;
  308. +         }
  309.           if (/;; flags.*aa.*;/) { 
  310.               $isauth=1;
  311.           }
  312.  
  313. exit 0 # Just in case...
  314.