367 Commits

Author SHA1 Message Date
Markus Makela
d3da98b58f Merge branch 'MXS-544' into develop-MXS-544-merge 2016-03-03 21:39:39 +02:00
Markus Makela
1a2bd8b234 Added FindLua.cmake from KitWare's repo for CMake 3.4.3
Some platforms did not have the FindLua.cmake file which caused errors on
configuration. Moved the invocation of find_package to the filter CMakeLists.txt
so that it is only called if the luafilter is built.
2016-03-03 16:42:48 +02:00
Markus Makela
e1a8a6f373 Luafilter is not built by default
The luafilter requires the lua development libraries so it isn't built
by default.
2016-03-02 13:37:00 +02:00
Markus Makela
b2742f02b9 More formatting of code
Code formatting.
2016-03-02 13:28:12 +02:00
Markus Makela
2204a245c9 General cleaning up of the luafilter
Renamed variables to make their use more clear and cmake now looks for the Lua
libraries.
2016-03-02 13:28:12 +02:00
Markus Makela
140d284eed Updated documentation for luafilter
Added more documentation to functions about how, when and with what parameters
the Lua functions are called with. Also adjusted the module version to experimental.
2016-03-02 13:27:24 +02:00
Markus Makela
1c74ca0ec7 Cleaned up the luafilter. 2016-03-02 13:27:24 +02:00
Markus Makela
3f3c553736 Finalized query blocking. 2016-03-02 13:26:50 +02:00
Markus Makela
5d0f3eb467 Added a simple test for Lua return values from fuction calls. If the Lua function returns a string, the current query is replaced with it. 2016-03-02 13:26:50 +02:00
Markus Makela
7e24d4c88b Added missing calls to the global script 2016-03-02 13:26:49 +02:00
Markus Makela
61ec8458d3 Initial implementation of a Lua filter 2016-03-02 13:26:49 +02:00
Markus Makela
2a2fdb2cc6 testing of Lua 2016-03-02 13:26:10 +02:00
Johan Wikman
cb3213af63 server/include/poll.h renamed to server/include/maxscale/poll.h
Due to an include conflict between /usr/include/poll.h and
maxscale/server/include/poll.h the latter was moved to
maxscale/server/include/maxscale/poll.h.

Once 1.4 is out, all maxscale header files will be moved to that
same sub-directory. That will prevent include conflicts and also
make it easy to see which include files belong to maxscale and
which do not.
2016-03-01 12:56:39 +02:00
Markus Makela
2990c3b25f Fixed wrong variable being freed in qlafilter
The match parameter was freed twice.
2016-02-29 16:17:55 +02:00
Markus Makela
bf24f18805 Merge branch 'develop' into MXS-544 2016-02-29 10:40:33 +02:00
Markus Makela
87ccff097d Minor fix to token processing of dbfwfilter
The yylineno was manually simulated even though it can be automated by enabling
the yylineno option.
2016-02-26 12:30:56 +02:00
Markus Makela
784166ad0b Added missing check for fopen return value
This would have led to a crash when a NULL pointer would have been used as
a valid FILE handle.
2016-02-25 20:10:37 +02:00
Markus Makela
2c28d8c5de Removed unused functions and variables from dbfwfilter
Removed the old parsing functions which are no longer used.
2016-02-25 20:09:10 +02:00
Markus Makela
7b8200eec0 Fixed build failures with older versions of Bison
Older versions of Bison don't include the yyparse function in the generated
header and use deprecated options.
2016-02-25 09:32:04 +02:00
Markus Makela
57af3e3e24 Added support for older Bison versions
The older versions of Bison use the deprecated versions of various options.
The automatic prefixing of tokens is not present in older versions so to
accommodate for this, all tokens were manually prefixed.
2016-02-25 09:32:04 +02:00
Markus Makela
cb2e3b898e Cleaned up qlafilter, topfilter and namedserverfilter instance creation
The change fixes a crash when no filebase parameter is given for the filter.

The instance creation functions of these filters had spossible memory leaks in
case errors in the configuration occurred. In addition to these, they would be
successfully created even if unexpected parameters were given.
2016-02-23 21:45:31 +02:00
Markus Makela
aec1310c52 MXS-580: Added more options for filters
The tee, qlafilter, namedserverfilter and topfilter now support the same filter
options: case, ignorecase and extended. The extended filter option enables
the Extended Regular Expression syntax for the filters which is used when
matching queries.
2016-02-23 20:52:53 +02:00
Markus Makela
19356be848 Updated documentation about Bison and Flex dependency
The dbfwfilter now requires Bison and Flex to be built
2016-02-23 20:52:52 +02:00
counterpoint
395cbdc103 Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc. 2016-02-23 11:13:21 +00:00
Markus Makela
1adbe3b23a No user definitions in dbfwfilter rules is treated as an error again
The lack of user definition lines in the dbfwfilter rule file was ignored
previously but this change makes the lack of users an error again. Also
added function documentation to some of the functions.
2016-02-23 10:34:12 +02:00
Markus Makela
effa2dbdae Set dbfwfilter maturity to GA and set the version to 1.1.0
The module has been GA for a while and it has also changed so the version
should be updated.
2016-02-17 10:59:26 +02:00
Markus Makela
497a72d42f Added extra logging to dbfwfilter output
The real username and host is now logged in addition to the user definition
that it matched. The messages also have the service name to distinct
connections to two different services which both use the same filter.
2016-02-17 10:45:21 +02:00
Markus Makela
eaddc4ea9d Fixed dbfwfilter build failure on Ubuntu
The bison executable didn't generate the headers even though it was instructed
to generate them. This was caused by an older CMake version.
2016-02-09 16:35:51 +02:00
Markus Makela
9e33f300b0 Added flex/bison based parsing of rules to dbfwfilter
The dbfwfilter now uses flex to tokenize the rules and bison to process those
tokens into a language. This will make the syntax checks more robust and
the rule language easier to maintain. It also makes the processing of rules
easier to understand and removes most of the C language side checks for
correctness.

The old rule processing functions are still left intact and will be removed
at a later point.
2016-02-09 11:00:27 +02:00
Markus Makela
6055ba25bf Added logging of matching and non-matching queries to dbfwfilter
When configured to log matching queries, the dbfwfilter will log all queries
that match a rule. The rule name, user name and the query itself are logged.

It is also possible to match all queries that do not match a rule. Only the user
name and query is logged in this mode.
2016-02-09 11:00:27 +02:00
Markus Makela
5efd5d8927 Added user configurable actions to dbfwfilter
The dbfwfilter can now either allow, block or ignore queries that match the
configured rules.
2016-02-09 11:00:27 +02:00
Johan Wikman
4a4f22c9a7 Make query_classifier part of core.
The query classifier interface is now built as an integral
part of MaxScale core.
2016-02-08 11:44:07 +02:00
Johan Wikman
834d04ed6c Merge branch 'MXS-517' into develop 2016-02-08 11:03:31 +02:00
Markus Makela
0d51f78a2a Dbfwfilter now uses PCRE2 regular expressions
Switched from the POSIX regex implementation to PCRE2. This should improve the
filter's performance as well as make the code more manageable.
2016-02-02 12:38:44 +02:00
Markus Makela
7bac2f8fab Moved the applying of rules to users to its own function
This makes the function easier to understand as a whole.
2016-02-02 12:38:44 +02:00
Johan Wikman
fc6f49fe8a Link against Connector-C.
Now, qc_mysqlembedded is linked against MySQL's embedded library,
and MaxScale itself against Connector-C.

So, in order to build MaxScale, Connector-C must be installed.
This has been tested with Connector-C 2.2.1.

The build variable MYSQLCLIENT_LIBRARIES is no longer used.
2016-02-01 15:43:05 +02:00
Johan Wikman
42b1722e49 Make query classifier self-contained.
Only the query classifier needs the functionality of the embedded
server, while the rest of MaxScale is content with the client
library or Connector/C.

This have now been rearranged so that query-classifier links with
the embedded static library and then explicitly exports its own
functions using the query_classifier.map linker script. That way
query classifier will use the embedded library, while the rest of
maxscale use the client library, and this without conflicts.

Currently, query_classifier is not linked to maxscale-common,
but executables must link to maxscale-common and query_classifier.
2016-01-25 21:43:49 +02:00
Johan Wikman
1f241a5ed1 Rearrange libraries and build files.
This is the first change in an attempt to arrange the linking so that
more errors are detected at link-time.

- All files in server/core but for gateway.c are linked to one shared
  library called maxscale-common.
- The files log_manager/log_manager.cc and utils/skygw_utils.cc are
  built into maxscale-common as well.
- MaxScale itself consists now only of gateway.c and is linked with
  maxscale-common.
- All plugins link with maxscale-common.
- All executables link in addition with {EMBEDDED_LIB}.

After this change, the change (MXS-517) where query_classifier is the
only component that uses ${EMBEDDED_LIB} and the rest mysqlclient can
be made much cleaner.

After a few additional steps, all shared libraries can be linked with
the linker flags "-Wl,-z,defs", which directs the linker to resolve
all symbols. That will require that all shared libraries list all the
libraries they need, but will at the same time ensure that any
missing symbols are detected at link-time and not at run-time.
2016-01-22 23:26:17 +02:00
Markus Makela
a2bc15c870 Removed obsolete functions from dbfwfilter
The filter defined its own hashing and string comparison functions even though
there are common functions for both.
2016-01-15 16:22:18 +02:00
Markus Makela
0a3e6b4352 MXS-498: Username and source address added to QLA filter output
The filter now logs the username and remote address of each client. This will
make tracking of users and their queries a lot easier.
2016-01-12 09:30:03 +02:00
Johan Wikman
23a7562d3a Replace skygw_ type prefix with qc_.
- skygw_query_type_t renamed to qc_query_type_t.
- skygw_query_op_t renamed to qc_query_op_t.
2016-01-11 12:06:21 +02:00
Johan Wikman
2f42246880 Rename query classifier functions consistently.
All public query classifier functions now have the prefix qc_.
2016-01-11 12:04:52 +02:00
Johan Wikman
ec281849aa Remove explicit calls to parse_query.
Now that all query classifier functions parse the query if it
has not been parsed, there is no reason for any module to call
parse_query explicitly.
2016-01-11 10:15:13 +02:00
Johan Wikman
57b79fc663 Remove unecessary calls to query_is_parsed/parse_query.
query_classifier_get_operation() parsed the query if it has not
yet been parsed. In the other places, the query need not be
parsed.
2016-01-08 11:52:20 +02:00
Johan Wikman
97282fca97 Make lines of mqfilter.c less that 110 characters long.
Untabified as well.
2016-01-08 11:43:05 +02:00
Markus Makela
40cfe1a864 Merge branch 'release-1.3.0' into develop 2016-01-08 11:14:02 +02:00
Johan Wikman
2b83530ae9 Make dbfwfilter.c rows less than 110 character long. 2016-01-08 10:35:53 +02:00
Markus Makela
080a9ebc9d PCRE2 is now statically linked
Since the PCRE2 library was always going to be a part of MaxScale, there was
no real reason to have it as a shared library apart from smaller binaries.
2015-12-29 10:09:38 +02:00
Markus Makela
0cf564aa0d Fix to MXS-508: Fixed username matching in regexfilter
The username matching was working as intended but the session's active value
was ignored when queries were being routed. This meant that both the username
and the IP address of the user were ignored and query replacement was always
done.
2015-12-29 09:57:27 +02:00
Markus Makela
aff3f66fa6 Fixed compilation error for slavelag.c
There was an extra parenthesis left when skygw_log_write was changed to
MXS_ERROR which caused the compilation to fail.
2015-12-23 06:45:28 +02:00