diff --git a/CHANGES b/CHANGES index 7bc8cbd27..8458908f4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ (to be released) - 2.9.x ------------------------ + * Fixed apr_global_mutex_create() usage (no filename) + [PR #3268 - @marcstern] * handle errors from apr_global_mutex_lock [PR #3257 - @marcstern] diff --git a/apache2/modsecurity.c b/apache2/modsecurity.c index 550318893..e21f17766 100644 --- a/apache2/modsecurity.c +++ b/apache2/modsecurity.c @@ -123,30 +123,7 @@ msc_engine *modsecurity_create(apr_pool_t *mp, int processing_mode) { } int acquire_global_lock(apr_global_mutex_t **lock, apr_pool_t *mp) { - apr_status_t rc; - apr_file_t *lock_name; - const char *temp_dir; - const char *filename = NULL; - - // get platform temp dir - rc = apr_temp_dir_get(&temp_dir, mp); - if (rc != APR_SUCCESS) { - ap_log_perror(APLOG_MARK, APLOG_ERR, 0, mp, "ModSecurity: Could not get temp dir"); - return -1; - } - - // use temp path template for lock files - char *path = apr_pstrcat(mp, temp_dir, GLOBAL_LOCK_TEMPLATE, NULL); - - rc = apr_file_mktemp(&lock_name, path, 0, mp); - if (rc != APR_SUCCESS) { - ap_log_perror(APLOG_MARK, APLOG_ERR, 0, mp, " ModSecurity: Could not create temporary file for global lock"); - return -1; - } - // below func always return APR_SUCCESS - apr_file_name_get(&filename, lock_name); - - rc = apr_global_mutex_create(lock, filename, APR_LOCK_DEFAULT, mp); + apr_status_t rc = apr_global_mutex_create(lock, NULL, APR_LOCK_DEFAULT, mp); if (rc != APR_SUCCESS) { ap_log_perror(APLOG_MARK, APLOG_ERR, 0, mp, " ModSecurity: Could not create global mutex"); return -1; diff --git a/apache2/modsecurity.h b/apache2/modsecurity.h index a1751000b..b3976f936 100644 --- a/apache2/modsecurity.h +++ b/apache2/modsecurity.h @@ -135,8 +135,6 @@ typedef struct msc_parm msc_parm; #define FATAL_ERROR "ModSecurity: Fatal error (memory allocation or unexpected internal error)!" -#define GLOBAL_LOCK_TEMPLATE "/modsec-lock-tmp.XXXXXX" - extern DSOLOCAL char *new_server_signature; extern DSOLOCAL char *real_server_signature; extern DSOLOCAL char *chroot_dir; diff --git a/modsecurity.conf-recommended b/modsecurity.conf-recommended index 11ffbbbdf..e120daef8 100644 --- a/modsecurity.conf-recommended +++ b/modsecurity.conf-recommended @@ -109,7 +109,7 @@ SecPcreMatchLimitRecursion 1000 # MSC_PCRE_LIMITS_EXCEEDED: PCRE match limits were exceeded. # SecRule TX:/^MSC_/ "!@streq 0" \ - "id:'200005',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'" + "id:'200005',phase:2,t:none,log,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'" # -- Response body handling --------------------------------------------------