summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2018-10-24 10:13:26 (GMT)
committerSven Nierlein <sven@nierlein.de>2018-10-24 10:13:26 (GMT)
commit87065ac4482c40247e285da27351b72b3019fc87 (patch)
treed8926bde4f016a3d646ff19cee8fed91f2c50500
parentb2f7eca374577b3982e6242376b812c0088ba7ef (diff)
downloadmonitoring-plugins-87065ac.tar.gz
check_curl: handle supplied port correctly
if a port was given by -p, it should not be overruled by the port extracted from -H.
-rw-r--r--plugins/check_curl.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 63c07e3..cbf21ed 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -132,6 +132,7 @@ char *host_name;
132char *server_url = 0; 132char *server_url = 0;
133char server_ip[DEFAULT_BUFFER_SIZE]; 133char server_ip[DEFAULT_BUFFER_SIZE];
134struct curl_slist *server_ips = NULL; 134struct curl_slist *server_ips = NULL;
135int specify_port = FALSE;
135unsigned short server_port = HTTP_PORT; 136unsigned short server_port = HTTP_PORT;
136unsigned short virtual_port = 0; 137unsigned short virtual_port = 0;
137int host_name_length; 138int host_name_length;
@@ -1223,6 +1224,7 @@ process_arguments (int argc, char **argv)
1223 if( strtol(optarg, NULL, 10) > MAX_PORT) 1224 if( strtol(optarg, NULL, 10) > MAX_PORT)
1224 usage2 (_("Invalid port number, supplied port number is too big"), optarg); 1225 usage2 (_("Invalid port number, supplied port number is too big"), optarg);
1225 server_port = (unsigned short)strtol(optarg, NULL, 10); 1226 server_port = (unsigned short)strtol(optarg, NULL, 10);
1227 specify_port = TRUE;
1226 } 1228 }
1227 break; 1229 break;
1228 case 'a': /* authorization info */ 1230 case 'a': /* authorization info */
@@ -1378,7 +1380,7 @@ process_arguments (int argc, char **argv)
1378#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */ 1380#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */
1379 if (verbose >= 2) 1381 if (verbose >= 2)
1380 printf(_("* Set SSL/TLS version to %d\n"), ssl_version); 1382 printf(_("* Set SSL/TLS version to %d\n"), ssl_version);
1381 if (server_port == HTTP_PORT) 1383 if (specify_port == FALSE)
1382 server_port = HTTPS_PORT; 1384 server_port = HTTPS_PORT;
1383 break; 1385 break;
1384#else /* LIBCURL_FEATURE_SSL */ 1386#else /* LIBCURL_FEATURE_SSL */
@@ -1542,9 +1544,9 @@ process_arguments (int argc, char **argv)
1542 if (virtual_port == 0) 1544 if (virtual_port == 0)
1543 virtual_port = server_port; 1545 virtual_port = server_port;
1544 else { 1546 else {
1545 if ((use_ssl && server_port == HTTPS_PORT) || 1547 if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT))
1546 (!use_ssl && server_port == HTTP_PORT)) 1548 if(specify_port == FALSE)
1547 server_port = virtual_port; 1549 server_port = virtual_port;
1548 } 1550 }
1549 1551
1550 return TRUE; 1552 return TRUE;