cc -I../plugins -I.. -I/usr/local/include -I/usr/include -I../lib -I../gl -c -o check_http-with-client-certificate.o check_http-with-client-certificate.c cc -O2 -fno-strict-aliasing -pipe -L. -o check_http-with-client-cert check_http-with-client-certificate.o ../plugins/sslutils.o ../plugins/netutils.o ../plugins/utils.o ../lib/libnagiosplug.a ../gl/libgnu.a -lssl -lcrypto /usr/local/lib/libintl.so -L/usr/local/lib /usr/local/lib/libiconv.so -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib --- /root/nagios-plugins-1.4.12/contrib/check_http-with-client-certificate.c 2005-02-01 06:20:04.000000000 +0200 +++ check_http-with-client-certificate.c 2008-06-18 11:19:10.000000000 +0300 @@ -164,11 +164,9 @@ #define HTTPS_PORT 443 #endif -#ifdef HAVE_REGEX_H #include #define REGEX_REGS 2 #define MAX_REGEX_SIZE 256 -#endif #define chk_protocol(protocol) ( strstr( protocol, "https" ) ? TRUE : FALSE ); #define protocol_std_port(use_ssl) ( use_ssl ? HTTPS_PORT : HTTP_PORT ); @@ -248,7 +246,6 @@ int http_redirect_state = DEFAULT_HTTP_REDIRECT_STATE; int http_client_error_state = DEFAULT_HTTP_CLIENT_ERROR_STATE; -#ifdef HAVE_REGEX_H regex_t regex_preg; regmatch_t regex_pmatch[REGEX_REGS]; int check_content_regex = FALSE; @@ -256,7 +253,6 @@ int regex_cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; int regex_error = 0; char regex_error_buffer[MAX_INPUT_BUFFER] = ""; -#endif @@ -697,20 +693,11 @@ check_content_string = TRUE; break; case 'l': /* regex linespan */ -#ifdef HAVE_REGEX_H regex_cflags &= ~REG_NEWLINE; -#else - usage( "check_http: call for regex which was not a compiled option\n" ); -#endif break; case 'R': /* expected case insensitive regular expression in content */ -#ifdef HAVE_REGEX_H regex_cflags |= REG_ICASE; -#else - usage( "check_http: call for regex which was not a compiled option\n" ); -#endif case 'r': /* expected regular expression in content */ -#ifdef HAVE_REGEX_H strncpy( content_regex , optarg, MAX_REGEX_SIZE - 1 ); content_regex[MAX_REGEX_SIZE - 1] = 0; check_content_regex = TRUE; @@ -720,9 +707,6 @@ printf( "Could Not Compile Regular Expression: %s", regex_error_buffer ); return ERROR; } -#else - usage( "check_http: call for regex which was not a compiled option\n" ); -#endif break; case 'f': /* onredirect (3xx errors) */ if ( !strcmp( optarg, "follow" ) ) @@ -967,7 +951,7 @@ state_text( STATE_CRITICAL ), elapsed_time, elapsed_time ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } if ( use_warning_interval && ( elapsed_time > warning_interval ) ) { asprintf( &msg, RESULT_TEMPLATE_RESPONSE_TIME, @@ -975,7 +959,7 @@ state_text( STATE_WARNING ), elapsed_time, elapsed_time ); - terminate( STATE_WARNING, msg ); + die( STATE_WARNING, msg ); } @@ -993,7 +977,7 @@ asprintf( &msg, "Expected HTTP response received from host\n" ); else asprintf( &msg, "Expected HTTP response received from host on port %d\n", server_port ); - terminate( STATE_OK, msg ); + die( STATE_OK, msg ); } } else { if ( ( server_port == HTTP_PORT ) @@ -1005,7 +989,7 @@ asprintf( &msg, "Invalid HTTP response received from host\n" ); else asprintf( &msg, "Invalid HTTP response received from host on port %d\n", server_port ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } /* check the return code */ @@ -1022,7 +1006,7 @@ page->status, elapsed_time, elapsed_time ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } /* client errors result in a warning state */ @@ -1050,7 +1034,7 @@ page->status, elapsed_time, elapsed_time ); - terminate( http_client_error_state, msg ); + die( http_client_error_state, msg ); } /* check redirected page if specified */ @@ -1072,7 +1056,7 @@ page->status, elapsed_time, elapsed_time ); - terminate( http_redirect_state, msg ); + die( http_redirect_state, msg ); } } @@ -1093,7 +1077,7 @@ page->status, elapsed_time, elapsed_time ); - terminate( STATE_OK, msg ); + die( STATE_OK, msg ); } else { asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, protocol_text( use_ssl ), @@ -1101,11 +1085,10 @@ page->status, elapsed_time, elapsed_time ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } } -#ifdef HAVE_REGEX_H /* check for regex in content */ if ( check_content_regex ) { regex_error = regexec( ®ex_preg, page->content, REGEX_REGS, regex_pmatch, 0); @@ -1116,24 +1099,23 @@ page->status, elapsed_time, elapsed_time ); - terminate( STATE_OK, msg ); + die( STATE_OK, msg ); } else { if ( regex_error == REG_NOMATCH ) { asprintf( &msg, "%s, %s: regex pattern not found\n", protocol_text( use_ssl) , state_text( STATE_CRITICAL ) ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } else { regerror( regex_error, ®ex_preg, regex_error_buffer, MAX_INPUT_BUFFER); asprintf( &msg, "%s %s: Regex execute Error: %s\n", protocol_text( use_ssl) , state_text( STATE_CRITICAL ), regex_error_buffer ); - terminate( STATE_CRITICAL, msg ); + die( STATE_CRITICAL, msg ); } } } -#endif return STATE_OK; } @@ -1166,7 +1148,7 @@ while ( strcspn( header, "\r\n" ) > (size_t) 0 ) { url_path = realloc( url_path, (size_t) strcspn( header, "\r\n" ) ); if ( url_path == NULL ) - terminate( STATE_UNKNOWN, "HTTP UNKNOWN: could not reallocate url_path" ); + die( STATE_UNKNOWN, "HTTP UNKNOWN: could not reallocate url_path" ); /* Try to find a Location header combination of METHOD HOSTNAME PORT and PATH */ @@ -1222,7 +1204,7 @@ protocol_text( use_ssl ), state_text( STATE_UNKNOWN ), page->status ); - terminate( STATE_UNKNOWN, msg ); + die( STATE_UNKNOWN, msg ); } #ifdef HAVE_SSL @@ -1333,7 +1315,7 @@ int ssl_terminate(int state, char *string ) { ERR_print_errors( bio_err ); - terminate( state, string ); + die( state, string ); } #endif