aa46a8
Handle DNSSEC messages in named.
aa46a8
aa46a8
Author: Frank Crawford <frank@crawford.emu.id.au>
aa46a8
RH-Bugzilla: #666394
aa46a8
aa46a8
diff -up logwatch-svn46/scripts/services/named.dnssec logwatch-svn46/scripts/services/named
aa46a8
--- logwatch-svn46/scripts/services/named.dnssec	2011-03-28 13:54:24.212725223 +0200
aa46a8
+++ logwatch-svn46/scripts/services/named	2011-03-28 14:08:21.044509429 +0200
aa46a8
@@ -228,6 +228,7 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
       ($ThisLine =~ /too many timeouts resolving '.*' .*: disabling EDNS/) or
aa46a8
       ($ThisLine =~ /too many timeouts resolving '.*' .*: reducing the advertised EDNS UDP packet size to .* octets/) or
aa46a8
       ($ThisLine =~ /reloading zones succeeded/) or
aa46a8
+      ($ThisLine =~ /generating session key/) or
aa46a8
       ($ThisLine =~ /success resolving '.*' \(in '.*'?\) after disabling EDNS/) or
aa46a8
       ($ThisLine =~ /success resolving '.*' \(in '.*'?\) after reducing the advertised EDNS UDP packet size to 512 octets/) or
aa46a8
       ($ThisLine =~ /the working directory is not writable/) or
aa46a8
@@ -250,6 +250,11 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
       ($ThisLine =~ /refresh in progress, refresh check queued/) or
aa46a8
       ($ThisLine =~ /refresh: NODATA response from master/) or
aa46a8
       ($ThisLine =~ /update with no effect/) or
aa46a8
+      ($ThisLine =~ /reading built-in trusted keys from file/) or
aa46a8
+      ($ThisLine =~ /using built-in trusted-keys/) or
aa46a8
+      ($ThisLine =~ /set up managed keys zone/) or
aa46a8
+      # the following seems okay since it says "success"
aa46a8
+      ($ThisLine =~ /managed-keys-zone .*: No DNSKEY RRSIGs found for '.*': success/) or
aa46a8
       ($ThisLine =~ /validating \@0x[[:xdigit:]]+: .* no valid signature found/) or
aa46a8
       # ignore this line because the following line describes the error
aa46a8
       ($ThisLine =~ /unexpected error/)
aa46a8
@@ -269,7 +275,8 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
       $ShutdownNamed++;
aa46a8
    } elsif ( $ThisLine =~ /named shutdown failed/ ) {
aa46a8
       $ShutdownNamedFail++;
aa46a8
-   } elsif ( ($Host, $Zone) = ( $ThisLine =~ /client ([^\#]+)#[^\:]+: zone transfer '(.+)' denied/ ) ) {
aa46a8
+   } elsif ( (($Host, $Zone) = ( $ThisLine =~ /client ([^\#]+)#[^\:]+: (?:view \w+: )?zone transfer '(.+)' denied/ )) or
aa46a8
+             (($Host, $Zone) = ( $ThisLine =~ /client ([^\#]+)#[^\:]+: (?:view \w+: )?bad zone transfer request: '(.+)':/ )) ) {
aa46a8
       $DeniedZoneTransfers{$Host}{$Zone}++;
aa46a8
    } elsif ( ($Zone) = ( $ThisLine =~ /zone (.+) zone transfer deferred due to quota/ ) ) {
aa46a8
       $DeferredZoneTransfers{$Zone}++;
aa46a8
@@ -291,14 +298,13 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
       $ZoneLoaded{$Zone}++;
aa46a8
    } elsif ( (undef,$Addr,undef,$Server) = ( $ThisLine =~ /ame server (on|resolving) '(.+)' \(in .+\):\s+(\[.+\]\.\d+)?\s*'?(.+)'?:?/ ) ) {
aa46a8
       $LameServer{"$Addr ($Server)"}++;
aa46a8
-   } elsif ( ($Zone) = ( $ThisLine =~ /Zone \"(.+)\" was removed/ ) ) {
aa46a8
+   } elsif ( (($Zone) = ( $ThisLine =~ /Zone \"(.+)\" was removed/ )) or
aa46a8
+             (($Zone) = ( $ThisLine =~ /zone (.+): \(.*\) removed/ )) ) {
aa46a8
       $ZoneRemoved{$Zone}++;
aa46a8
    } elsif ( ($Zone) = ( $ThisLine =~ /received notify for zone '(.*)'/ ) ) {
aa46a8
       $ZoneReceivedNotify{$Zone}++;
aa46a8
    } elsif ( ($Zone) = ( $ThisLine =~ /zone (.*): notify from .* up to date/ ) ) {
aa46a8
       $ZoneReceivedNotify{$Zone}++;
aa46a8
-   } elsif ( ($Zone) = ( $ThisLine =~ /zone (.*): notify from .* up to date/ ) ) {
aa46a8
-      $ZoneReceivedNotify{$Zone}++;
aa46a8
    } elsif ( ($Zone) = ( $ThisLine =~ /zone (.+)\/IN: refused notify from non-master/ ) ) {
aa46a8
       $ZoneRefusedNotify{$Zone}++;
aa46a8
 #   } elsif ( ($Rhost,$Ldom,$Reason) = ( $ThisLine =~ /client ([\d\.a-fA-F:]+) bad zone transfer request: '(.+)': (.+)$/ ) ) {
aa46a8
@@ -321,13 +327,13 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
    } elsif ( ($Client) = ( $ThisLine =~ /warning: client (.*) no more TCP clients/ ) ) {
aa46a8
       $FullClient = LookupIP ($Client);
aa46a8
       $DeniedTCPClient{$FullClient}++;
aa46a8
-   } elsif ( ($Client) = ( $ThisLine =~ /client (.*)#\d+: query \(cache\) denied/ ) ) {
aa46a8
+   } elsif ( ($Client) = ( $ThisLine =~ /client (.*)#\d+: (?:view \w+: )?query \(cache\) denied/ ) ) {
aa46a8
       $FullClient = LookupIP ($Client);
aa46a8
       $DeniedQuery{$FullClient}++;
aa46a8
    } elsif ( ($Client) = ( $ThisLine =~ /client (.*)#\d+: query '.*\/IN' denied/ ) ) {
aa46a8
       $FullClient = LookupIP ($Client);
aa46a8
       $DeniedQueryNoCache{$FullClient}++;
aa46a8
-   } elsif ( ($Rhost, $ViewName, $Ldom) = ($ThisLine =~ /client ([\.0-9a-fA-F:]+)#\d+:(?: view ([^ ]+):)? update '(.*)' denied/)) {
aa46a8
+   } elsif ( ($Rhost, $ViewName, $Ldom) = ($ThisLine =~ /client ([\.0-9a-fA-F:]+)#\d+: (?:view \w+: )?update '(.*)' denied/)) {
aa46a8
       $ViewName = ($ViewName ? "/$ViewName" : "");
aa46a8
       $UpdateDenied{"$Rhost ($Ldom$ViewName)"}++;
aa46a8
    } elsif ( ($Rhost, $Ldom) = ($ThisLine =~ /client ([\d\.]+)#\d+: update forwarding '(.*)' denied/)) {
aa46a8
@@ -384,6 +390,18 @@ while (defined($ThisLine = <STDIN>)) {
aa46a8
       $NoSOA{$Client}++;
aa46a8
    } elsif (($Hint) = ($ThisLine =~ /checkhints: (.*)/) ) {
aa46a8
       $Hints{$Hint}++;
aa46a8
+   } elsif (($Zone,$RR) = ($ThisLine =~ /^\s*validating \@0x[[:xdigit:]]+: (.*) (\w+): got insecure response; parent indicates it should be secure/)) {
aa46a8
+      $DNSSECInsec{'__Total__'}++;
aa46a8
+      $DNSSECInsec{$Zone}{$RR}++;
aa46a8
+   } elsif (($Zone,$RR) = ($ThisLine =~ /^\s*validating \@0x[[:xdigit:]]+: (.*) (\w+): no valid signature found/)) {
aa46a8
+      $DNSSECInvalid{'__Total__'}++;
aa46a8
+      $DNSSECInvalid{$Zone}{$RR}++;
aa46a8
+   } elsif (($Zone,$RR) = ($ThisLine =~ /^\s*validating \@0x[[:xdigit:]]+: (.*) (\w+): bad cache hit/)) {
aa46a8
+      $DNSSECBadCache{'__Total__'}++;
aa46a8
+      $DNSSECBadCache{$Zone}{$RR}++;
aa46a8
+   } elsif (($Error,$Host) = ($ThisLine =~ /error \((.*)\) resolving '([^']+)':/)) {
aa46a8
+      $DNSSECError{$Error}{'__Total__'}++;
aa46a8
+      $DNSSECError{$Error}{$Host}++;
aa46a8
    } else {
aa46a8
       # Report any unmatched entries...
aa46a8
       # remove PID from named messages
aa46a8
@@ -713,6 +731,51 @@ if (keys %Hints) {
aa46a8
    }
aa46a8
 }
aa46a8
 
aa46a8
+if (($Detail >= 5) and (keys %DNSSECInsec)) {
aa46a8
+   print "\n DNSSEC Insecure Responses: " . $DNSSECInsec{'__Total__'} . " Time(s)\n";
aa46a8
+   foreach $Zone (sort keys %DNSSECInsec) {
aa46a8
+      if (($Detail >= 10) and ($Zone =~ /.+/) and ($Zone ne '__Total__')) {
aa46a8
+        foreach $RR (sort keys %{$DNSSECInsec{$Zone}}) {
aa46a8
+           print "   " . "$Zone/$RR: " . $DNSSECInsec{$Zone}{$RR} . " Time(s)\n";
aa46a8
+        }
aa46a8
+      }
aa46a8
+   }
aa46a8
+}
aa46a8
+
aa46a8
+if (($Detail >= 5) and (keys %DNSSECInvalid)) {
aa46a8
+   print "\n DNSSEC No Valid Signature: " . $DNSSECInvalid{'__Total__'} . " Time(s)\n";
aa46a8
+   foreach $Zone (sort keys %DNSSECInvalid) {
aa46a8
+      if (($Detail >= 10) and ($Zone =~ /.+/) and ($Zone ne '__Total__')) {
aa46a8
+        foreach $RR (sort keys %{$DNSSECInvalid{$Zone}}) {
aa46a8
+           print "   " . "$Zone/$RR: " . $DNSSECInvalid{$Zone}{$RR} . " Time(s)\n";
aa46a8
+        }
aa46a8
+      }
aa46a8
+   }
aa46a8
+}
aa46a8
+
aa46a8
+if (($Detail >= 5) and (keys %DNSSECBadCache)) {
aa46a8
+   print "\n DNSSEC Bad Cache hit: " . $DNSSECBadCache{'__Total__'} . " Time(s)\n";
aa46a8
+   foreach $Zone (sort keys %DNSSECBadCache) {
aa46a8
+      if (($Detail >= 10) and ($Zone =~ /.+/) and ($Zone ne '__Total__')) {
aa46a8
+        foreach $RR (sort keys %{$DNSSECBadCache{$Zone}}) {
aa46a8
+           print "   " . "$Zone/$RR: " . $DNSSECBadCache{$Zone}{$RR} . " Time(s)\n";
aa46a8
+        }
aa46a8
+      }
aa46a8
+   }
aa46a8
+}
aa46a8
+
aa46a8
+if (($Detail >= 5) and (keys %DNSSECError)) {
aa46a8
+   print "\n DNS Errors:\n";
aa46a8
+   foreach $Error (sort keys %DNSSECError) {
aa46a8
+      print "   $Error: " . $DNSSECError{$Error}{'__Total__'} . " Time(s)\n";
aa46a8
+      if ($Detail >= 10) {
aa46a8
+         foreach $Host (sort keys %{$DNSSECError{$Error}}) {
aa46a8
+            print "     " . "$Host: " . $DNSSECError{$Error}{$Host} . " Time(s)\n" unless ($Host eq '__Total__');
aa46a8
+         }
aa46a8
+      }
aa46a8
+   }
aa46a8
+}
aa46a8
+
aa46a8
 if (keys %OtherList) {
aa46a8
    print "\n**Unmatched Entries**\n";
aa46a8
    foreach $line (sort {$a cmp $b} keys %OtherList) {