diff options
Diffstat (limited to 'web/attachments/85410-check_dig.c.patch')
-rw-r--r-- | web/attachments/85410-check_dig.c.patch | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/web/attachments/85410-check_dig.c.patch b/web/attachments/85410-check_dig.c.patch new file mode 100644 index 0000000..b4fedc2 --- /dev/null +++ b/web/attachments/85410-check_dig.c.patch | |||
@@ -0,0 +1,151 @@ | |||
1 | --- check_dig.c.orig Thu Apr 15 12:38:19 2004 | ||
2 | +++ check_dig.c Fri Apr 16 16:20:03 2004 | ||
3 | @@ -37,6 +37,8 @@ | ||
4 | }; | ||
5 | |||
6 | char *query_address = NULL; | ||
7 | +char *record_type = "A"; | ||
8 | +char *expected_address = NULL; | ||
9 | char *dns_server = NULL; | ||
10 | int verbose = FALSE; | ||
11 | int server_port = DEFAULT_PORT; | ||
12 | @@ -68,14 +70,20 @@ | ||
13 | usage (_("Could not parse arguments\n")); | ||
14 | |||
15 | /* get the command to run */ | ||
16 | - asprintf (&command_line, "%s @%s -p %d %s", | ||
17 | - PATH_TO_DIG, dns_server, server_port, query_address); | ||
18 | + asprintf (&command_line, "%s @%s -p %d %s -t %s", | ||
19 | + PATH_TO_DIG, dns_server, server_port, query_address, record_type); | ||
20 | |||
21 | alarm (timeout_interval); | ||
22 | gettimeofday (&tv, NULL); | ||
23 | |||
24 | - if (verbose) | ||
25 | + if (verbose) { | ||
26 | printf ("%s\n", command_line); | ||
27 | + if(expected_address != NULL) { | ||
28 | + printf ("Looking for: '%s'\n", expected_address); | ||
29 | + } else { | ||
30 | + printf ("Looking for: '%s'\n", query_address); | ||
31 | + } | ||
32 | + } | ||
33 | |||
34 | /* run the command */ | ||
35 | child_process = spopen (command_line); | ||
36 | @@ -93,28 +101,39 @@ | ||
37 | /* the server is responding, we just got the host name... */ | ||
38 | if (strstr (input_buffer, ";; ANSWER SECTION:")) { | ||
39 | |||
40 | - /* get the host address */ | ||
41 | - if (!fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) | ||
42 | - break; | ||
43 | - | ||
44 | - if (strpbrk (input_buffer, "\r\n")) | ||
45 | - input_buffer[strcspn (input_buffer, "\r\n")] = '\0'; | ||
46 | - | ||
47 | - if (strstr (input_buffer, query_address) == input_buffer) { | ||
48 | - output = strdup(input_buffer); | ||
49 | - result = STATE_OK; | ||
50 | - } | ||
51 | - else { | ||
52 | - asprintf (&output, _("Server not found in ANSWER SECTION")); | ||
53 | - result = STATE_WARNING; | ||
54 | - } | ||
55 | + /* loop through the whole 'ANSWER SECTION' */ | ||
56 | + do { | ||
57 | + /* get the host address */ | ||
58 | + if (!fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) | ||
59 | + break; | ||
60 | + | ||
61 | + if (strpbrk (input_buffer, "\r\n")) | ||
62 | + input_buffer[strcspn (input_buffer, "\r\n")] = '\0'; | ||
63 | + | ||
64 | + if (verbose && !strstr (input_buffer, ";; ")) | ||
65 | + printf ("%s\n", input_buffer); | ||
66 | + | ||
67 | + if (expected_address==NULL && strstr (input_buffer, query_address) != NULL) { | ||
68 | + output = strdup(input_buffer); | ||
69 | + result = STATE_OK; | ||
70 | + } | ||
71 | + else if (expected_address != NULL && strstr (input_buffer, expected_address) != NULL) { | ||
72 | + output = strdup(input_buffer); | ||
73 | + result = STATE_OK; | ||
74 | + } | ||
75 | + | ||
76 | + } while (!strstr (input_buffer, ";; ")); | ||
77 | + | ||
78 | + if (result == STATE_UNKNOWN) { | ||
79 | + asprintf (&output, _("Server not found in ANSWER SECTION")); | ||
80 | + result = STATE_WARNING; | ||
81 | + } | ||
82 | |||
83 | - continue; | ||
84 | } | ||
85 | |||
86 | } | ||
87 | |||
88 | - if (result != STATE_OK) { | ||
89 | + if (result == STATE_UNKNOWN) { | ||
90 | asprintf (&output, _("No ANSWER SECTION found")); | ||
91 | } | ||
92 | |||
93 | @@ -181,6 +200,8 @@ | ||
94 | {"verbose", no_argument, 0, 'v'}, | ||
95 | {"version", no_argument, 0, 'V'}, | ||
96 | {"help", no_argument, 0, 'h'}, | ||
97 | + {"record_type", required_argument, 0, 'T'}, | ||
98 | + {"expected_address", required_argument, 0, 'a'}, | ||
99 | {0, 0, 0, 0} | ||
100 | }; | ||
101 | |||
102 | @@ -188,7 +209,7 @@ | ||
103 | return ERROR; | ||
104 | |||
105 | while (1) { | ||
106 | - c = getopt_long (argc, argv, "hVvt:l:H:w:c:", longopts, &option); | ||
107 | + c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:a:", longopts, &option); | ||
108 | |||
109 | if (c == -1 || c == EOF) | ||
110 | break; | ||
111 | @@ -248,6 +269,12 @@ | ||
112 | case 'v': /* verbose */ | ||
113 | verbose = TRUE; | ||
114 | break; | ||
115 | + case 'T': | ||
116 | + record_type = optarg; | ||
117 | + break; | ||
118 | + case 'a': | ||
119 | + expected_address = optarg; | ||
120 | + break; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | @@ -309,6 +336,15 @@ | ||
125 | -l, --lookup=STRING\n\ | ||
126 | machine name to lookup\n")); | ||
127 | |||
128 | + printf (_("\ | ||
129 | + -T, --record_type=STRING\n\ | ||
130 | + record type to lookup (default: A)\n")); | ||
131 | + | ||
132 | + printf (_("\ | ||
133 | + -a, --expected_address=STRING\n\ | ||
134 | + an address expected to be in the asnwer section.\n\ | ||
135 | + if not set, uses whatever was in -l\n")); | ||
136 | + | ||
137 | printf (_(UT_WARN_CRIT)); | ||
138 | |||
139 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
140 | @@ -325,8 +361,9 @@ | ||
141 | print_usage (void) | ||
142 | { | ||
143 | printf (_("\ | ||
144 | -Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\ | ||
145 | - [-c <critical interval>] [-t <timeout>] [-v]\n"), | ||
146 | +Usage: %s -H host -l lookup [-p <server port>] [-T <query type>]\n\ | ||
147 | + [-w <warning interval>] [-c <critical interval>] [-t <timeout>]\n\ | ||
148 | + [-a <expected answer address>] [-v]\n"), | ||
149 | progname); | ||
150 | printf (" %s (-h|--help)\n", progname); | ||
151 | printf (" %s (-V|--version)\n", progname); | ||