From d0da78ced184197b29af9fe910aaf56a9e7fe762 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Sun, 29 Sep 2013 02:23:11 +0200 Subject: check_dns: returns incorrect state when specifying server This patch verifies if the response is returned by the dns server we are trying to check --- Closes #981 Closes #982 Closes #1164 diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 31a953d..da90da7 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -136,6 +136,28 @@ main (int argc, char **argv) } } + /* bug ID: 2946553 - Older versions of bind will use all available dns + servers, we have to match the one specified */ + if (strstr (chld_out.line[i], "Server:") && strlen(dns_server) > 0) { + temp_buffer = index (chld_out.line[i], ':'); + temp_buffer++; + + /* Strip leading tabs */ + for (; *temp_buffer != '\0' && *temp_buffer == '\t'; temp_buffer++) + /* NOOP */; + + strip(temp_buffer); + if (temp_buffer==NULL || strlen(temp_buffer)==0) { + die (STATE_CRITICAL, + _("DNS CRITICAL - '%s' returned empty server string\n"), + NSLOOKUP_COMMAND); + } + + if (strcmp(temp_buffer, dns_server) != 0) { + die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server); + } + } + /* the server is responding, we just got the host name... */ if (strstr (chld_out.line[i], "Name:")) parse_address = TRUE; -- cgit v0.10-9-g596f From b7ce241ba66298e06004236936e9915108876144 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Wed, 30 Jul 2014 23:29:28 +0200 Subject: check_dns: Use strchr instead of index diff --git a/plugins/check_dns.c b/plugins/check_dns.c index da90da7..d7f7346 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -139,7 +139,7 @@ main (int argc, char **argv) /* bug ID: 2946553 - Older versions of bind will use all available dns servers, we have to match the one specified */ if (strstr (chld_out.line[i], "Server:") && strlen(dns_server) > 0) { - temp_buffer = index (chld_out.line[i], ':'); + temp_buffer = strchr (chld_out.line[i], ':'); temp_buffer++; /* Strip leading tabs */ -- cgit v0.10-9-g596f From 3b640c32b95053acb998a2a2493359f6d0522d74 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Mon, 30 Sep 2013 18:14:06 +0200 Subject: adding to THANKS diff --git a/THANKS.in b/THANKS.in index b6dc294..9fd8ebf 100644 --- a/THANKS.in +++ b/THANKS.in @@ -326,3 +326,4 @@ Mikael Falkvidd Patric Wust Julius Kriukas Patrick McAndrew +Matthew Kent -- cgit v0.10-9-g596f