@@ -166,7 +166,7 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
166
166
}
167
167
else {
168
168
if (msr -> txcfg -> data_dir == NULL ) {
169
- msr_log (msr , 1 , "[ERROR] collection_retrieve_ex_origin: Unable to retrieve collection (name \"%s\", key \"%s\"). Use "
169
+ msr_log (msr , 1 , "collection_retrieve_ex_origin: Unable to retrieve collection (name \"%s\", key \"%s\"). Use "
170
170
"SecDataDir to define data directory first." , log_escape (msr -> mp , col_name ),
171
171
log_escape_ex (msr -> mp , col_key , col_key_len ));
172
172
goto cleanup ;
@@ -218,22 +218,22 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
218
218
//if not called by collection_store(), need to get lock
219
219
if (existing_dbm == NULL ){
220
220
rc = AGMDB_getSharedLock (ag_dbm );
221
- if (rc != AGMDB_SUCCESS ){
222
- msr_log (msr , 1 , "[ERROR] collection_retrieve_ex_agmdb: Failed to get shared lock" );
221
+ if (AGMDB_isError ( rc ) ){
222
+ msr_log (msr , 1 , "collection_retrieve_ex_agmdb: Failed to get shared lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
223
223
goto cleanup ;
224
224
}
225
225
}
226
226
rc = AGMDB_get (ag_dbm , col_key , col_key_len , buffer , AGMDB_MAX_ENTRY_SIZE , & tmp_val_len );
227
- if (rc != AGMDB_SUCCESS ) {
228
- msr_log (msr , 1 , "[ERROR] collection_retrieve_ex_agmdb: Failed to read from database \"%s\": %s" , log_escape (msr -> mp ,
229
- col_name ), col_key );
227
+ if (AGMDB_isError ( rc ) ) {
228
+ msr_log (msr , 1 , "collection_retrieve_ex_agmdb: Failed to read from database \"%s\": %s. Error info: %s. " , log_escape (msr -> mp ,
229
+ col_name ), col_key , AGMDB_getErrorInfo ( rc ) );
230
230
goto cleanup ;
231
231
}
232
232
233
233
if (existing_dbm == NULL ){
234
234
rc = AGMDB_freeSharedLock (ag_dbm );
235
- if (rc != AGMDB_SUCCESS ) {
236
- msr_log (msr , 1 , "[ERROR] collection_retrieve_ex_agmdb: Failed to free shared lock" );
235
+ if (AGMDB_isError ( rc ) ) {
236
+ msr_log (msr , 1 , "collection_retrieve_ex_agmdb: Failed to free shared lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
237
237
goto cleanup ;
238
238
}
239
239
}
@@ -316,19 +316,19 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
316
316
if (db_option == DB_OPT_AGMDB ){
317
317
if (existing_dbm == NULL ){
318
318
rc = AGMDB_getExclusiveLock (ag_dbm );
319
- if (rc != AGMDB_SUCCESS ){
320
- msr_log (msr , 1 , "collection_retrieve_ex: Failed to get exclusive lock" );
319
+ if (AGMDB_isError ( rc ) ){
320
+ msr_log (msr , 1 , "collection_retrieve_ex: Failed to get exclusive lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
321
321
goto cleanup ;
322
322
}
323
323
}
324
324
rc = AGMDB_delete (ag_dbm , col_key , col_key_len );
325
- if (rc != AGMDB_SUCCESS )
325
+ if (AGMDB_isError ( rc ) )
326
326
fail_flag = 1 ;
327
327
328
328
if (existing_dbm == NULL ){
329
329
rc = AGMDB_freeExclusiveLock (ag_dbm );
330
- if (rc != AGMDB_SUCCESS ){
331
- msr_log (msr , 1 , "collection_retrieve_ex: Failed to free exclusive lock" );
330
+ if (AGMDB_isError ( rc ) ){
331
+ msr_log (msr , 1 , "collection_retrieve_ex: Failed to free exclusive lock. Error info: %s." , AGMDB_getErrorInfo ( rc ) );
332
332
goto cleanup ;
333
333
}
334
334
}
@@ -494,7 +494,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
494
494
msc_string * var_name = NULL , * var_key = NULL ;
495
495
unsigned char * blob = NULL ;
496
496
unsigned int blob_size = 0 , blob_offset = 0 ;
497
- int rc , rc2 ;
497
+ int rc ;
498
498
apr_sdbm_datum_t key ;
499
499
apr_sdbm_datum_t value ;
500
500
const apr_array_header_t * arr ;
@@ -598,7 +598,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
598
598
root_dcfg = msr -> dcfg1 -> root_config ;
599
599
dbm_filename = apr_pstrcat (root_dcfg -> mp , root_dcfg -> data_dir , "/" , var_name -> value , NULL );
600
600
if (root_dcfg == NULL ){
601
- msr_log_error (msr , "[ERROR] collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1." );
601
+ msr_log (msr , 1 , " collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1." );
602
602
goto error ;
603
603
}
604
604
new_handle = (struct agmdb_handle_entry * )apr_pcalloc (root_dcfg -> mp , sizeof (struct agmdb_handle_entry ));
@@ -607,8 +607,8 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
607
607
strcpy ((char * )(new_handle -> col_name ), var_name -> value );
608
608
609
609
rc = AGMDB_openDB (new_handle -> handle , dbm_filename , strlen (dbm_filename ), MAXIMUM_AGMDB_ENTRY_NUM );
610
- if (rc != AGMDB_SUCCESS ){
611
- msr_log (msr , 1 , "[ERROR] collection_retrieve_ex_agmdb: Failed to create DBM name: %s" , apr_psprintf (msr -> mp , "%.*s" , var_name -> value_len , var_name -> value ));
610
+ if (AGMDB_isError ( rc ) ){
611
+ msr_log (msr , 1 , "collection_retrieve_ex_agmdb: Failed to create DBM name: %s. Error info: %s " , apr_psprintf (msr -> mp , "%.*s" , var_name -> value_len , var_name -> value ), AGMDB_getErrorInfo ( rc ));
612
612
goto error ;
613
613
}
614
614
ag_dbm = new_handle -> handle ;
@@ -619,7 +619,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
619
619
// ENH: lowercase the var name in the filename
620
620
dbm_filename = apr_pstrcat (msr -> mp , msr -> txcfg -> data_dir , "/" , var_name -> value , NULL );
621
621
if (msr -> txcfg -> debuglog_level >= 9 ) {
622
- msr_log (msr , 9 , "[ERRNO] collection_store_ex_origin: Retrieving collection (name \"%s\", filename \"%s\")" ,log_escape (msr -> mp , var_name -> value ),
622
+ msr_log (msr , 9 , "collection_store_ex_origin: Retrieving collection (name \"%s\", filename \"%s\")" ,log_escape (msr -> mp , var_name -> value ),
623
623
log_escape (msr -> mp , dbm_filename ));
624
624
}
625
625
@@ -639,7 +639,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
639
639
#ifdef GLOBAL_COLLECTION_LOCK
640
640
apr_global_mutex_unlock (msr -> modsecurity -> dbm_lock );
641
641
#endif
642
- msr_log (msr , 1 , "[ERRNO] collection_store_ex_origin: Failed to access DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
642
+ msr_log (msr , 1 , "collection_store_ex_origin: Failed to access DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
643
643
get_apr_error (msr -> mp , rc ));
644
644
apr_dbm = NULL ;
645
645
goto error ;
@@ -653,12 +653,12 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
653
653
//---------------------------------
654
654
if (db_option == DB_OPT_AGMDB ){
655
655
rc = AGMDB_getExclusiveLock (ag_dbm );
656
- if (rc != AGMDB_SUCCESS ) {
656
+ if (AGMDB_isError ( rc ) ) {
657
657
#ifdef _WIN32
658
658
int lasterr = (int )GetLastError ();
659
- msr_log (msr , 1 , "collection_store: Failed to getExclusiveLock, lasterr = %d" , lasterr );
659
+ msr_log (msr , 1 , "collection_store: Failed to getExclusiveLock, lasterr = %d. Error info: %s " , lasterr , AGMDB_getErrorInfo ( rc ) );
660
660
#else
661
- msr_log (msr , 1 , "collection_store: Failed to getExclusiveLock, errno = %d" , errno );
661
+ msr_log (msr , 1 , "collection_store: Failed to getExclusiveLock, errno = %d. Error info: %s " , errno , AGMDB_getErrorInfo ( rc ) );
662
662
#endif
663
663
goto error ;
664
664
}
@@ -668,7 +668,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
668
668
/* Need to lock to pull in the stored data again and apply deltas. */
669
669
rc = apr_sdbm_lock (apr_dbm , APR_FLOCK_EXCLUSIVE );
670
670
if (rc != APR_SUCCESS ) {
671
- msr_log (msr , 1 , "[ERRNO] collection_store_ex_origin: Failed to exclusivly lock DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
671
+ msr_log (msr , 1 , "collection_store_ex_origin: Failed to exclusivly lock DBM file \"%s\": %s" , log_escape (msr -> mp , dbm_filename ),
672
672
get_apr_error (msr -> mp , rc ));
673
673
goto error ;
674
674
}
@@ -745,8 +745,10 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
745
745
if (blob == NULL ) {
746
746
if (ag_dbm != NULL ) {
747
747
rc = AGMDB_freeExclusiveLock (ag_dbm );
748
+ if (AGMDB_isError (rc ))
749
+ msr_log (msr , 1 , "collection_stror_ex: Fail to free exclusive lock. Error info: %s" , AGMDB_getErrorInfo (rc ));
748
750
}
749
- msr_log_error (msr , "[ERROR] collection_store_ex_agdb: fail to create blob" );
751
+ msr_log (msr , 1 , " collection_store_ex_agdb: fail to create blob" );
750
752
return -1 ;
751
753
}
752
754
}
@@ -815,15 +817,14 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
815
817
value .dsize = blob_size ;
816
818
817
819
if (db_option == DB_OPT_AGMDB ) {
818
- rc2 = AGMDB_set (ag_dbm , var_key -> value , var_key -> value_len , (char * )blob , blob_size );
819
- rc = AGMDB_freeExclusiveLock (ag_dbm );
820
-
821
- if (rc2 != AGMDB_SUCCESS ) {
822
- msr_log (msr , 1 , "[ERROR]collection_store_ex_agmdb: Failed to write to database key: %s" , var_key -> value );
823
- return -1 ;
820
+ rc = AGMDB_set (ag_dbm , var_key -> value , var_key -> value_len , (char * )blob , blob_size );
821
+ if (AGMDB_isError (rc )) {
822
+ msr_log (msr , 1 , "collection_store_ex_agmdb: Failed to write to database key: %s. Error info: %s." , var_key -> value , AGMDB_getErrorInfo (rc ));
824
823
}
825
- if (rc != AGMDB_SUCCESS ){
826
- msr_log (msr , 1 , "[ERROR]collection_store_ex_agmdb: Failed to free exclusive lock" );
824
+
825
+ rc = AGMDB_freeExclusiveLock (ag_dbm );
826
+ if (AGMDB_isError (rc )){
827
+ msr_log (msr , 1 , "collection_store_ex_agmdb: Failed to free exclusive lock. Error info: %s." , AGMDB_getErrorInfo (rc ));
827
828
return -1 ;
828
829
}
829
830
}
@@ -895,7 +896,7 @@ static int collections_remove_stale_ex(int db_option, modsec_rec *msr, const cha
895
896
apr_array_header_t * keys_arr ;
896
897
char * * keys ;
897
898
apr_time_t now = apr_time_sec (msr -> request_time );
898
- int i ;
899
+ int i , rc2 ;
899
900
900
901
//---------------------------------
901
902
//AGMDB
@@ -906,7 +907,9 @@ static int collections_remove_stale_ex(int db_option, modsec_rec *msr, const cha
906
907
ag_dbm = dcfg_searchAGMDBhandler (col_name , (struct agmdb_handle_entry * )(root_dcfg -> agmdb_handles ));
907
908
if (ag_dbm == NULL )
908
909
return 1 ;
909
- return AGMDB_removeStale (ag_dbm );
910
+ rc2 = AGMDB_removeStale (ag_dbm );
911
+ if (AGMDB_isError (rc2 ))
912
+ msr_log (msr , 1 , "collections_remove_stale_ex_agmdb: error in remove stale. Error info: %s" , AGMDB_getErrorInfo (rc2 ));
910
913
}
911
914
//---------------------------------
912
915
//apr_sdbm
0 commit comments