diff options
author | Sven Nierlein <sven@nierlein.de> | 2018-10-24 12:13:26 +0200 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-24 12:13:26 +0200 |
commit | 87065ac4482c40247e285da27351b72b3019fc87 (patch) | |
tree | d8926bde4f016a3d646ff19cee8fed91f2c50500 /plugins | |
parent | b2f7eca374577b3982e6242376b812c0088ba7ef (diff) | |
download | monitoring-plugins-87065ac4482c40247e285da27351b72b3019fc87.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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_curl.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 63c07e3e..cbf21ed9 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -132,6 +132,7 @@ char *host_name; | |||
132 | char *server_url = 0; | 132 | char *server_url = 0; |
133 | char server_ip[DEFAULT_BUFFER_SIZE]; | 133 | char server_ip[DEFAULT_BUFFER_SIZE]; |
134 | struct curl_slist *server_ips = NULL; | 134 | struct curl_slist *server_ips = NULL; |
135 | int specify_port = FALSE; | ||
135 | unsigned short server_port = HTTP_PORT; | 136 | unsigned short server_port = HTTP_PORT; |
136 | unsigned short virtual_port = 0; | 137 | unsigned short virtual_port = 0; |
137 | int host_name_length; | 138 | int 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; |