[monitoring-plugins] check_curl: handle supplied port correctly
Sven Nierlein
git at monitoring-plugins.org
Wed Oct 24 14:50:16 CEST 2018
Module: monitoring-plugins
Branch: feature_check_curl
Commit: 87065ac4482c40247e285da27351b72b3019fc87
Author: Sven Nierlein <sven at nierlein.de>
Date: Wed Oct 24 12:13:26 2018 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=87065ac
check_curl: handle supplied port correctly
if a port was given by -p, it should not be overruled by the port extracted from -H.
---
plugins/check_curl.c | 10 ++++++----
1 file 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;
char *server_url = 0;
char server_ip[DEFAULT_BUFFER_SIZE];
struct curl_slist *server_ips = NULL;
+int specify_port = FALSE;
unsigned short server_port = HTTP_PORT;
unsigned short virtual_port = 0;
int host_name_length;
@@ -1223,6 +1224,7 @@ process_arguments (int argc, char **argv)
if( strtol(optarg, NULL, 10) > MAX_PORT)
usage2 (_("Invalid port number, supplied port number is too big"), optarg);
server_port = (unsigned short)strtol(optarg, NULL, 10);
+ specify_port = TRUE;
}
break;
case 'a': /* authorization info */
@@ -1378,7 +1380,7 @@ process_arguments (int argc, char **argv)
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */
if (verbose >= 2)
printf(_("* Set SSL/TLS version to %d\n"), ssl_version);
- if (server_port == HTTP_PORT)
+ if (specify_port == FALSE)
server_port = HTTPS_PORT;
break;
#else /* LIBCURL_FEATURE_SSL */
@@ -1542,9 +1544,9 @@ process_arguments (int argc, char **argv)
if (virtual_port == 0)
virtual_port = server_port;
else {
- if ((use_ssl && server_port == HTTPS_PORT) ||
- (!use_ssl && server_port == HTTP_PORT))
- server_port = virtual_port;
+ if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT))
+ if(specify_port == FALSE)
+ server_port = virtual_port;
}
return TRUE;
More information about the Commits
mailing list