5824 Commits

Author SHA1 Message Date
Johan Wikman
2fe58ebe5b Move test_utils.h to server/core/test 2016-10-13 22:59:39 +03:00
Johan Wikman
d04cb54b9f maxscale/maxscale_pcre2.h renamed to maxscale/pcre2.h 2016-10-13 22:59:39 +03:00
Johan Wikman
76430e060f maxconfig.h renamed to config.h 2016-10-13 22:59:39 +03:00
Johan Wikman
3a18b64bdd mysql_client_server_protocol.h moved.
Moved to include/maxscale/protocol/mysql.h
2016-10-13 22:59:39 +03:00
Johan Wikman
485675d065 Duplicate declarations removed
Duplicate declarations of functions declared in maxscale/users.h
and maxscale/gw.h removed and corresponding includes added instead.
Unimplemented declaration removed.

Further cleanup will be needed to ensure that functions etc. are
declared in the right place.
2016-10-13 22:59:39 +03:00
Johan Wikman
c433d11b39 Module private headers moved to modules 2016-10-13 22:59:39 +03:00
Markus Makela
1895c04fc6 Fix luafilter build failure
The luafilter included a non-existent header file <maxscale/string.h> when
it needed <string.h>.
2016-10-13 22:33:03 +03:00
Markus Makela
840575d1dc MXS-862: Add FindGSSAPI.cmake and missing includes
Added FindGSSAPI.cmake which allows the modules to be built only if the
libraries are found.

The log manager header was not included by the GSSAPI modules.
2016-10-13 16:30:56 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00
Johan Wikman
ef5bbd9353 Remove trailing NULLs from throttling message 2016-10-13 16:04:27 +03:00
Markus Makela
db4b6793c4 MXS-862: Add authenticator documentation
The authentication process in MaxScale is now described in
Authentication-Modules.md. The GSSAPI authenticator also has its own
document.
2016-10-13 15:58:21 +03:00
Markus Makela
4a4c65577c MXS-862: Add initialize entry point to GSSAPIAuth
The GSSAPIAuth module now creates an instance and stores the configured
service principal name there.
2016-10-13 15:58:21 +03:00
Markus Makela
9d8c5cd410 MXS-862: Add authenticator options and instances
Authenticators now have a similar mechanism to the `router_options`
parameter which enables configurable authentication.

The authenticators also have a new initialize entry point which is similar
to the createInstance entry point of the filters and routers. The value of
`authenticator_options` is passed as a parameter to this function. The
return vaulue of the `initialize` entry point is passed to the `create`
entry point.
2016-10-13 15:58:18 +03:00
Markus Makela
a2a8562c39 MXS-862: Implement GSSAPI backend authentication
The GSSAPI backend authentication is based on tokens.  The server first
sends the service principal name which is used for token generation. The
client then retrieves a token from the GSSAPI server which it sends to the
backend server. If the server can verify the authenticity of the token,
authentication is successful.

This module can be used with both GSSAPIAuth and MySQLAuth modules.
2016-10-13 15:51:54 +03:00
Markus Makela
5d96faedd8 MXS-862: Move sending of OK packet to mysql_client
Moving the sending of the final OK packet of the authentication process to
the client protocol plugin makes the authentication plugins simpler.

By reading the client's sequence and incrementing that by one, the client
protocol module will always send the correct sequence byte in the final OK
packet.
2016-10-13 15:51:53 +03:00
Markus Makela
239b53e156 MXS-862: Do first part of authentication in MySQLBackend
The first message exchange between the server and the client will almost
always contain the same data. If the server is going to change
authentication methods, it will send an AuthSwitchRequest packet instead
of the OK/ERR packet that it would normally send. Only after this point
the authenticator modules actually need to do something.

In the case of the default 'mysql_native_password' plugin, the only thing
that the plugin needs to do is to check whether the server responded with
an OK packet.
2016-10-13 15:51:53 +03:00
Markus Makela
cb7c112764 MXS-862: Create common MySQL library
The MySQLCommon library contains functions used by both the protocol and
authenticator modules. The contents of the modutil.c file could also be
moved to this file if the functions in that file are only used by modules
and not the core.
2016-10-13 15:51:52 +03:00
Markus Makela
d87f15b7f6 MXS-862: Add client side GSSAPI authenticator
Initial implementation of the client side GSSAPI authenticator. The
current version successfully authenticates clients using the same style as
the MariaDB GSSAPI plugin does. Currently, it is not possible to acutally
use the plugin as the backend server would require the matchig GSSAPI
plugin.

Also added skeleton code for the backend GSSAPI authenticator. It only
implements the required entry points and sends the client auth packet to
the backend.
2016-10-13 15:51:51 +03:00
Markus Makela
dfeb5c46c9 MXS-862: Add create/destroy and remove plugin_name entry points
The create and destroy entry points allow authenticators to store data in
the DCB. This data is not shared by other DCBs related to the same
session.

The plugin_name entry point wasn't really useful as the plugins would
still need to send a AuthSwitchRequest packet if they wanted to change the
authentication mechanism.
2016-10-13 15:51:51 +03:00
Markus Makela
829d5a7453 Send COM_QUIT to backends if persistent connections are disabled
The COM_QUIT packets should be sent to the backends if persistent
connections aren't used. This allows for a controlled shutdown of the
connections on both ends even if the client closes the connection before
all backends have authenticated.
2016-10-13 15:51:51 +03:00
Markus Makela
6d057f8152 MXS-862: Move backend authentication from MySQLBackend to MySQLBackendAuth
The authentication for backend connections is now done in the
MySQLBackendAuth module. This is also the default authentication module
for backend connections created by MySQLBackend.
2016-10-13 15:51:51 +03:00
Markus Makela
35d9b35609 MXS-862: Refactor backend authentication handling
The backend responses are now read in one place and the functions just
read the data. The protocol level will now handle the packet gathering
process and the authentication part just inspects the data.

Backend connections now load authenticators when they are being
connected. In the future, this enables the use of authentication modules
for backend connection.
2016-10-13 15:51:50 +03:00
Markus Makela
cd11971d5d Log more precise DCB write error messages
The DCB error messages now log the type of the DCB and the remote address
in addition to the system error message. The file descriptor and memory
address are no longer printed in the error message as they are not useful
to the end user. The fd and address are now logged at debug level with a
more verbose error message.
2016-10-13 15:51:50 +03:00
Markus Makela
53f01106aa Always try to build CDC modules
The CDC protocol, authentication and router modules should be build if the
required libraries are found.
2016-10-11 20:37:49 +03:00
Johan Wikman
7e058a327f Add test for cache use-rule parsing 2016-10-11 19:56:01 +03:00
Johan Wikman
4a7040c308 MXS-879: Match users properly.
If account wildcards - % - are used, the string is changed
into a pcre regular expressions and compared using that.
2016-10-11 19:55:29 +03:00
Johan Wikman
69cf3cf93a Extend error message when query cannot be parsed 2016-10-11 19:55:29 +03:00
Markus Makela
2fb9e99549 Add missing license blurbs
Some file were missing the license blurb at the top of the file.
2016-10-07 09:33:17 +03:00
Markus Makela
9b2209a8d1 Log only one warning when failover is initiated
Mysqlmon would log a warning at every monitoring interval when failover
was initiated.
2016-10-06 16:53:37 +03:00
Johan Wikman
56f0edb247 Cache: Add possibility to parse rules from string
To be used in test program.
2016-10-06 14:58:42 +03:00
Markus Makela
81fa8c6c0c Assign master status immediately to the replacement master
As the failover status check is done after the pending status has been
moved to the current status, the do_failover should set the current status
of the server as Master.
2016-10-06 14:30:02 +03:00
Johan Wikman
84cadd4c45 Slightly adjust the semi-sync documentation 2016-10-05 15:58:34 +03:00
Markus Makela
e54c40ca7b Merge branch 'pull-102' into develop 2016-10-05 10:00:09 +03:00
Markus Makela
cc01ce5c16 Remove obsolete parts from testlog.c
The code used the log manager in the wrong way which caused the test to
hang from time to time.
2016-10-03 15:40:49 +03:00
Markus Makela
fbf5c331f1 Merge branch '2.0.1' into develop 2016-10-03 15:21:04 +03:00
Johan Wikman
b42231e5d4 storage_rocksdb: Clearer error when db in use 2016-09-30 12:45:02 +03:00
Johan Wikman
45073ebd73 cache: Pick out default db when connecting with database 2016-09-30 11:32:38 +03:00
Johan Wikman
91759ef323 Use MXS_ALERT when logging the stack of a crash
As MXS_ERROR is throttled you'd risk missing some part of the stack.
2016-09-30 10:48:04 +03:00
Johan Wikman
93b755fc33 Add MXS_ALERT
As errors and warnings are throttled, there is a need for being able
to log severe errors without ever having them throttled (e.g. when
logging the stack in conjunction with a crash).

MXS_ALERT should only be used in a context where the process is known
to be going down, either via crash or explicit exit.
2016-09-30 10:44:59 +03:00
Johan Wikman
fa2a667195 qc_sqlite: Handle a name like ``a. 2016-09-29 23:48:21 +03:00
Johan Wikman
ca76cb1576 qc_sqlite: Recognize backslash as escape character
Without this change, e.g.

    insert into t1 values('\'');

causes a buffer overflow and crash.
2016-09-29 22:50:18 +03:00
Markus Makela
4658a28965 Fix out of bounds read in avro_client_process_command
When the last transaction was queried, it caused an out of bounds read
when strstr was used on the raw data of a GWBUF.
2016-09-29 15:28:57 +03:00
Markus Makela
dcf55d4099 Fix possible out of bounds read in CDCPlainAuth
When the authentication string was decoded from hexadecimal to binary, it
was possible that an out of bounds read was done if the length of the data
was not an even number.
2016-09-29 14:57:44 +03:00
Johan Wikman
087338910e storage_rocksdb: Store version to database
The storage_rocksdb version is now stored to the database. That will
ensure that should the format (key content, length, etc.) change, we
can will detect whether a database is too old and take action.
2016-09-29 14:06:23 +03:00
Johan Wikman
b9c956dda9 cache: Include the databases in the key
The databases targeted by a query are now included in the key.
That way, two identical queries targeting a different default
database will not clash.
Further, it will mean that queries targeting the same databases
are stored near each other, which is good for the performance.
2016-09-29 11:28:01 +03:00
Johan Wikman
7732070546 cache: Add 'use' rules handling
Currently onyl the user name is matched, eventually it should
probably be possible to indicate the network as well, or only
the network.
2016-09-29 11:26:12 +03:00
Johan Wikman
3d5cfee348 housekeeper: Copy data to prevent access of freed data 2016-09-29 09:34:54 +03:00
Johan Wikman
0478c3cc83 cache: Add table and query matching 2016-09-28 19:38:11 +03:00
Johan Wikman
7f24f12cfc cache: Update documentation and add rule handling
The concept of 'allowed_references' was removed from the
documentation and the code. Now that COM_INIT_DB is tracked,
we will always know what the default database is and hence
we can create a cache key that distinguises between identical
queries targeting different default database (that is not
implemented yet in this change).

The rules for the cache is expressed using a JSON object.
There are two decisions to be made; when to store data to the
cache and when to use data from the cache. The latter is
obviously dependent on the former.

In this change, the 'store' handling is implemented; 'use'
handling will be in a subsequent change.
2016-09-28 19:38:11 +03:00
Johan Wikman
20b57b1577 cache: Remove default db only is use db succeeds 2016-09-28 19:38:11 +03:00