X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_http.c;h=0a4b12bb9a413ead9c58d0d74a3c7159cb0eac25;hb=88b9e75deec6f84efe1260a6df57f3f79ba04edf;hp=79f6adf39962767c4d14a19d6d587c988afb6d8f;hpb=0489df95fc5ab2c84cd7830df97942a874e431d9;p=nagiosplug.git diff --git a/plugins/check_http.c b/plugins/check_http.c index 79f6adf..0a4b12b 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -105,6 +105,7 @@ int check_warning_time = FALSE; double critical_time = 0; int check_critical_time = FALSE; char user_auth[MAX_INPUT_BUFFER] = ""; +char proxy_auth[MAX_INPUT_BUFFER] = ""; int display_html = FALSE; char **http_opt_headers; int http_opt_headers_count = 0; @@ -192,6 +193,7 @@ process_arguments (int argc, char **argv) {"url", required_argument, 0, 'u'}, {"port", required_argument, 0, 'p'}, {"authorization", required_argument, 0, 'a'}, + {"proxy_authorization", required_argument, 0, 'b'}, {"string", required_argument, 0, 's'}, {"expect", required_argument, 0, 'e'}, {"regex", required_argument, 0, 'r'}, @@ -229,7 +231,7 @@ process_arguments (int argc, char **argv) } while (1) { - c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); + c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); if (c == -1 || c == EOF) break; @@ -350,6 +352,10 @@ process_arguments (int argc, char **argv) strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); user_auth[MAX_INPUT_BUFFER - 1] = 0; break; + case 'b': /* proxy-authorization info */ + strncpy (proxy_auth, optarg, MAX_INPUT_BUFFER - 1); + proxy_auth[MAX_INPUT_BUFFER - 1] = 0; + break; case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ if (! http_post_data) http_post_data = strdup (optarg); @@ -836,6 +842,12 @@ check_http (void) asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); } + /* optionally send the proxy authentication info */ + if (strlen(proxy_auth)) { + base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); + asprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); + } + /* either send http POST data (any data, not only POST)*/ if (http_post_data) { if (http_content_type) { @@ -1346,6 +1358,8 @@ print_help (void) printf (" %s\n", "-a, --authorization=AUTH_PAIR"); printf (" %s\n", _("Username:password on sites with basic authentication")); + printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); + printf (" %s\n", _("Username:password on proxy-servers with basic authentication")); printf (" %s\n", "-A, --useragent=STRING"); printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); printf (" %s\n", "-k, --header=STRING"); @@ -1406,8 +1420,8 @@ print_usage (void) { printf (_("Usage:")); printf (" %s -H | -I [-u ] [-p ]\n",progname); - printf (" [-w ] [-c ] [-t ] [-L]\n"); - printf (" [-a auth] [-f ]\n"); + printf (" [-w ] [-c ] [-t ] [-L] [-a auth]\n"); + printf (" [-b proxy_auth] [-f ]\n"); printf (" [-e ] [-s string] [-l] [-r | -R ]\n"); printf (" [-P string] [-m :] [-4|-6] [-N] [-M ]\n"); printf (" [-A string] [-k string] [-S] [-C ] [-T ] [-j method]\n");