4334 Commits

Author SHA1 Message Date
Markus Mäkelä
4d561c5f6a Detect password usage based on token length
The client protocol module can resolve whether a password was used based
on the information the authenticators gather before authentication is
done. It uses the authentication token length as the basis on which it
makes the decision.
2017-03-13 19:42:38 +02:00
Markus Mäkelä
9c325104b7 Use correct size for snprintf
The mysql authenticator used the size of the pointer for the snprintf size
parameter instead of the actual size of the destination buffer.
2017-03-13 10:45:56 +02:00
Markus Mäkelä
086650bb4d Fix loading of users from multiple servers
The users were deleted before each individual server was queried. This
caused authentication to fail if the authentication data was loaded from
multiple servers.
2017-03-13 10:45:56 +02:00
Markus Mäkelä
e8ef701409 Combine socket creation code
The client connection and the server listener sockets used largely similar
code. Combining them allows for simpler protocol code.

Cleaned up parts of the DCB listener creation and moved the parsing of the
network binding configuration to a higher level.
2017-03-13 10:45:56 +02:00
Markus Mäkelä
7bc47fd5a4 Return the localhost_match_wildcard_host warning
When a local address is used which could match the wildcard host, a
warning is again logged.
2017-03-13 10:45:56 +02:00
Markus Mäkelä
ea55667096 Add back the missing netmask handling code
The netmask code was mistakenly removed when the authentication was moved
to the SQLite based system.
2017-03-13 10:45:56 +02:00
Markus Mäkelä
d88d02ee95 Fix namedserverfilter source parameter
The `source` parameter was broken by the IPv6 change. Now the filter no
longer uses functions from the core to resolve the network addresses.
2017-03-13 10:45:55 +02:00
Markus Mäkelä
894679d611 Fix hostname resolution in MySQLAuth
The hostname resolution was broken by the move to IPv6.
2017-03-13 10:45:55 +02:00
Markus Mäkelä
66ba7f3c80 Simplify network socket creation code
The socket creation code in mysql_backend.c wasn't MySQL specific and it
could be used for all non-blocking network connections. Thus, it makes
sense to move it to a common file where other protocol modules can use
it.

The address resolution code now uses `getaddrinfo` to resolve all
addresses instead of manually handling wildcard hosts. This allows the
same code to be used for all addresses.
2017-03-13 10:45:55 +02:00
Markus Mäkelä
37dd561470 Add support for IPv6
Both the listeners and servers now support IPv6 addresses.

The namedserverfilter does not yet use the new structures and needs to be
fixed in a following commit.
2017-03-13 10:45:55 +02:00
Johan Wikman
82247f9143 Add mxs_strerror
Thread-safe version of strerror; thread local buffer used for storing
the message. The performance penalty of a thread local buffer is not
likely to be significant, since this is only called in an error
situation that anyway is likely to interrupt the normal processing.
2017-03-13 10:45:55 +02:00
Markus Mäkelä
405b944abb Use on-disk database for MySQLAuth users
The SQLite database is now always created on disk. This will remove the
need to dump the database users from the in-memory database to the
persisted on-disk database.

This change will also make the authentication compatible with older SQLite
implementations which lack the URI-based database strings found in newer
versions.
2017-03-13 10:45:55 +02:00
Markus Mäkelä
71b3ee70a4 Fix empty password detection
If a user was defined without a password, the authentication would fail.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
adb9b5049b Fix user cache directory permissions
The user cache directory is only used by the maxscale user so only the
maxscale user should have access to it.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
b796967df8 Add diagnostic entry point to authenticators
The authenticators should have a similar way to print diagnostic
information as filter and routers do. This allows the authenticators to
print the users in their own format.

In the future, all the diagnostic entry points should be changed so that
they return a structure that contains the information in a standard
form. This information can then be formatted in different ways by other
modules.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
f225b29756 Fix injection of service user
The parameters that were given to the user creation function were in the
wrong order.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
2dd79e2e0c Make sure user cache directory exists
The cache directory needs to be created by the authenticator itself.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
a3a2a24c97 Return correct value for failed db authentication
The unknown database error was never triggered as all authentication
errors returned MXS_AUTH_FAILED.
2017-03-13 10:45:54 +02:00
Markus Mäkelä
b2c018a986 Don't users with a pre-4.1 password
The old error message and behavior was lost with the new implementation.
2017-03-13 10:45:53 +02:00
Markus Mäkelä
5494b262d3 Reorder SQL statements when persisting users
The statements are now executed in a more controlled order and a failure
of one will skip the others. The transaction is also rolled back if it
fails.
2017-03-13 10:45:53 +02:00
Markus Mäkelä
0488f8a052 Fix enable_root_user
The option was inverted.
2017-03-13 10:45:53 +02:00
Markus Mäkelä
04899f3a3e Remove unused code from MySQLAuth
Removed the old implementation of MySQL authentication. The user printing
functionality still expects a hashtable which should be fixed.
2017-03-13 10:45:53 +02:00
Markus Mäkelä
b206300975 Exact hostnames grants take precedence over wildcard grants
MariaDB and others match grants first by exact hostname/IP and then by
wildcard. If there are no exact matches, the wildcard grant should be
picked. This can be tested by having different passwords for localhost and
remote address.

The SQLite based authentication should first check for an exact match and
then only after that should it try to match the hostname to a wildcard
grant.
2017-03-13 10:45:53 +02:00
Markus Mäkelä
ba16b8ca1c Fix memory leak in dbusers.c
The MySQL connection was created twice.
2017-03-13 10:45:52 +02:00
Markus Mäkelä
b376d9043a Use new authentication for reauthentication
This fixes the reauthentication of users that was missing from the new
implementation. Now COM_CHANGE_USER should work properly.
2017-03-13 10:45:52 +02:00
Markus Mäkelä
48d70fa4a8 Replace get_users implementation with new version
The get_users function now combines the functionality of the old get_users
and get_all_users. This removes large parts of similar code.

Removed the listener resources as MySQLAuth was the only one that used it.
2017-03-13 10:45:52 +02:00
Markus Mäkelä
62763e2505 Store SQLite tables on disk
The SQLite database users are cached on disk. This allows the binlogrouter
to authenticate users without a connection to the master server.
2017-03-13 10:45:52 +02:00
Markus Mäkelä
2f4df0c21e Store databases in the SQLite database
The databases are now also stored in the sqlite database. This allows the
`resource` member of the USERS struct to be removed in the future.
2017-03-13 10:45:51 +02:00
Markus Mäkelä
041c0f1f2d Use SQLite3 based authentication
The user data is now stored inside a SQLite3 database. By storing the data
inside a database, we remove the restriction that the previous hashtable
based implementation had.
2017-03-13 10:45:51 +02:00
Markus Mäkelä
d4a06c61de Move reauthentication to authenticators
Currently the only situation where a user needs to be authenticated after
the initial authentication is when a COM_CHANGE_USER is being
executed. This was previously handled by directly calling a function in
the MySQLAuth authenticator.

The new entry in the API of the authenticators is very specific to MySQL
and should be reviewed once other protocols are added.
2017-03-13 10:45:51 +02:00
Markus Mäkelä
6da8cfe97e Fix assignment of master status on failed servers
When the real root master server went down, it still received the master
status bit due to how the replication tree was built. The bit should only
be set for servers that are running.

Also fixed a false state change event when the master status bit was
manually cleared from the downed root master server.
2017-03-12 09:40:21 +02:00
Markus Mäkelä
41ff01d16d Merge branch '2.0' into 2.1 2017-03-09 10:01:38 +02:00
Johan Wikman
d82f4ad6dc Prevent ignoring return value error
When strtol[l] is used for verifying that a string represents a
number, we are not interested in the actual value.
2017-03-09 09:46:38 +02:00
Timofey Turenko
84a6848f10 Add build information to --version-full
If the Jenkins build information is available, print it in the full
version output.
2017-03-09 09:32:37 +02:00
Markus Mäkelä
d764bb9e1f MXS-1178: Fix master_accept_reads
The order of the servers in the service definition could break the
master_accept_reads functionality.

When the first server defined in the service is a slave, it will always be
picked as the first candidate for reads. The master would only be
considered as a candidate for reads if no previous candidate was
available. For this reason, the master_accept_reads only worked when the
first server in the list was the master.
2017-03-09 07:45:29 +02:00
Markus Mäkelä
fd2df3a863 Always open files with configured block size
If the Avro file already exists, it should be opened with the configured
block size instead of the default block size of 16 kilobytes.
2017-03-08 20:03:45 +02:00
Markus Mäkelä
c18f94b31b Get socket family from struct sockaddr_storage
The struct sockaddr_storage has a member variable that tells the socket
family.
2017-03-08 17:04:14 +02:00
Johan Wikman
b1521e0545 Log the use of prepared statements
If cache decisions should be logged, we log the presence of
prepared statements as they currently are the primary source
for the cache not caching.
2017-03-07 15:45:29 +02:00
Esa Korhonen
a7379d7ae2 MXS-1165 MaxInfo endless loop
If one queried in MySQL MaxInfo 'show sessions' or 'show clients',
MaxScale would go in an endless loop and finally crash when memory
ran out. The reason is the rather confusing callback-based dcb-
iterating code. Adding one line fixes the issue, although the iteration
is still rather awkward with calling dcb_foreach for every session/
client.
2017-03-07 10:42:48 +02:00
Markus Mäkelä
b4d81ffe27 Use correct capability for schemarouter
The router should use RCAP_TYPE_CONTIGUOUS_INPUT as it parses the
statements.
2017-03-06 16:35:17 +02:00
Markus Mäkelä
e7b5731976 Fix internal test suite
Two of the tests didn't initialize the random number generator.
2017-03-06 11:06:33 +02:00
Markus Mäkelä
bb22b82461 Merge branch '2.0' into 2.1 2017-03-06 10:38:07 +02:00
Markus Mäkelä
f2fc9b9d9f Add workaround for null value handling in Avro C API
The Avro C API fails to write bytes of size zero. A workaround is to write
a single zero byte for each NULL field of type bytes.

Also added an option to configure the Avro block size in case very large
records are written.
2017-03-04 10:12:18 +02:00
Markus Mäkelä
09df0acb00 Fix binlog rotation detection
The rotations of binlogs weren't detected as the file names weren't
compared.

Moved the indexing of the binlogs to the end of the binlog
processing. This way the files can be flushed multiple times before they
are indexed.
2017-03-04 00:31:07 +02:00
Markus Mäkelä
dadc0d6a9d Fix DATETIME and BLOB processing
The old DATETIME format wasn't processed properly which caused a
corruption of following events.

A BLOB type value could be non-NULL but still have no data. In this case,
the value should be stored as a null Avro value.
2017-03-04 00:26:51 +02:00
Markus Mäkelä
916cb4df08 Rename failover and failover_recovery
The names of the parameters were misleading as MaxScale doesn't perform
the actual failover but only detects if one has been done.
2017-03-03 18:45:20 +02:00
Markus Mäkelä
09ef292283 Update dbfwfilter build configuration
The filter now uses a more recent syntax to declare the function name
prefixes. This removes a build warning.
2017-03-03 18:44:58 +02:00
Johan Wikman
76e56a2688 Perform SSL cleanup 2017-03-03 13:28:27 +02:00
Esa Korhonen
7b67cfd1ef Variables written to in signal handlers should be volatile 2017-03-03 09:41:56 +02:00
Markus Mäkelä
789c14197d Merge branch '2.0' into 2.1 2017-03-02 14:05:42 +02:00