"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "apache2/persist_dbm.c" between
modsecurity-2.9.6.tar.gz and modsecurity-2.9.7.tar.gz

About: ModSecurity is an intrusion detection and prevention module (web application firewall) for the Apache (and Nginx) Web servers.

persist_dbm.c  (modsecurity-2.9.6):persist_dbm.c  (modsecurity-2.9.7)
skipping to change at line 107 skipping to change at line 107
apr_sdbm_t *dbm = NULL; apr_sdbm_t *dbm = NULL;
apr_table_t *col = NULL; apr_table_t *col = NULL;
const apr_array_header_t *arr; const apr_array_header_t *arr;
apr_table_entry_t *te; apr_table_entry_t *te;
int expired = 0; int expired = 0;
int i; int i;
/** /**
* This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations * This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations
*/ */
char *username; char *userinfo;
apr_uid_t uid; apr_uid_t uid;
apr_gid_t gid; apr_gid_t gid;
apr_uid_current(&uid, &gid, msr->mp); apr_uid_current(&uid, &gid, msr->mp);
apr_uid_name_get(&username, uid, msr->mp); rc = apr_uid_name_get(&userinfo, uid, msr->mp);
if (rc != APR_SUCCESS) {
userinfo = apr_psprintf(msr->mp, "%u", uid);
}
if (msr->txcfg->data_dir == NULL) { if (msr->txcfg->data_dir == NULL) {
msr_log(msr, 1, "collection_retrieve_ex: Unable to retrieve collection ( name \"%s\", key \"%s\"). Use " msr_log(msr, 1, "collection_retrieve_ex: Unable to retrieve collection ( name \"%s\", key \"%s\"). Use "
"SecDataDir to define data directory first.", log_escape(msr->mp, co l_name), "SecDataDir to define data directory first.", log_escape(msr->mp, co l_name),
log_escape_ex(msr->mp, col_key, col_key_len)); log_escape_ex(msr->mp, col_key, col_key_len));
goto cleanup; goto cleanup;
} }
dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", username, "-" , col_name, NULL); dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", userinfo, "-" , col_name, NULL);
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
msr_log(msr, 9, "collection_retrieve_ex: collection_retrieve_ex: Retriev ing collection (name \"%s\", filename \"%s\")",log_escape(msr->mp, col_name), msr_log(msr, 9, "collection_retrieve_ex: collection_retrieve_ex: Retriev ing collection (name \"%s\", filename \"%s\")",log_escape(msr->mp, col_name),
log_escape(msr->mp, dbm_filename)); log_escape(msr->mp, dbm_filename));
} }
key.dptr = (char *)col_key; key.dptr = (char *)col_key;
key.dsize = col_key_len + 1; key.dsize = col_key_len + 1;
if (existing_dbm == NULL) { if (existing_dbm == NULL) {
skipping to change at line 387 skipping to change at line 390
apr_sdbm_t *dbm = NULL; apr_sdbm_t *dbm = NULL;
const apr_array_header_t *arr; const apr_array_header_t *arr;
apr_table_entry_t *te; apr_table_entry_t *te;
int i; int i;
const apr_table_t *stored_col = NULL; const apr_table_t *stored_col = NULL;
const apr_table_t *orig_col = NULL; const apr_table_t *orig_col = NULL;
/** /**
* This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations * This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations
*/ */
char *username; char *userinfo;
apr_uid_t uid; apr_uid_t uid;
apr_gid_t gid; apr_gid_t gid;
apr_uid_current(&uid, &gid, msr->mp); apr_uid_current(&uid, &gid, msr->mp);
apr_uid_name_get(&username, uid, msr->mp); rc = apr_uid_name_get(&userinfo, uid, msr->mp);
if (rc != APR_SUCCESS) {
userinfo = apr_psprintf(msr->mp, "%u", uid);
}
var_name = (msc_string *)apr_table_get(col, "__name"); var_name = (msc_string *)apr_table_get(col, "__name");
if (var_name == NULL) { if (var_name == NULL) {
goto error; goto error;
} }
var_key = (msc_string *)apr_table_get(col, "__key"); var_key = (msc_string *)apr_table_get(col, "__key");
if (var_key == NULL) { if (var_key == NULL) {
goto error; goto error;
} }
if (msr->txcfg->data_dir == NULL) { if (msr->txcfg->data_dir == NULL) {
msr_log(msr, 1, "collection_store: Unable to store collection (name \"%s \", key \"%s\"). Use " msr_log(msr, 1, "collection_store: Unable to store collection (name \"%s \", key \"%s\"). Use "
"SecDataDir to define data directory first.", log_escape_ex(msr->mp, var_name->value, var_name->value_len), "SecDataDir to define data directory first.", log_escape_ex(msr->mp, var_name->value, var_name->value_len),
log_escape_ex(msr->mp, var_key->value, var_key->value_len)); log_escape_ex(msr->mp, var_key->value, var_key->value_len));
goto error; goto error;
} }
// ENH: lowercase the var name in the filename // ENH: lowercase the var name in the filename
dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", username, "-" , var_name->value, NULL); dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", userinfo, "-" , var_name->value, NULL);
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
msr_log(msr, 9, "collection_store: Retrieving collection (name \"%s\", f ilename \"%s\")",log_escape(msr->mp, var_name->value), msr_log(msr, 9, "collection_store: Retrieving collection (name \"%s\", f ilename \"%s\")",log_escape(msr->mp, var_name->value),
log_escape(msr->mp, dbm_filename)); log_escape(msr->mp, dbm_filename));
} }
#ifdef GLOBAL_COLLECTION_LOCK #ifdef GLOBAL_COLLECTION_LOCK
/* Need to lock to pull in the stored data again and apply deltas. */ /* Need to lock to pull in the stored data again and apply deltas. */
rc = apr_global_mutex_lock(msr->modsecurity->dbm_lock); rc = apr_global_mutex_lock(msr->modsecurity->dbm_lock);
if (rc != APR_SUCCESS) { if (rc != APR_SUCCESS) {
skipping to change at line 677 skipping to change at line 683
apr_sdbm_t *dbm = NULL; apr_sdbm_t *dbm = NULL;
apr_status_t rc; apr_status_t rc;
apr_array_header_t *keys_arr; apr_array_header_t *keys_arr;
char **keys; char **keys;
apr_time_t now = apr_time_sec(msr->request_time); apr_time_t now = apr_time_sec(msr->request_time);
int i; int i;
/** /**
* This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations * This is required for mpm-itk & mod_ruid2, though should be harmless for o ther implementations
*/ */
char *username; char *userinfo;
apr_uid_t uid; apr_uid_t uid;
apr_gid_t gid; apr_gid_t gid;
apr_uid_current(&uid, &gid, msr->mp); apr_uid_current(&uid, &gid, msr->mp);
apr_uid_name_get(&username, uid, msr->mp); rc = apr_uid_name_get(&userinfo, uid, msr->mp);
if (rc != APR_SUCCESS) {
userinfo = apr_psprintf(msr->mp, "%u", uid);
}
if (msr->txcfg->data_dir == NULL) { if (msr->txcfg->data_dir == NULL) {
/* The user has been warned about this problem enough times already by n ow. /* The user has been warned about this problem enough times already by n ow.
* msr_log(msr, 1, "Unable to access collection file (name \"%s\"). Use SecDataDir to " * msr_log(msr, 1, "Unable to access collection file (name \"%s\"). Use SecDataDir to "
* "define data directory first.", log_escape(msr->mp, col_name)); * "define data directory first.", log_escape(msr->mp, col_name));
*/ */
goto error; goto error;
} }
if(strstr(col_name,"USER") || strstr(col_name,"SESSION") || strstr(col_name, "RESOURCE")) if(strstr(col_name,"USER") || strstr(col_name,"SESSION") || strstr(col_name, "RESOURCE"))
dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", username, "-", msr->txcfg->webappid, "_", col_name, NULL); dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", userinfo, "-", msr->txcfg->webappid, "_", col_name, NULL);
else else
dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", username, "-", col_name, NULL); dbm_filename = apr_pstrcat(msr->mp, msr->txcfg->data_dir, "/", userinfo, "-", col_name, NULL);
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
msr_log(msr, 9, "collections_remove_stale: Retrieving collection (name \ "%s\", filename \"%s\")",log_escape(msr->mp, col_name), msr_log(msr, 9, "collections_remove_stale: Retrieving collection (name \ "%s\", filename \"%s\")",log_escape(msr->mp, col_name),
log_escape(msr->mp, dbm_filename)); log_escape(msr->mp, dbm_filename));
} }
#ifdef GLOBAL_COLLECTION_LOCK #ifdef GLOBAL_COLLECTION_LOCK
rc = apr_global_mutex_lock(msr->modsecurity->dbm_lock); rc = apr_global_mutex_lock(msr->modsecurity->dbm_lock);
if (rc != APR_SUCCESS) { if (rc != APR_SUCCESS) {
msr_log(msr, 1, "collections_remove_stale: Failed to lock proc mutex: %s ", msr_log(msr, 1, "collections_remove_stale: Failed to lock proc mutex: %s ",
 End of changes. 10 change blocks. 
10 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)