summaryrefslogtreecommitdiffstats
path: root/web/attachments/429681-check_http.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/429681-check_http.patch')
-rw-r--r--web/attachments/429681-check_http.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/web/attachments/429681-check_http.patch b/web/attachments/429681-check_http.patch
new file mode 100644
index 0000000..ae9d48a
--- /dev/null
+++ b/web/attachments/429681-check_http.patch
@@ -0,0 +1,80 @@
1--- nagios-plugins-1.4.15/plugins/check_http.c 2011-11-28 16:35:25.000000000 +0000
2+++ nagios-plugins-1.4.15.new/plugins/check_http.c 2011-11-28 13:26:56.000000000 +0000
3@@ -90,10 +90,12 @@
4
5 int specify_port = FALSE;
6 int server_port = HTTP_PORT;
7+int virtual_port = 0;
8 char server_port_text[6] = "";
9 char server_type[6] = "http";
10 char *server_address;
11 char *host_name;
12+int host_name_length;
13 char *server_url;
14 char *user_agent;
15 int server_url_length;
16@@ -334,11 +336,25 @@
17 case 'H': /* Host Name (virtual host) */
18 host_name = strdup (optarg);
19 if (host_name[0] == '[') {
20- if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */
21- server_port = atoi (p + 2);
22+ if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */
23+ virtual_port = atoi (p + 2);
24+ /* cut off the port */
25+ host_name_length = strlen (host_name) - strlen (p) - 1;
26+ free (host_name);
27+ host_name = strndup (optarg, host_name_length);
28+ if (specify_port == FALSE)
29+ server_port = virtual_port;
30+ }
31 } else if ((p = strchr (host_name, ':')) != NULL
32- && strchr (++p, ':') == NULL) /* IPv4:port or host:port */
33- server_port = atoi (p);
34+ && strchr (++p, ':') == NULL) { /* IPv4:port or host:port */
35+ virtual_port = atoi (p);
36+ /* cut off the port */
37+ host_name_length = strlen (host_name) - strlen (p) - 1;
38+ free (host_name);
39+ host_name = strndup (optarg, host_name_length);
40+ if (specify_port == FALSE)
41+ server_port = virtual_port;
42+ }
43 break;
44 case 'I': /* Server IP-address */
45 server_address = strdup (optarg);
46@@ -484,6 +500,9 @@
47 if (http_method == NULL)
48 http_method = strdup ("GET");
49
50+ if (virtual_port == 0)
51+ virtual_port = server_port;
52+
53 return TRUE;
54 }
55
56@@ -829,11 +848,11 @@
57 * 14.23). Some server applications/configurations cause trouble if the
58 * (default) port is explicitly specified in the "Host:" header line.
59 */
60- if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
61- (use_ssl == TRUE && server_port == HTTPS_PORT))
62+ if ((use_ssl == FALSE && virtual_port == HTTP_PORT) ||
63+ (use_ssl == TRUE && virtual_port == HTTPS_PORT))
64 asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
65 else
66- asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
67+ asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
68 }
69
70 /* optionally send any other header tag */
71@@ -1255,6 +1274,9 @@
72 MAX_PORT, server_type, server_address, server_port, server_url,
73 display_html ? "</A>" : "");
74
75+ /* reset virtual port */
76+ virtual_port = server_port;
77+
78 if (verbose)
79 printf (_("Redirection to %s://%s:%d%s\n"), server_type,
80 host_name ? host_name : server_address, server_port, server_url);