[Nagiosplug-devel] check_dns fixes

Ollie Cook ollie at uk.clara.net
Thu Dec 9 05:32:01 CET 2004


Hi,

The check_dns plugin from 1.4.0alpha2 crashes (segmentation violation) if the
standard output is not recognised *and* there is no recognised error on
standard error.

The crash is an attempt to reference 'output' which is NULL.

I've attached a patch which covers two new errors:

  Query refused:  usually caused by an ACL in the nameserver configuration
  No information: I've seen this when the primary IP of the nameserver being
                  queried has two PTR records.

I've modified the check which it seems was supposed to detect the case of not
recognising and output either on stdout or stderr.

I've also caused stderr lines to be written when in verbose mode, as for
stdout.

Cheers,

Ollie

-- 
Ollie Cook         Systems Architect, Claranet UK
ollie at uk.clara.net               +44 20 7685 8065
-------------- next part --------------
--- check_dns.c.orig	Thu Dec  9 13:01:30 2004
+++ check_dns.c	Thu Dec  9 12:55:43 2004
@@ -150,6 +150,10 @@
 
 	/* scan stderr */
 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
+
+		if (verbose)
+			printf ("%s", input_buffer);
+
 		if (error_scan (input_buffer) != STATE_OK) {
 			result = max_state (result, error_scan (input_buffer));
 			output = strdup (1 + index (input_buffer, ':'));
@@ -163,7 +167,7 @@
 	/* close stdout */
 	if (spclose (child_process)) {
 		result = max_state (result, STATE_WARNING);
-		if (!strcmp (output, ""))
+		if (output == NULL || !strcmp (output, ""))
 			output = strdup (_("nslookup returned error status"));
 	}
 
@@ -237,6 +241,14 @@
 	         (strstr (input_buffer, "** server can't find") &&
 	          strstr (input_buffer, ": REFUSED")))
 		die (STATE_CRITICAL, _("Connection to DNS %s was refused\n"), dns_server);
+
+	/* Query refused (usually by an ACL in the namserver) 
+	else if (strstr (input_buffer, "Query refused"))
+		die (STATE_CRITICAL, _("Query was refused by DNS server at %s\n"), dns_server); */
+
+	/* No information (e.g. nameserver IP has two PTR records) */
+	else if (strstr (input_buffer, "No information"))
+		die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
 
 	/* Host or domain name does not exist */
 	else if (strstr (input_buffer, "Non-existent") ||


More information about the Devel mailing list