diff options
Diffstat (limited to 'web/attachments/32558-check_dns.c.patch')
-rw-r--r-- | web/attachments/32558-check_dns.c.patch | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/web/attachments/32558-check_dns.c.patch b/web/attachments/32558-check_dns.c.patch new file mode 100644 index 0000000..3a03290 --- /dev/null +++ b/web/attachments/32558-check_dns.c.patch | |||
@@ -0,0 +1,104 @@ | |||
1 | Index: plugins/check_dns.c | ||
2 | =================================================================== | ||
3 | RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v | ||
4 | retrieving revision 1.2 | ||
5 | diff -u -b -r1.2 check_dns.c | ||
6 | --- plugins/check_dns.c 19 Jun 2002 05:11:52 -0000 1.2 | ||
7 | +++ plugins/check_dns.c 7 Oct 2002 17:33:58 -0000 | ||
8 | @@ -10,8 +10,9 @@ | ||
9 | * | ||
10 | * Notes: | ||
11 | * - Safe popen added by Karl DeBisschop 9-11-99 | ||
12 | + * - expected-address parameter added by Alex Chaffee - 7 Oct 2002 | ||
13 | * | ||
14 | - * Command line: CHECK_DNS <query_address> [dns_server] | ||
15 | + * Command line: (see print_usage) | ||
16 | * | ||
17 | * Description: | ||
18 | * | ||
19 | @@ -59,6 +60,8 @@ | ||
20 | char dns_server[ADDRESS_LENGTH] = ""; | ||
21 | char ptr_server[ADDRESS_LENGTH] = ""; | ||
22 | int verbose = FALSE; | ||
23 | +char expected_address[ADDRESS_LENGTH] = ""; | ||
24 | +int match_expected_address = FALSE; | ||
25 | |||
26 | int | ||
27 | main (int argc, char **argv) | ||
28 | @@ -165,6 +168,12 @@ | ||
29 | output = strscpy (output, "nslookup returned error status"); | ||
30 | } | ||
31 | |||
32 | + /* compare to expected address */ | ||
33 | + if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) { | ||
34 | + result = STATE_CRITICAL; | ||
35 | + output = ssprintf(output, "expected %s but got %s", expected_address, address); | ||
36 | + } | ||
37 | + | ||
38 | (void) time (&end_time); | ||
39 | |||
40 | if (result == STATE_OK) | ||
41 | @@ -297,6 +306,7 @@ | ||
42 | {"hostname", required_argument, 0, 'H'}, | ||
43 | {"server", required_argument, 0, 's'}, | ||
44 | {"reverse-server", required_argument, 0, 'r'}, | ||
45 | + {"expected-address", required_argument, 0, 'a'}, | ||
46 | {0, 0, 0, 0} | ||
47 | }; | ||
48 | #endif | ||
49 | @@ -304,9 +314,9 @@ | ||
50 | |||
51 | while (1) { | ||
52 | #ifdef HAVE_GETOPT_H | ||
53 | - c = getopt_long (argc, argv, "+?hVvt:H:s:r:", long_opts, &opt_index); | ||
54 | + c = getopt_long (argc, argv, "+?hVvt:H:s:r:a:", long_opts, &opt_index); | ||
55 | #else | ||
56 | - c = getopt (argc, argv, "+?hVvt:H:s:r:"); | ||
57 | + c = getopt (argc, argv, "+?hVvt:H:s:r:a:"); | ||
58 | #endif | ||
59 | |||
60 | if (c == -1 || c == EOF) | ||
61 | @@ -318,6 +328,7 @@ | ||
62 | case 'H': | ||
63 | case 's': | ||
64 | case 'r': | ||
65 | + case 'a': | ||
66 | i++; | ||
67 | } | ||
68 | |||
69 | @@ -368,6 +379,17 @@ | ||
70 | terminate (STATE_UNKNOWN, "Input buffer overflow\n"); | ||
71 | strcpy (ptr_server, optarg); | ||
72 | break; | ||
73 | + case 'a': /* expected address */ | ||
74 | + if (is_host (optarg) == FALSE) { | ||
75 | + printf ("Invalid expected address\n\n"); | ||
76 | + print_usage (my_basename (argv[0])); | ||
77 | + exit (STATE_UNKNOWN); | ||
78 | + } | ||
79 | + if (strlen (optarg) >= ADDRESS_LENGTH) | ||
80 | + terminate (STATE_UNKNOWN, "Input buffer overflow\n"); | ||
81 | + strcpy (expected_address, optarg); | ||
82 | + match_expected_address = TRUE; | ||
83 | + break; | ||
84 | } | ||
85 | } | ||
86 | return i; | ||
87 | @@ -385,7 +407,7 @@ | ||
88 | void | ||
89 | print_usage (char *cmd) | ||
90 | { | ||
91 | - printf ("Usage: %s -H host [-s server] [-t timeout]\n" " %s --help\n" | ||
92 | + printf ("Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n" " %s --help\n" | ||
93 | " %s --version\n", cmd, cmd, cmd); | ||
94 | } | ||
95 | |||
96 | @@ -401,6 +423,8 @@ | ||
97 | " The name or address you want to query\n" | ||
98 | "-s, --server=HOST\n" | ||
99 | " Optional DNS server you want to use for the lookup\n" | ||
100 | + "-a, --expected-address=IP-ADDRESS\n" | ||
101 | + " Optional IP address you expect the DNS server to return\n" | ||
102 | "-t, --timeout=INTEGER\n" | ||
103 | " Seconds before connection times out (default: %d)\n" | ||
104 | "-h, --help\n" | ||