Merge branch '2.2' into develop

This commit is contained in:
Johan Wikman
2018-03-26 10:03:20 +03:00
11 changed files with 163 additions and 142 deletions

View File

@ -1,10 +1,12 @@
find_package(Lua)
if(LUA_FOUND)
include_directories(${LUA_INCLUDE_DIR})
add_library(luafilter SHARED luafilter.c)
set_target_properties(luafilter PROPERTIES VERSION "1.0.0")
target_link_libraries(luafilter maxscale-common ${LUA_LIBRARIES})
install_module(luafilter experimental)
else()
message(STATUS "Lua was not found, luafilter will not be built.")
if (BUILD_LUAFILTER)
find_package(Lua)
if(LUA_FOUND)
include_directories(${LUA_INCLUDE_DIR})
add_library(luafilter SHARED luafilter.c)
set_target_properties(luafilter PROPERTIES VERSION "1.0.0")
target_link_libraries(luafilter maxscale-common ${LUA_LIBRARIES})
install_module(luafilter experimental)
else()
message(STATUS "Lua was not found, luafilter will not be built.")
endif()
endif()

View File

@ -1071,10 +1071,18 @@ bool MaskingRules::Rule::matches(const ComQueryResponse::ColumnDef& column_def,
const char* zUser,
const char* zHost) const
{
const LEncString& table = column_def.org_table();
const LEncString& database = column_def.schema();
// If the resultset does not contain table and database names, as will
// be the case in e.g. "SELECT * FROM table UNION SELECT * FROM table",
// we consider it a match if a table or database have been provided.
// Otherwise it would be easy to bypass a table/database rule.
bool match =
(m_column == column_def.org_name()) &&
(m_table.empty() || (m_table == column_def.org_table())) &&
(m_database.empty() || (m_database == column_def.schema()));
(m_table.empty() || table.empty() || (m_table == table)) &&
(m_database.empty() || database.empty() || (m_database == database));
if (match)
{

View File

@ -284,6 +284,14 @@ public:
return m_length;
}
/**
* @return True if the string is empty, false otherwise.
*/
bool empty() const
{
return m_length == 0;
}
/**
* Compare for equality.
*