5854 Commits

Author SHA1 Message Date
Johan Wikman
6bcb3ce4dc Change capabilities to uint64_t
- Since the capabilities are a bitmask, it is better if an unsigned
  integral type is used.
- Since the function is part of an ABI, it is better if an explicit
  size is used.
- 64-bits so that there also is room for independent filter
  capabilities.
2016-10-20 20:14:59 +03:00
Markus Makela
d938f0e72f Add custom cache directory for MySQLAuth
The MySQLAuth authenticator can now store the cached credentials in a
custom location. This is intended for the binlogrouter, which currently
uses a different location for the user cache.

The MySQL authentication modules now have their own document in the
Authenticators directory. Right now this document only describes the
general details of the MySQL authentication and the new option.
2016-10-20 09:26:54 +03:00
Johan Wikman
21094fb0cb Prefer so-version of Jansson library 2016-10-19 11:32:02 +03:00
Johan Wikman
348143eb6c Remove too aggressive assert 2016-10-19 11:00:26 +03:00
Markus Makela
48b1583830 Add FindJansson.cmake
Added find_package module for CMake which locates the Jansson libraries
and headers. This will make dependency checking easier and prevents build
failures due to missing dependencies.
2016-10-19 09:35:09 +03:00
Johan Wikman
e9f94dcd9d mysql_common.c and mysql_client.c astyled 2016-10-19 09:27:15 +03:00
Markus Makela
623acfe1b5 Build MaxScale in debug mode for Travis
The internal test set depends on SS_DEBUG being defined and it is only
defined for debug builds.
2016-10-18 21:58:59 +03:00
Markus Makela
7d202eb084 Fix Travis builds
The maxavro requires some special libraries which aren't always
available. For this reason, the maxavro library shouldn't be build unless
all libraries are available.
2016-10-18 21:40:59 +03:00
Markus Makela
891ce2d0e7 MXS-862: Move client information extraction to client protocol
The client protocol module now extracts the information that is relevant
for all modules. Currently this information consists of the client
capabilities, character set, username and default database.
2016-10-18 14:23:43 +03:00
Markus Makela
c0ad2936a4 MXS-862: Implement loadusers entry point
The GSSAPI client side authenticator now loads a list of users that are,
for the time being, logged at info level. The next step is to store this
information in the listener's user hashtable.
2016-10-18 14:23:43 +03:00
Johan Wikman
fe8ebda11e MXS-828: Log warning if both syslog and maxlog disabled
A warning is logged to stderr if both syslog and maxlog are
disabled. Earlier a note was unconditionally written to stdout
for each.
2016-10-17 14:02:16 +03:00
MassimilianoPinto
15de0a0fb3 COM_QUIT handler in binlog server now returns 1
COM_QUIT handler in binlog server now returns 1.
2016-10-17 12:16:47 +02:00
Johan Wikman
f0cf391c18 include/maxscale/gw.h removed.
In a subsequent change, the includes of server/core/*.c will be
cleaned up, and if there is a common set of include files, needed
by most, then a server/core/maxscale/core.h that includes those
will be introduced.
2016-10-17 12:17:09 +03:00
Johan Wikman
63b5c10f31 Move daemonize() to gateway.c
The one remaining function in gw_utils.c was moved to gateway.c,
so gw_utils.c could be removed.
2016-10-17 12:17:09 +03:00
Johan Wikman
e6d7ca4ed9 GW_NOINTR_CALL removed.
Used in just one place inside MaxScale so better to simply write
it explcitly.
2016-10-17 12:17:09 +03:00
Johan Wikman
b27774e674 Rename MAX_BUFFER_SIZE
MAX_BUFFER_SIZE, which is used for limiting the amount of the data
read from a socket renamed to MXS_MAX_NW_READ_BUFFER_SIZE and moved
from gw.h to limits.h.

Consider removing altogether. Difficult to justify since non-blocking
reads are used and the amount of available data is known.
2016-10-17 12:17:09 +03:00
Johan Wikman
8aafa34d66 Hard limits moved to limits.h
Limits used with SO_[RCV|SEND]BUF moved from gw.h to limits.h and
renamed so that the prefix is MXS_.
2016-10-17 10:11:13 +03:00
Johan Wikman
4faa7f8d21 Obsolete defines removed 2016-10-17 10:11:13 +03:00
Markus Makela
4cb6d9227e MXS-778: Set read-only masters into Slave status
When a master server is set into read-only mode, it can be treated as an
always up-to-date slave. This gives us a somewhat graceful way to prevent
writes to a master.

Usually setting the master into read-only mode is done before a change in
the replication topology to prevent stray writes arriving on the
master. MaxScale should respect the read-only mode and not send any writes
to a server that's in read-only mode.
2016-10-17 10:03:25 +03:00
Johan Wikman
d5cf74bd24 Cleanup gw.h, part 1.
Gw.h contained a fair amount of obsolete function declarations,
duplicate declarations of functions declared in utils.h and
declarations of functions that conceptually are similar to those
in utils.h.

The obsolete and duplicate ones were removed and all but one of
the remaining moved to utils.h. Correspondingly the implementation
was moved from gw_utils.c to utils.c.

The one remaining function - gw_daemonize() - is not really worthy
of a file of its own, so that is to be moved to gateway.c after which
gw_utils.c can be removed.

Gw.h still contains defines that are duplicated in
maxscale/protocol/mysql.h. The ones in gw.h are to be removed. It
appears that the entire gw.h will disappear.
2016-10-15 11:18:14 +03:00
Johan Wikman
1333da0712 Remove skygw_utils.h
The general purpose stuff in skygw_utils.h was moved to utils.h
and the corresponding implementation from skygw_utils.cc to utils.c.
Includes updated accordingly.

Skygw_utils.h is now only used by log_manager and by mlist, which
is only used by log_manager. Consequently, skygw_utils.h was moved
to server/maxscale.

Utils.h needs a separate overhaul.
2016-10-14 19:50:54 +03:00
Markus Makela
571919264f MXS-862: Make packet sequence handling automatic
Made the packet sequence number handling automatic so that it always uses
the correct one.

All functions now have documentation in them. Cleaned up code and added
comments to GSSAPI code.
2016-10-14 18:25:38 +03:00
Johan Wikman
68e53567a0 Make mlist.h private
Mlist is only used by log_manager so for the time being it is moved
under server/core/maxscale. Eventually it may be included in log_manager
itself.
2016-10-14 15:55:33 +03:00
Johan Wikman
cd26c69ffb Remove slist
Not used by anybody, so better to remove it.
2016-10-14 15:52:27 +03:00
Johan Wikman
03dbc6df80 Remove dependency on skygw_utils.h
- STRERROR_BUFLEN moved to cdefs.h and renamed to MXS_STRERROR_BUFLEN.
  Better would be to provide a 'const char* mxs_strerror(int errno)'
  that would have a thread specific buffer for the error message.
- MIN and MAX also moved to defs.h as MXS_MIN and MXS_MAX.
- Now only mlist.h of the headers depend upon skygw_utils.h.
2016-10-14 15:42:02 +03:00
Johan Wikman
bff2cfb7e5 Remove skygw_types.h
Some stuff moved to maxscale/utils.h. Further cleanup still needed.
2016-10-14 14:24:31 +03:00
Johan Wikman
0800bf4a59 Rename skygw_debug.h to debug.h
Also remove unneded includes in debug.h
2016-10-14 13:48:10 +03:00
Johan Wikman
c03b8079fd Move @file comment
Where it exists, the @file comment has now been moved to be
consistently right after the license blurb.
2016-10-14 13:20:52 +03:00
Johan Wikman
1a978be6b6 Cleanup header files
- All now include maxscale/cdefs.h as the very first file.
- MXS_[BEGIN|END]_DECLS added to all C-headers.
  Strictly speaking not necessary for private headers, but
  does not hurt either.
- Include guards moved to the very top of the file.
- #pragma once added.
2016-10-14 11:54:37 +03:00
Johan Wikman
dc1f599b49 Add maxscale/cdefs.h
The purpose of this file is to provide a header that *must* be included
first (that is, also before any system headers) by all other headers. On
the one hand this file provides a place where compilation environment
dependent things can be defined, and, on the other hand, a place where
things can be redefined globally, should that be necessary for whatever
reason. It further provides a place where constants applicable across
the line can be defined.
2016-10-14 10:10:00 +03:00
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