summaryrefslogtreecommitdiffstats
path: root/web/attachments/230229-nagios-checkdns.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/230229-nagios-checkdns.patch')
-rw-r--r--web/attachments/230229-nagios-checkdns.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/web/attachments/230229-nagios-checkdns.patch b/web/attachments/230229-nagios-checkdns.patch
new file mode 100644
index 0000000..591cbf8
--- /dev/null
+++ b/web/attachments/230229-nagios-checkdns.patch
@@ -0,0 +1,86 @@
1diff -ru nagios-plugins-HEAD-200705220000/plugins/check_dns.c nagios-plugins/plugins/check_dns.c
2--- nagios-plugins-HEAD-200705220000/plugins/check_dns.c 2007-01-28 22:46:40.000000000 +0100
3+++ nagios-plugins/plugins/check_dns.c 2007-05-23 12:06:06.000000000 +0200
4@@ -62,12 +62,24 @@
5 int expect_authority = FALSE;
6 thresholds *time_thresholds = NULL;
7
8+static int
9+qstrcmp(const void *p1, const void *p2)
10+{
11+ /* The actual arguments to this function are "pointers to
12+ pointers to char", but strcmp() arguments are "pointers
13+ to char", hence the following cast plus dereference */
14+ return strcmp(* (char * const *) p1, * (char * const *) p2);
15+}
16+
17+
18 int
19 main (int argc, char **argv)
20 {
21 char *command_line = NULL;
22 char input_buffer[MAX_INPUT_BUFFER];
23 char *address = NULL;
24+ char **addresses = NULL;
25+ int n_addresses = 0;
26 char *msg = NULL;
27 char *temp_buffer = NULL;
28 int non_authoritative = FALSE;
29@@ -141,16 +153,17 @@
30 NSLOOKUP_COMMAND);
31 }
32
33- if (address == NULL)
34- address = strdup (temp_buffer);
35- else
36- asprintf(&address, "%s,%s", address, temp_buffer);
37+ if (addresses == NULL)
38+ addresses = malloc(sizeof(*addresses)*10);
39+ else if (!(n_addresses % 10))
40+ addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));
41+ addresses[n_addresses++] = strdup(temp_buffer);
42 }
43-
44 else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
45 non_authoritative = TRUE;
46 }
47
48+
49 result = error_scan (chld_out.line[i]);
50 if (result != STATE_OK) {
51 msg = strchr (chld_out.line[i], ':');
52@@ -171,9 +184,21 @@
53 }
54 }
55
56- /* If we got here, we should have an address string,
57- * and we can segfault if we do not */
58- if (address==NULL || strlen(address)==0)
59+ if (addresses) {
60+ int i,slen;
61+ char *adrp;
62+ qsort(addresses, n_addresses, sizeof(*addresses), qstrcmp);
63+ for(i=0, slen=1; i < n_addresses; i++) {
64+ slen += strlen(addresses[i])+1;
65+ }
66+ adrp = address = malloc(slen);
67+ for(i=0; i < n_addresses; i++) {
68+ if (i) *adrp++ = ',';
69+ strcpy(adrp, addresses[i]);
70+ adrp += strlen(addresses[i]);
71+ }
72+ *adrp = 0;
73+ } else
74 die (STATE_CRITICAL,
75 _("DNS CRITICAL - '%s' msg parsing exited with no address\n"),
76 NSLOOKUP_COMMAND);
77@@ -428,7 +453,8 @@
78 printf (" -s, --server=HOST\n");
79 printf (" %s\n", _("Optional DNS server you want to use for the lookup"));
80 printf (" -a, --expected-address=IP-ADDRESS|HOST\n");
81- printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with ."));
82+ printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with .\n\
83+Multiple addresses can be separated with commas, and need to be sorted."));
84 printf (" -A, --expect-authority\n");
85 printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
86 printf (" -w, --warning=seconds\n");