diff options
| author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-04-19 18:58:56 +0000 |
|---|---|---|
| committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-04-19 18:58:56 +0000 |
| commit | 37fdf17820628b12e400d82c4f437b9d49f8eb3d (patch) | |
| tree | 6a033ed222783870070bd2ca983fa72951adc9a2 | |
| parent | e67ac139fcf337fdc866676fed567236d7d35434 (diff) | |
| download | monitoring-plugins-37fdf17.tar.gz | |
small fixes and cleanups around SSL, be more tolerant to -S<x> options
| -rw-r--r-- | plugins/check_curl.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 5aee165b..f7c7596e 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
| @@ -43,7 +43,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 43 | #include "utils.h" | 43 | #include "utils.h" |
| 44 | 44 | ||
| 45 | #ifndef LIBCURL_PROTOCOL_HTTP | 45 | #ifndef LIBCURL_PROTOCOL_HTTP |
| 46 | #error libcurl compiled without HTTP support, compiling check_curl plugin makes not much sense | 46 | #error libcurl compiled without HTTP support, compiling check_curl plugin does not makes a lot of sense |
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | #include "curl/curl.h" | 49 | #include "curl/curl.h" |
| @@ -739,6 +739,7 @@ process_arguments (int argc, char **argv) | |||
| 739 | }; | 739 | }; |
| 740 | 740 | ||
| 741 | int option = 0; | 741 | int option = 0; |
| 742 | int got_plus = 0; | ||
| 742 | static struct option longopts[] = { | 743 | static struct option longopts[] = { |
| 743 | STD_LONG_OPTS, | 744 | STD_LONG_OPTS, |
| 744 | {"link", no_argument, 0, 'L'}, | 745 | {"link", no_argument, 0, 'L'}, |
| @@ -933,7 +934,6 @@ process_arguments (int argc, char **argv) | |||
| 933 | * parameters, like -S and -C combinations */ | 934 | * parameters, like -S and -C combinations */ |
| 934 | ssl_version = CURL_SSLVERSION_TLSv1_0; | 935 | ssl_version = CURL_SSLVERSION_TLSv1_0; |
| 935 | if (c=='S' && optarg != NULL) { | 936 | if (c=='S' && optarg != NULL) { |
| 936 | int got_plus = 0; | ||
| 937 | char *plus_ptr = strchr(optarg, '+'); | 937 | char *plus_ptr = strchr(optarg, '+'); |
| 938 | if (plus_ptr) { | 938 | if (plus_ptr) { |
| 939 | got_plus = 1; | 939 | got_plus = 1; |
| @@ -948,27 +948,26 @@ process_arguments (int argc, char **argv) | |||
| 948 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) | 948 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) |
| 949 | ssl_version = CURL_SSLVERSION_TLSv1_0; | 949 | ssl_version = CURL_SSLVERSION_TLSv1_0; |
| 950 | #else | 950 | #else |
| 951 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3")); | 951 | ssl_version = CURL_SSLVERSION_DEFAULT; |
| 952 | #endif | 952 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */ |
| 953 | else if (!strcmp (optarg, "1.1")) | 953 | else if (!strcmp (optarg, "1.1")) |
| 954 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) | 954 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) |
| 955 | ssl_version = CURL_SSLVERSION_TLSv1_1; | 955 | ssl_version = CURL_SSLVERSION_TLSv1_1; |
| 956 | #else | 956 | #else |
| 957 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3")); | 957 | ssl_version = CURL_SSLVERSION_DEFAULT; |
| 958 | #endif | 958 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */ |
| 959 | else if (!strcmp (optarg, "1.2")) | 959 | else if (!strcmp (optarg, "1.2")) |
| 960 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) | 960 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) |
| 961 | ssl_version = CURL_SSLVERSION_TLSv1_2; | 961 | ssl_version = CURL_SSLVERSION_TLSv1_2; |
| 962 | #else | 962 | #else |
| 963 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3")); | 963 | ssl_version = CURL_SSLVERSION_DEFAULT; |
| 964 | #endif | 964 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */ |
| 965 | else if (!strcmp (optarg, "1.3")) | 965 | else if (!strcmp (optarg, "1.3")) |
| 966 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 52, 0) | 966 | #if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 52, 0) |
| 967 | ssl_version = CURL_SSLVERSION_TLSv1_3; | 967 | ssl_version = CURL_SSLVERSION_TLSv1_3; |
| 968 | #else | 968 | #else |
| 969 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2")); | 969 | ssl_version = CURL_SSLVERSION_DEFAULT; |
| 970 | #endif | 970 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 52, 0) */ |
| 971 | |||
| 972 | else | 971 | else |
| 973 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); | 972 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); |
| 974 | } | 973 | } |
| @@ -1000,19 +999,20 @@ process_arguments (int argc, char **argv) | |||
| 1000 | break; | 999 | break; |
| 1001 | } | 1000 | } |
| 1002 | } | 1001 | } |
| 1003 | #endif | 1002 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */ |
| 1004 | if (verbose >= 2) | 1003 | if (verbose >= 2) |
| 1005 | printf(_("* Set SSL/TLS version to %d\n"), ssl_version); | 1004 | printf(_("* Set SSL/TLS version to %d\n"), ssl_version); |
| 1006 | if (server_port == HTTP_PORT) | 1005 | if (server_port == HTTP_PORT) |
| 1007 | server_port = HTTPS_PORT; | 1006 | server_port = HTTPS_PORT; |
| 1008 | #else | 1007 | break; |
| 1008 | #else /* LIBCURL_FEATURE_SSL */ | ||
| 1009 | /* -C -J and -K fall through to here without SSL */ | 1009 | /* -C -J and -K fall through to here without SSL */ |
| 1010 | usage4 (_("Invalid option - SSL is not available")); | 1010 | usage4 (_("Invalid option - SSL is not available")); |
| 1011 | #endif | ||
| 1012 | break; | 1011 | break; |
| 1013 | case SNI_OPTION: /* --sni is parsed, but ignored, the default is TRUE with libcurl */ | 1012 | case SNI_OPTION: /* --sni is parsed, but ignored, the default is TRUE with libcurl */ |
| 1014 | use_sni = TRUE; | 1013 | use_sni = TRUE; |
| 1015 | break; | 1014 | break; |
| 1015 | #endif /* LIBCURL_FEATURE_SSL */ | ||
| 1016 | case 'f': /* onredirect */ | 1016 | case 'f': /* onredirect */ |
| 1017 | if (!strcmp (optarg, "ok")) | 1017 | if (!strcmp (optarg, "ok")) |
| 1018 | onredirect = STATE_OK; | 1018 | onredirect = STATE_OK; |
