瀏覽代碼

plugins/check_dns.c - Server specified fixes

Previously check_dns was not checking correctly to see if the server you requested was the server responding. This is an adaptation of M-P version, since patching is not an option for this plugin, and we needed some additional changes here.
Spenser Reinhardt 11 年之前
父節點
當前提交
8c248a716b
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      plugins/check_dns.c

+ 18 - 0
plugins/check_dns.c

@@ -148,6 +148,24 @@ main (int argc, char **argv)
     if (verbose)
     if (verbose)
       puts(chld_out.line[i]);
       puts(chld_out.line[i]);
 
 
+    /* bug ID: 2946553 - Older versions of bind will use all available dns
+    + servers, we have to match the one specified */
+    if (strlen(dns_server) > 0 && strstr(chld_out.line[i], "Server:")) {
+        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, "%s%s%s\n", _("DNS CRITICAL - '"), NSLOOKUP_COMMAND, _("' returned empty server string"));
+
+	if (strcmp(temp_buffer, dns_server) != 0)
+            die (STATE_CRITICAL, "%s %s\n", _("No response from DNS"), dns_server);
+    }
+
     if (strstr (chld_out.line[i], "Authoritative answers can be found from:")) {
     if (strstr (chld_out.line[i], "Authoritative answers can be found from:")) {
       non_authoritative = FALSE;
       non_authoritative = FALSE;
       break;
       break;