@@ -129,12 +129,20 @@ msc_engine *modsecurity_create(apr_pool_t *mp, int processing_mode) {
129
129
*/
130
130
int modsecurity_init (msc_engine * msce , apr_pool_t * mp ) {
131
131
apr_status_t rc ;
132
- apr_file_t * auditlog_lock_name ;
133
- apr_file_t * geo_lock_name ;
134
- apr_file_t * dbm_lock_name ;
135
-
132
+ apr_file_t * auditlog_lock_file = NULL ;
133
+ apr_file_t * geo_lock_file = NULL ;
134
+ apr_file_t * dbm_lock_file = NULL ;
135
+ const char * temp_dir = NULL ;
136
+ char * temp_path_template = NULL ;
137
+ const char * temp_file ;
138
+
139
+ // get temp path suitable for writing
140
+ rc = apr_temp_dir_get (& temp_dir , mp );
141
+ if (rc != APR_SUCCESS ) {
142
+ return -1 ;
143
+ }
136
144
// use temp path template for lock files
137
- char * path = apr_pstrcat (p , temp_dir , "/modsec-lock-tmp.XXXXXX" , NULL );
145
+ temp_path_template = apr_pstrcat (mp , temp_dir , "/modsec-lock-tmp.XXXXXX" , NULL );
138
146
139
147
msce -> auditlog_lock = msce -> geo_lock = NULL ;
140
148
#ifdef GLOBAL_COLLECTION_LOCK
@@ -152,11 +160,15 @@ int modsecurity_init(msc_engine *msce, apr_pool_t *mp) {
152
160
curl_global_init (CURL_GLOBAL_ALL );
153
161
#endif
154
162
/* Serial audit log mutext */
155
- rc = apr_file_mktemp (& auditlog_lock_name , path , 0 , p )
163
+ rc = apr_file_mktemp (& auditlog_lock_file , temp_path_template , 0 , mp );
156
164
if (rc != APR_SUCCESS ) {
157
- return -1
165
+ return -1 ;
166
+ }
167
+ rc = apr_file_name_get (& temp_file , auditlog_lock_file );
168
+ if (rc != APR_SUCCESS ) {
169
+ return -1 ;
158
170
}
159
- rc = apr_global_mutex_create (& msce -> auditlog_lock , auditlog_lock_name , APR_LOCK_DEFAULT , mp );
171
+ rc = apr_global_mutex_create (& msce -> auditlog_lock , temp_file , APR_LOCK_DEFAULT , mp );
160
172
if (rc != APR_SUCCESS ) {
161
173
return -1 ;
162
174
}
@@ -175,11 +187,15 @@ int modsecurity_init(msc_engine *msce, apr_pool_t *mp) {
175
187
}
176
188
#endif /* SET_MUTEX_PERMS */
177
189
178
- rc = apr_file_mktemp (& geo_lock_name , path , 0 , p )
190
+ rc = apr_file_mktemp (& geo_lock_file , temp_path_template , 0 , mp );
179
191
if (rc != APR_SUCCESS ) {
180
- return -1
192
+ return -1 ;
193
+ }
194
+ rc = apr_file_name_get (& temp_file , geo_lock_file );
195
+ if (rc != APR_SUCCESS ) {
196
+ return -1 ;
181
197
}
182
- rc = apr_global_mutex_create (& msce -> geo_lock , geo_lock_name , APR_LOCK_DEFAULT , mp );
198
+ rc = apr_global_mutex_create (& msce -> geo_lock , temp_file , APR_LOCK_DEFAULT , mp );
183
199
if (rc != APR_SUCCESS ) {
184
200
return -1 ;
185
201
}
@@ -196,11 +212,15 @@ int modsecurity_init(msc_engine *msce, apr_pool_t *mp) {
196
212
#endif /* SET_MUTEX_PERMS */
197
213
198
214
#ifdef GLOBAL_COLLECTION_LOCK
199
- rc = apr_file_mktemp (& dbm_lock_name , path , 0 , p )
215
+ rc = apr_file_mktemp (& dbm_lock_file , temp_path_template , 0 , mp );
200
216
if (rc != APR_SUCCESS ) {
201
- return -1
217
+ return -1 ;
218
+ }
219
+ rc = apr_file_name_get (& temp_file , dbm_lock_file );
220
+ if (rc != APR_SUCCESS ) {
221
+ return -1 ;
202
222
}
203
- rc = apr_global_mutex_create (& msce -> dbm_lock , dbm_lock_name , APR_LOCK_DEFAULT , mp );
223
+ rc = apr_global_mutex_create (& msce -> dbm_lock , temp_file , APR_LOCK_DEFAULT , mp );
204
224
if (rc != APR_SUCCESS ) {
205
225
return -1 ;
206
226
}
0 commit comments