@@ -1519,6 +1519,7 @@ apr_status_t msre_action_setvar_execute(modsec_rec *msr, apr_pool_t *mptmp,
1519
1519
char * s = NULL ;
1520
1520
apr_table_t * target_col = NULL ;
1521
1521
int is_negated = 0 ;
1522
+ char * real_col_name = NULL ;
1522
1523
msc_string * var = NULL ;
1523
1524
1524
1525
if (msr -> txcfg -> debuglog_level >= 9 ) {
@@ -1561,19 +1562,26 @@ apr_status_t msre_action_setvar_execute(modsec_rec *msr, apr_pool_t *mptmp,
1561
1562
var_name = s + 1 ;
1562
1563
* s = '\0' ;
1563
1564
1565
+ if (strcasecmp (col_name ,"USER" ) == 0 || strcasecmp (col_name ,"SESSION" ) == 0
1566
+ || strcasecmp (col_name , "RESOURCE" ) == 0 ) {
1567
+ real_col_name = apr_psprintf (mptmp , "%s_%s" , msr -> txcfg -> webappid , col_name );
1568
+ }
1569
+
1564
1570
/* Locate the collection. */
1565
1571
if (strcasecmp (col_name , "tx" ) == 0 ) { /* Special case for TX variables. */
1566
1572
target_col = msr -> tx_vars ;
1567
1573
} else {
1568
1574
target_col = (apr_table_t * )apr_table_get (msr -> collections , col_name );
1569
- if (target_col == NULL ) {
1570
- if (msr -> txcfg -> debuglog_level >= 3 ) {
1571
- msr_log (msr , 3 , "Could not set variable \"%s.%s\" as the collection does not exist." ,
1572
- log_escape (msr -> mp , col_name ), log_escape (msr -> mp , var_name ));
1573
- }
1575
+ }
1574
1576
1575
- return 0 ;
1577
+
1578
+ if (target_col == NULL ) {
1579
+ if (msr -> txcfg -> debuglog_level >= 3 ) {
1580
+ msr_log (msr , 3 , "Could not set variable \"%s.%s\" as the collection does not exist." ,
1581
+ log_escape (msr -> mp , col_name ), log_escape (msr -> mp , var_name ));
1576
1582
}
1583
+
1584
+ return 0 ;
1577
1585
}
1578
1586
1579
1587
if (is_negated ) {
@@ -1616,7 +1624,11 @@ apr_status_t msre_action_setvar_execute(modsec_rec *msr, apr_pool_t *mptmp,
1616
1624
}
1617
1625
1618
1626
/* Record the original value before we change it */
1619
- collection_original_setvar (msr , col_name , rec );
1627
+ if (real_col_name == NULL ) {
1628
+ collection_original_setvar (msr , col_name , rec );
1629
+ } else {
1630
+ collection_original_setvar (msr , real_col_name , rec );
1631
+ }
1620
1632
1621
1633
/* Expand values in value */
1622
1634
val -> value = var_value ;
@@ -1651,6 +1663,7 @@ apr_status_t msre_action_setvar_execute(modsec_rec *msr, apr_pool_t *mptmp,
1651
1663
var -> value = apr_pstrdup (msr -> mp , var_value );
1652
1664
var -> value_len = strlen (var -> value );
1653
1665
expand_macros (msr , var , rule , mptmp );
1666
+
1654
1667
apr_table_setn (target_col , var -> name , (void * )var );
1655
1668
1656
1669
if (msr -> txcfg -> debuglog_level >= 9 ) {
@@ -2048,7 +2061,11 @@ static apr_status_t init_collection(modsec_rec *msr, const char *real_col_name,
2048
2061
/* Record the original counter value before we change it */
2049
2062
var = (msc_string * )apr_table_get (table , "UPDATE_COUNTER" );
2050
2063
if (var != NULL ) {
2051
- collection_original_setvar (msr , col_name , var );
2064
+ if (real_col_name == NULL ) {
2065
+ collection_original_setvar (msr , col_name , var );
2066
+ } else {
2067
+ collection_original_setvar (msr , real_col_name , var );
2068
+ }
2052
2069
}
2053
2070
2054
2071
/* Add the collection to the list. */
0 commit comments