@@ -151,6 +151,18 @@ int acquire_global_lock(apr_global_mutex_t *lock, apr_pool_t *mp) {
151151 ap_log_perror (APLOG_MARK , APLOG_ERR , 0 , NULL , " ModSecurity: Could not create global mutex" );
152152 return -1 ;
153153 }
154+ #if !defined(MSC_TEST )
155+ #ifdef __SET_MUTEX_PERMS
156+ #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
157+ rc = ap_unixd_set_global_mutex_perms (lock );
158+ #else
159+ rc = unixd_set_global_mutex_perms (lock );
160+ #endif
161+ if (rc != APR_SUCCESS ) {
162+ return -1 ;
163+ }
164+ #endif /* SET_MUTEX_PERMS */
165+ #endif /* MSC_TEST */
154166 return APR_SUCCESS ;
155167}
156168/**
@@ -163,7 +175,7 @@ int modsecurity_init(msc_engine *msce, apr_pool_t *mp) {
163175
164176 msce -> auditlog_lock = msce -> geo_lock = NULL ;
165177#ifdef GLOBAL_COLLECTION_LOCK
166- msce -> geo_lock = NULL ;
178+ msce -> dbm_lock = NULL ;
167179#endif
168180
169181 /**
@@ -182,54 +194,17 @@ int modsecurity_init(msc_engine *msce, apr_pool_t *mp) {
182194 return -1 ;
183195 }
184196
185- #if !defined(MSC_TEST )
186- #ifdef __SET_MUTEX_PERMS
187- #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
188- rc = ap_unixd_set_global_mutex_perms (msce -> auditlog_lock );
189- #else
190- rc = unixd_set_global_mutex_perms (msce -> auditlog_lock );
191- #endif
192- if (rc != APR_SUCCESS ) {
193- // ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, "mod_security: Could not set permissions on modsec_auditlog_lock; check User and Group directives");
194- // return HTTP_INTERNAL_SERVER_ERROR;
195- return -1 ;
196- }
197- #endif /* SET_MUTEX_PERMS */
198-
199197 rc = acquire_global_lock (msce -> geo_lock , mp );
200198 if (rc != APR_SUCCESS ) {
201199 return -1 ;
202200 }
203201
204- #ifdef __SET_MUTEX_PERMS
205- #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
206- rc = ap_unixd_set_global_mutex_perms (msce -> geo_lock );
207- #else
208- rc = unixd_set_global_mutex_perms (msce -> geo_lock );
209- #endif
210- if (rc != APR_SUCCESS ) {
211- return -1 ;
212- }
213- #endif /* SET_MUTEX_PERMS */
214-
215202#ifdef GLOBAL_COLLECTION_LOCK
216203 rc = acquire_global_lock (& msce -> dbm_lock , mp );
217204 if (rc != APR_SUCCESS ) {
218205 return -1 ;
219206 }
220-
221- #ifdef __SET_MUTEX_PERMS
222- #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
223- rc = ap_unixd_set_global_mutex_perms (msce -> dbm_lock );
224- #else
225- rc = unixd_set_global_mutex_perms (msce -> dbm_lock );
226- #endif
227- if (rc != APR_SUCCESS ) {
228- return -1 ;
229- }
230- #endif /* SET_MUTEX_PERMS */
231- #endif
232- #endif
207+ #endif /* GLOBAL_COLLECTION_LOCK */
233208
234209 return 1 ;
235210}
0 commit comments