MXS-1346: Fix rule handling
The call to update_rules is needed before each query to make sure that the rules are up to date. The check whether the rule was active was inverted.
This commit is contained in:
@ -1051,6 +1051,24 @@ bool replace_rules(Dbfw* instance)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool update_rules(Dbfw* my_instance)
|
||||||
|
{
|
||||||
|
bool rval = true;
|
||||||
|
int rule_version = my_instance->get_rule_version();
|
||||||
|
|
||||||
|
if (this_thread.rule_version < rule_version)
|
||||||
|
{
|
||||||
|
if (!replace_rules(my_instance))
|
||||||
|
{
|
||||||
|
rval = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this_thread.rule_version = rule_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
Dbfw::Dbfw(MXS_CONFIG_PARAMETER* params):
|
Dbfw::Dbfw(MXS_CONFIG_PARAMETER* params):
|
||||||
m_action((enum fw_actions)config_get_enum(params, "action", action_values)),
|
m_action((enum fw_actions)config_get_enum(params, "action", action_values)),
|
||||||
m_log_match(0),
|
m_log_match(0),
|
||||||
@ -1295,6 +1313,11 @@ int DbfwSession::routeQuery(GWBUF* buffer)
|
|||||||
int rval = 0;
|
int rval = 0;
|
||||||
uint32_t type = 0;
|
uint32_t type = 0;
|
||||||
|
|
||||||
|
if (!update_rules(m_instance))
|
||||||
|
{
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
if (modutil_is_SQL(buffer) || modutil_is_SQL_prepare(buffer))
|
if (modutil_is_SQL(buffer) || modutil_is_SQL_prepare(buffer))
|
||||||
{
|
{
|
||||||
type = qc_get_type_mask(buffer);
|
type = qc_get_type_mask(buffer);
|
||||||
@ -1567,24 +1590,6 @@ bool rule_matches(Dbfw* my_instance,
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool update_rules(Dbfw* my_instance)
|
|
||||||
{
|
|
||||||
bool rval = true;
|
|
||||||
int rule_version = my_instance->get_rule_version();
|
|
||||||
|
|
||||||
if (this_thread.rule_version < rule_version)
|
|
||||||
{
|
|
||||||
if (!replace_rules(my_instance))
|
|
||||||
{
|
|
||||||
rval = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this_thread.rule_version = rule_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostics routine
|
* Diagnostics routine
|
||||||
*
|
*
|
||||||
|
@ -127,7 +127,7 @@ bool User::do_match(Dbfw* my_instance, DbfwSession* my_session,
|
|||||||
rval = true;
|
rval = true;
|
||||||
for (RuleList::iterator it = rules.begin(); it != rules.end(); it++)
|
for (RuleList::iterator it = rules.begin(); it != rules.end(); it++)
|
||||||
{
|
{
|
||||||
if (!rule_is_active(*it))
|
if (rule_is_active(*it))
|
||||||
{
|
{
|
||||||
have_active_rule = true;
|
have_active_rule = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user