Bläddra i källkod

Merge branch 'iwhite-nagios-fix_host_name_port'

madlohe 6 år sedan
förälder
incheckning
b454edfe6a
3 ändrade filer med 12 tillägg och 5 borttagningar
  1. 4 0
      NEWS
  2. 8 4
      plugins/check_http.c
  3. 0 1
      plugins/check_ping.c

+ 4 - 0
NEWS

@@ -1,5 +1,9 @@
 This file documents the major additions and syntax changes between releases.
 
+2.3.2 2020-??-??
+	FIXES
+	check_http: Fix host:port syntax when using -H (Isaac White)
+
 2.3.1 2019-12-09
 	FIXES
 	check_icmp: Fixed backward-compatibility issue with performance data (#480)

+ 8 - 4
plugins/check_http.c

@@ -426,13 +426,17 @@ enable_ssl:
             break;
             /* Note: H, I, and u must be malloc'd or will fail on redirects */
         case 'H': /* Host Name (virtual host) */
-            host_name = strdup (optarg);
-            if (host_name[0] == '[') {
-                if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */
+            host_name = strdup(optarg);
+            if (*host_name == '[') {
+                if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */ {
                     server_port = atoi (p + 2);
+                    *++p = '\0'; // Set The host_name sans ":port"
+                }
             } else if ((p = strchr (host_name, ':')) != NULL
-                       && strchr (++p, ':') == NULL) /* IPv4:port or host:port */
+                       && strchr (++p, ':') == NULL) /* IPv4:port or host:port */ {
                 server_port = atoi (p);
+                *--p = '\0'; // Set The host_name sans ":port"
+            }
             break;
         case 'I': /* Server IP-address */
             server_address = strdup (optarg);

+ 0 - 1
plugins/check_ping.c

@@ -139,7 +139,6 @@ main (int argc, char **argv)
 		this_result = run_ping (cmd, addresses[i]);
 
 		if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) {
-			printf ("%s\n", cmd);
 			die (STATE_UNKNOWN,
 			           _("CRITICAL - Could not interpret output from ping command\n"));
 		}