diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..51169518a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +*.o +*.lo +*.la +**/Makefile +**/Makefile.in +.deps +.libs +configure +configure~ +config.log +config.status +aclocal.m4 +libtool +.dirstamp +config.guess +config.sub +apache2/modsecurity_config_auto.h +apache2/modsecurity_config_auto.h.in +apache2/stamp-h1 +build/apxs-wrapper +build/ar-lib +build/compile +build/depcomp +build/install-sh +build/libtool.m4 +build/ltmain.sh +build/ltoptions.m4 +build/ltsugar.m4 +build/ltversion.m4 +build/lt~obsolete.m4 +build/missing +build/test-driver +mlogc/mlogc +mlogc/mlogc-batch-load.pl +tests/csv_rx-pm.pl +tests/gen_rx-pm.pl +tests/regression/misc/40-secRemoteRules.t +tests/regression/misc/50-ipmatchfromfile-external.t +tests/regression/misc/60-pmfromfile-external.t +tests/regression/server_root/conf/httpd.conf +tests/run-regression-tests.pl +tests/run-unit-tests.pl +tools/rules-updater.pl + diff --git a/apache2/apache2_config.c b/apache2/apache2_config.c index 74c76a5810..80c99baa29 100644 --- a/apache2/apache2_config.c +++ b/apache2/apache2_config.c @@ -1300,7 +1300,7 @@ static const char *cmd_audit_log_relevant_status(cmd_parms *cmd, void *_dcfg, { directory_config *dcfg = _dcfg; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE2_DOTALL, NULL, NULL); #else dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE_DOTALL, NULL, NULL); diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c index 7786543a12..abe2908929 100644 --- a/apache2/mod_security2.c +++ b/apache2/mod_security2.c @@ -116,7 +116,7 @@ static void version(apr_pool_t *mp) { ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, "ModSecurity: Loaded APR do not match with compiled!"); } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE pcre_vrs = apr_psprintf(mp,"%d.%d ", PCRE2_MAJOR, PCRE2_MINOR); pcre_loaded_vrs = pcre2_loaded_vrs_buffer; pcre2_config(PCRE2_CONFIG_VERSION, pcre2_loaded_vrs_buffer); @@ -126,7 +126,7 @@ static void version(apr_pool_t *mp) { #endif ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL, -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE "ModSecurity: PCRE2 compiled version=\"%s\"; " #else "ModSecurity: PCRE compiled version=\"%s\"; " diff --git a/apache2/modsecurity.c b/apache2/modsecurity.c index af5294668b..1aae2e8c61 100644 --- a/apache2/modsecurity.c +++ b/apache2/modsecurity.c @@ -565,14 +565,14 @@ static int is_response_status_relevant(modsec_rec *msr, int status) { rc = msc_regexec(msr->txcfg->auditlog_relevant_regex, buf, strlen(buf), &my_error_msg); if (rc >= 0) return 1; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc == PCRE2_ERROR_NOMATCH) return 0; #else if (rc == PCRE_ERROR_NOMATCH) return 0; #endif msr_log(msr, 1, "Regex processing failed (rc %d): %s", rc, my_error_msg); - + return 0; } diff --git a/apache2/msc_crypt.c b/apache2/msc_crypt.c index 3fe18c78b4..b2e5c2b311 100644 --- a/apache2/msc_crypt.c +++ b/apache2/msc_crypt.c @@ -386,7 +386,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { case HASH_URL_HREF_HASH_RX: if(em[i]->type == HASH_URL_HREF_HASH_RX) { rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -419,7 +419,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { msr_log(msr, 4, "%s.", error_msg); return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -449,7 +449,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { case HASH_URL_FACTION_HASH_RX: if(em[i]->type == HASH_URL_FACTION_HASH_RX) { rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -482,7 +482,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { msr_log(msr, 4, "%s.", error_msg); return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -512,7 +512,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { case HASH_URL_LOCATION_HASH_RX: if(em[i]->type == HASH_URL_LOCATION_HASH_RX) { rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -545,7 +545,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { msr_log(msr, 4, "%s.", error_msg); return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -575,7 +575,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { case HASH_URL_IFRAMESRC_HASH_RX: if(em[i]->type == HASH_URL_IFRAMESRC_HASH_RX) { rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -608,7 +608,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { msr_log(msr, 4, "%s.", error_msg); return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -638,7 +638,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { case HASH_URL_FRAMESRC_HASH_RX: if(em[i]->type == HASH_URL_FRAMESRC_HASH_RX) { rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -671,7 +671,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) { msr_log(msr, 4, "%s.", error_msg); return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ diff --git a/apache2/msc_pcre.c b/apache2/msc_pcre.c index 6f1a9a186c..f5d89fee25 100644 --- a/apache2/msc_pcre.c +++ b/apache2/msc_pcre.c @@ -20,7 +20,7 @@ */ static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) { if (regex != NULL) { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (regex->match_context != NULL) { pcre2_match_context_free(regex->match_context); regex->match_context = NULL; @@ -59,7 +59,7 @@ static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) { void *msc_pregcomp_ex(apr_pool_t *pool, const char *pattern, int options, const char **_errptr, int *_erroffset, int match_limit, int match_limit_recursion) -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE { msc_regex_t *regex = NULL; PCRE2_SPTR pcre2_pattern; @@ -132,7 +132,7 @@ void *msc_pregcomp_ex(apr_pool_t *pool, const char *pattern, int options, return regex; } -#else /* not WITH_PCRE2 */ +#else /* not ifndef WITH_PCRE */ { const char *errptr = NULL; int erroffset; @@ -216,7 +216,7 @@ void *msc_pregcomp_ex(apr_pool_t *pool, const char *pattern, int options, return regex; } -#endif /* WITH_PCRE2 */ +#endif /* ifndef WITH_PCRE */ /** * Compiles the provided regular expression pattern. Calls msc_pregcomp_ex() @@ -239,7 +239,7 @@ int msc_regexec_ex(msc_regex_t *regex, const char *s, unsigned int slen, if (error_msg == NULL) return -1000; /* To differentiate from PCRE as it already uses -1. */ *error_msg = NULL; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE { PCRE2_SPTR pcre2_s; int pcre2_ret; @@ -319,7 +319,7 @@ int msc_regexec(msc_regex_t *regex, const char *s, unsigned int slen, */ int msc_fullinfo(msc_regex_t *regex, int what, void *where) { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE return pcre2_pattern_info(regex->re, (uint32_t)what, where); #else return pcre_fullinfo(regex->re, regex->pe, what, where); diff --git a/apache2/msc_pcre.h b/apache2/msc_pcre.h index c0ab37b4ae..709d31ccfa 100644 --- a/apache2/msc_pcre.h +++ b/apache2/msc_pcre.h @@ -17,14 +17,14 @@ typedef struct msc_regex_t msc_regex_t; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE #define PCRE2_CODE_UNIT_WIDTH 8 #include "pcre2.h" #else #include "pcre.h" #endif -#ifndef WITH_PCRE2 +#ifdef WITH_PCRE #ifndef PCRE_ERROR_MATCHLIMIT /* Define for compile, but not valid in this version of PCRE. */ @@ -42,7 +42,7 @@ typedef struct msc_regex_t msc_regex_t; #include "modsecurity.h" struct msc_regex_t { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE pcre2_code *re; pcre2_match_context *match_context; #ifdef WITH_PCRE_JIT diff --git a/apache2/msc_status_engine.c b/apache2/msc_status_engine.c index 4587641641..b593648cd9 100644 --- a/apache2/msc_status_engine.c +++ b/apache2/msc_status_engine.c @@ -349,7 +349,7 @@ int DSOLOCAL msc_beacon_string (char *beacon_string, int beacon_string_max_len) apr = APR_VERSION_STRING; apr_loaded = apr_version_string(); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE apr_snprintf(pcre, 7, "%d.%d", PCRE2_MAJOR, PCRE2_MINOR); pcre_loaded = ""; /* complete this if/when status reactivated */ #else diff --git a/apache2/re_operators.c b/apache2/re_operators.c index cfd8952539..afbd276f35 100644 --- a/apache2/re_operators.c +++ b/apache2/re_operators.c @@ -697,7 +697,7 @@ static int msre_op_validateHash_param_init(msre_rule *rule, char **error_msg) { /* Compile pattern */ if(strstr(pattern,"%{") == NULL) { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE int options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY; #else int options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY; @@ -711,7 +711,7 @@ static int msre_op_validateHash_param_init(msre_rule *rule, char **error_msg) { #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -796,7 +796,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v msr_log(msr, 6, "Escaping pattern [%s]",pattern); } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY; #else options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY; @@ -812,7 +812,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT if (msr->txcfg->debuglog_level >= 4) { - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -850,7 +850,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v * and no memory has to be allocated for any backreferences. */ rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -884,7 +884,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v return -1; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -967,7 +967,7 @@ static int msre_op_rx_param_init(msre_rule *rule, char **error_msg) { /* Compile pattern */ if(strstr(pattern,"%{") == NULL) { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE int options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY; #else int options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY; @@ -981,7 +981,7 @@ static int msre_op_rx_param_init(msre_rule *rule, char **error_msg) { #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -1057,7 +1057,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c msr_log(msr, 6, "Expanded-macro pattern [%s]",pattern); } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY; #else options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY; @@ -1072,7 +1072,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT if (msr->txcfg->debuglog_level >= 4) { - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -1121,7 +1121,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c /* Show when the regex captures but "capture" is not set */ if (msr->txcfg->debuglog_level >= 6) { int capcount = 0; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE rc = msc_fullinfo(regex, PCRE2_INFO_CAPTURECOUNT, &capcount); #else rc = msc_fullinfo(regex, PCRE_INFO_CAPTURECOUNT, &capcount); @@ -1137,7 +1137,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c * and no memory has to be allocated for any backreferences. */ rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_error_msg); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) { #else if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { @@ -1232,7 +1232,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c } } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */ #else if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ @@ -1688,7 +1688,7 @@ static int msre_op_gsbLookup_param_init(msre_rule *rule, char **error_msg) { *error_msg = NULL; /* Compile rule->op_param */ -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_MULTILINE; #else options = PCRE_DOTALL | PCRE_MULTILINE; @@ -1762,7 +1762,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var memcpy(data,var->value,var->value_len); -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_NOTEMPTY; #else options = PCRE_NOTEMPTY; @@ -2807,7 +2807,7 @@ static int msre_op_verifyCC_init(msre_rule *rule, char **error_msg) { if (error_msg == NULL) return -1; *error_msg = NULL; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_MULTILINE; #else options = PCRE_DOTALL | PCRE_MULTILINE; @@ -2858,7 +2858,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var * #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT if (msr->txcfg->debuglog_level >= 4) { - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -2898,7 +2898,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var * } } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_NOTEMPTY; #else options = PCRE_NOTEMPTY; @@ -2906,7 +2906,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var * rc = msc_regexec_ex(regex, target, target_length, offset, options, ovector, 30, &my_error_msg); /* If there was no match, then we are done. */ -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc == PCRE2_ERROR_NOMATCH) { #else if (rc == PCRE_ERROR_NOMATCH) { @@ -3125,7 +3125,7 @@ static int msre_op_verifyCPF_init(msre_rule *rule, char **error_msg) { if (error_msg == NULL) return -1; *error_msg = NULL; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_MULTILINE; #else options = PCRE_DOTALL | PCRE_MULTILINE; @@ -3189,7 +3189,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT if (msr->txcfg->debuglog_level >= 4) { - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -3228,7 +3228,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var } } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_NOTEMPTY; #else options = PCRE_NOTEMPTY; @@ -3236,7 +3236,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var rc = msc_regexec_ex(regex, target, target_length, offset, options, ovector, 30, &my_error_msg); /* If there was no match, then we are done. */ -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc == PCRE2_ERROR_NOMATCH) { #else if (rc == PCRE_ERROR_NOMATCH) { @@ -3439,7 +3439,7 @@ static int msre_op_verifySSN_init(msre_rule *rule, char **error_msg) { if (error_msg == NULL) return -1; *error_msg = NULL; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_MULTILINE; #else options = PCRE_DOTALL | PCRE_MULTILINE; @@ -3503,7 +3503,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var #ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_JIT if (msr->txcfg->debuglog_level >= 4) { - #ifdef WITH_PCRE2 + #ifndef WITH_PCRE rc = regex->jit_compile_rc; #else rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); @@ -3542,7 +3542,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var } } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_NOTEMPTY; #else options = PCRE_NOTEMPTY; @@ -3550,7 +3550,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var rc = msc_regexec_ex(regex, target, target_length, offset, options, ovector, 30, &my_error_msg); /* If there was no match, then we are done. */ -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE if (rc == PCRE2_ERROR_NOMATCH) { #else if (rc == PCRE_ERROR_NOMATCH) { diff --git a/apache2/re_variables.c b/apache2/re_variables.c index a53140b2c1..39693b7bdb 100644 --- a/apache2/re_variables.c +++ b/apache2/re_variables.c @@ -21,7 +21,7 @@ #include "libxml/xpathInternals.h" -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE #define PCRE_ERROR_NOMATCH PCRE2_ERROR_NOMATCH #endif /** @@ -73,7 +73,7 @@ static char *var_generic_list_validate(msre_ruleset *ruleset, msre_var *var) { pattern = apr_pstrmemdup(ruleset->mp, var->param + 1, strlen(var->param + 1) - 1); if (pattern == NULL) return FATAL_ERROR; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE options = PCRE2_DOTALL | PCRE2_CASELESS | PCRE2_DOLLAR_ENDONLY; #else options = PCRE_DOTALL | PCRE_CASELESS | PCRE_DOLLAR_ENDONLY; diff --git a/build/compile b/build/compile deleted file mode 100755 index 1b1d232169..0000000000 --- a/build/compile +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. - -scriptversion=2005-05-14.22 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; -esac - -ofile= -cfile= -eat= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/build/find_pcre.m4 b/build/find_pcre.m4 index 2cff8f3ccb..fa2a44a26c 100644 --- a/build/find_pcre.m4 +++ b/build/find_pcre.m4 @@ -19,19 +19,17 @@ AC_ARG_WITH( pcre, [AC_HELP_STRING([--with-pcre=PATH],[Path to pcre prefix or config script])], [test_paths="${with_pcre}"], - [test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr"]) + [with_pcre="no"]) -if test "x${with_pcre2}" != "x" && test "x${with_pcre2}" != "xno"; then - AC_MSG_NOTICE([pcre2 specified; omitting check for pcre]) -else - AC_MSG_CHECKING([for libpcre config script]) +AS_CASE(["${with_pcre}"], + [no], [test_paths=], + [yes], [test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr"], + [test_paths="${with_pcre}"]) - dnl # Determine pcre lib directory - if test -z "${with_pcre}"; then - test_paths="/usr/local/pcre /usr/local /usr" - else - test_paths="${with_pcre}" - fi +if test "x${with_pcre}" = "x" || test "x${with_pcre}" = "xno"; then + AC_MSG_NOTICE([pcre not specified; omitting check for pcre]) +else + AC_MSG_CHECKING([for libpcre configig script]) for x in ${test_paths}; do dnl # Determine if the script was specified and use it directly @@ -87,7 +85,8 @@ else AC_MSG_NOTICE([*** pcre library not found.]) else AC_MSG_NOTICE([using pcre v${PCRE_VERSION}]) - ifelse([$1], , , $1) - fi + PCRE_CFLAGS="-DWITH_PCRE ${PCRE_CFLAGS}" + ifelse([$1], , , $1) + fi fi ]) diff --git a/build/find_pcre2.m4 b/build/find_pcre2.m4 index 18c2e25807..961578ac25 100644 --- a/build/find_pcre2.m4 +++ b/build/find_pcre2.m4 @@ -18,26 +18,27 @@ AC_DEFUN([CHECK_PCRE2], AC_ARG_WITH( pcre2, [AC_HELP_STRING([--with-pcre2=PATH],[Path to pcre2 prefix or config script])], - , with_pcre2=no) + [test_paths="${with_pcre2}"], + [with_pcre2="yes"]) AS_CASE(["${with_pcre2}"], - [no], [test_paths=], - [yes], [test_paths="/usr/local/libpcre2 /usr/local/pcre2 /usr/local /opt/libpcre2 /opt/pcre2 /opt /usr"], - [test_paths="${with_pcre2}"]) + [no], [test_paths=], + [yes], [test_paths="/usr/local/libpcre2 /usr/local/pcre2 /usr/local /opt/libpcre2 /opt/pcre2 /opt /usr"], + [test_paths="${with_pcre2}"]) -if test "x${with_pcre2}" = "x" || test "x${with_pcre2}" = "xno"; then - AC_MSG_NOTICE([pcre2 not specified; omitting check]) +if test "x${with_pcre}" != "x" && test "x${with_pcre}" != "xno"; then +AC_MSG_NOTICE([pcre specified; omitting check for pcre2]) else AC_MSG_CHECKING([for libpcre2 config script]) for x in ${test_paths}; do dnl # Determine if the script was specified and use it directly - if test ! -d "$x" -a -e "$x"; then - PCRE2_CONFIG=$x - pcre2_path="no" - break - fi + if test ! -d "$x" -a -e "$x"; then + PCRE2_CONFIG=$x + pcre2_path="no" + break + fi dnl # Try known config script names/locations for PCRE2_CONFIG in pcre2-config; do @@ -86,8 +87,8 @@ else ifelse([$2], , AC_MSG_ERROR([pcre2 library is required]), $2) else AC_MSG_NOTICE([using pcre2 v${PCRE2_VERSION}]) - PCRE2_CFLAGS="-DWITH_PCRE2 ${PCRE2_CFLAGS}" - ifelse([$1], , , $1) - fi + PCRE2_CFLAGS="${PCRE2_CFLAGS}" + ifelse([$1], , , $1) + fi fi ]) diff --git a/mlogc/mlogc.c b/mlogc/mlogc.c index b1030ee45e..7a9edaa12b 100644 --- a/mlogc/mlogc.c +++ b/mlogc/mlogc.c @@ -28,7 +28,7 @@ #if APR_HAVE_UNISTD_H #include /* for getpid() */ #endif -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE #define PCRE2_CODE_UNIT_WIDTH 8 #include #else @@ -152,7 +152,7 @@ static int keep_alive = 150; /* Not used yet. */ static int keep_alive_timeout = 300; /* Not used yet. */ static int keep_entries = 0; static const char *log_repository = NULL; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE static pcre2_code *logline_regex = NULL; static pcre2_code *requestline_regex = NULL; #else @@ -1218,7 +1218,7 @@ static void logc_init(void) int i, erroffset; /* cURL major, minor and patch version */ short cmaj, cmin, cpat = 0; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE int pcre2_errorcode = 0; PCRE2_SIZE pcre2_erroffset = 0; #endif @@ -1325,7 +1325,7 @@ static void logc_init(void) error_log(LOG_DEBUG2, NULL, "TLSv1.2 is unsupported in cURL %d.%d.%d", cmaj, cmin, cpat); } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE logline_regex = pcre2_compile(logline_pattern, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &pcre2_errorcode, &pcre2_erroffset, NULL); #else @@ -1338,7 +1338,7 @@ static void logc_init(void) logc_shutdown(1); } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE requestline_regex = pcre2_compile(requestline_pattern, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &pcre2_errorcode, &pcre2_erroffset, NULL); #else @@ -1455,7 +1455,7 @@ static void * APR_THREAD_FUNC thread_worker(apr_thread_t *thread, void *data) apr_status_t rc; apr_finfo_t finfo; int capturevector[CAPTUREVECTORSIZE]; -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE pcre2_match_data *pcre2_match_data = NULL; #endif int take_new = 1; @@ -1563,7 +1563,7 @@ static void * APR_THREAD_FUNC thread_worker(apr_thread_t *thread, void *data) num_requests++; } -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE pcre2_match_data = pcre2_match_data_create_from_pattern(logline_regex, NULL); rc = pcre2_match(logline_regex, entry->line, entry->line_size, 0, 0, pcre2_match_data, NULL); @@ -2334,7 +2334,7 @@ static void usage(void) { * Version text. */ static void version(void) { -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE char pcre2_loaded_version_buffer[80] ={0}; char *pcre_loaded_version = pcre2_loaded_version_buffer; pcre2_config(PCRE2_CONFIG_VERSION, pcre_loaded_version); @@ -2346,7 +2346,7 @@ static void version(void) { "loaded=\"%s\"\n", APR_VERSION_STRING, apr_version_string()); fprintf(stderr, " PCRE: compiled=\"%d.%d\"; " -#ifdef WITH_PCRE2 +#ifndef WITH_PCRE "loaded=\"%s\"\n", PCRE2_MAJOR, PCRE2_MINOR, pcre_loaded_version); #else "loaded=\"%s\"\n", PCRE_MAJOR, PCRE_MINOR, pcre_version());