From 558bd9279bf7c33651bf3baab0e47f2587b3b5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 16 Nov 2020 16:54:37 +0200 Subject: [PATCH 1/3] Use same script for both SSL and non-SSL users --- system-test/create_user.sh | 17 +++++++++++------ system-test/create_user_ssl.sh | 8 ++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/system-test/create_user.sh b/system-test/create_user.sh index b8b6064b7..4fac0a098 100755 --- a/system-test/create_user.sh +++ b/system-test/create_user.sh @@ -1,10 +1,15 @@ #!/bin/bash +# The following environment variables are used: +# node_user - A custom user to create +# node_password - The password for the user +# require_ssl - Require SSL for all users except the replication user + mysql --force $1 <& /dev/null DROP USER IF EXISTS '$node_user'@'%'; CREATE USER '$node_user'@'%' IDENTIFIED BY '$node_password'; -GRANT ALL PRIVILEGES ON *.* TO '$node_user'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON *.* TO '$node_user'@'%' $require_ssl WITH GRANT OPTION; DROP USER IF EXISTS 'repl'@'%'; CREATE USER 'repl'@'%' IDENTIFIED BY 'repl'; @@ -16,7 +21,7 @@ GRANT ALL ON *.* TO 'repl'@'localhost' WITH GRANT OPTION; DROP USER IF EXISTS 'skysql'@'%'; CREATE USER 'skysql'@'%' IDENTIFIED BY 'skysql'; -GRANT ALL ON *.* TO 'skysql'@'%' WITH GRANT OPTION; +GRANT ALL ON *.* TO 'skysql'@'%' $require_ssl WITH GRANT OPTION; DROP USER IF EXISTS 'skysql'@'localhost'; CREATE USER 'skysql'@'localhost' IDENTIFIED BY 'skysql'; @@ -24,19 +29,19 @@ GRANT ALL ON *.* TO 'skysql'@'localhost' WITH GRANT OPTION; DROP USER IF EXISTS 'maxskysql'@'%'; CREATE USER 'maxskysql'@'%' IDENTIFIED BY 'skysql'; -GRANT ALL ON *.* TO 'maxskysql'@'%' WITH GRANT OPTION; +GRANT ALL ON *.* TO 'maxskysql'@'%' $require_ssl WITH GRANT OPTION; DROP USER IF EXISTS 'maxskysql'@'localhost'; CREATE USER 'maxskysql'@'localhost' IDENTIFIED BY 'skysql'; -GRANT ALL ON *.* TO 'maxskysql'@'localhost' WITH GRANT OPTION; +GRANT ALL ON *.* TO 'maxskysql'@'localhost' $require_ssl WITH GRANT OPTION; DROP USER IF EXISTS 'maxuser'@'%'; CREATE USER 'maxuser'@'%' IDENTIFIED BY 'maxpwd'; -GRANT ALL ON *.* TO 'maxuser'@'%' WITH GRANT OPTION; +GRANT ALL ON *.* TO 'maxuser'@'%' $require_ssl WITH GRANT OPTION; DROP USER IF EXISTS 'maxuser'@'localhost'; CREATE USER 'maxuser'@'localhost' IDENTIFIED BY 'maxpwd'; -GRANT ALL ON *.* TO 'maxuser'@'localhost' WITH GRANT OPTION; +GRANT ALL ON *.* TO 'maxuser'@'localhost' $require_ssl WITH GRANT OPTION; RESET MASTER; EOF diff --git a/system-test/create_user_ssl.sh b/system-test/create_user_ssl.sh index 879c57fd1..2190d3ee8 100755 --- a/system-test/create_user_ssl.sh +++ b/system-test/create_user_ssl.sh @@ -1,8 +1,4 @@ #!/bin/bash -echo "DROP USER '$node_user'@'%'" | sudo mysql $1 -echo "grant all privileges on *.* to '$node_user'@'%' identified by '$node_password' require ssl WITH GRANT OPTION" -echo "grant all privileges on *.* to '$node_user'@'%' identified by '$node_password' require ssl WITH GRANT OPTION" | sudo mysql $1 - -echo "grant all privileges on *.* to 'maxskysql'@'%' identified by 'skysql' require ssl WITH GRANT OPTION" | sudo mysql $1 -echo "grant all privileges on *.* to 'maxuser'@'%' identified by 'maxpwd' require ssl WITH GRANT OPTION" | sudo mysql $1 +export require_ssl="REQUIRE SSL" +./create_user.sh $1 From 4545b8f798546f54ac5e1184a8fbbfd67d96b049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 17 Nov 2020 10:08:15 +0200 Subject: [PATCH 2/3] Fix division by zero If the query failed instantly it would crash the test. --- system-test/mxs1926_killed_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-test/mxs1926_killed_server.cpp b/system-test/mxs1926_killed_server.cpp index a17b8a6a8..0710c2fc5 100644 --- a/system-test/mxs1926_killed_server.cpp +++ b/system-test/mxs1926_killed_server.cpp @@ -54,7 +54,7 @@ void tune_rowcount(TestConnections& test) remove(filename.c_str()); int orig = ROWCOUNT; - ROWCOUNT = orig / dur.count() * 10000; + ROWCOUNT = orig / (dur.count() + 1) * 10000; test.tprintf("Loading %d rows took %ld ms, setting row count to %d", orig, dur.count(), From f577d098292b63e616e3864216daebcdeab0c5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 17 Nov 2020 10:43:40 +0200 Subject: [PATCH 3/3] MXS-3297: Don't advertise unsupported capabilities Only bulk execute is supported. Supporting progress reporting currently breaks the protocol result processing code. --- include/maxscale/protocol/mysql.h | 3 +++ server/modules/protocol/MySQL/mariadbclient/mysql_client.cc | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/maxscale/protocol/mysql.h b/include/maxscale/protocol/mysql.h index b5baedf00..454280b73 100644 --- a/include/maxscale/protocol/mysql.h +++ b/include/maxscale/protocol/mysql.h @@ -272,6 +272,9 @@ typedef enum #define MXS_MARIA_CAP_COM_MULTI (1 << 1) #define MXS_MARIA_CAP_STMT_BULK_OPERATIONS (1 << 2) +// Only bulk operations are supported +#define MXS_MARIADB_CAP_SERVER MXS_MARIA_CAP_STMT_BULK_OPERATIONS + typedef enum { MXS_COM_SLEEP = 0, diff --git a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc index f8c3b51a5..763f1de2f 100644 --- a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc +++ b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc @@ -661,7 +661,8 @@ static void store_client_information(DCB* dcb, GWBUF* buffer) * there are extra capabilities stored in the last 4 bytes of the 23 byte filler. */ if ((proto->client_capabilities & GW_MYSQL_CAPABILITIES_CLIENT_MYSQL) == 0) { - proto->extra_capabilities = gw_mysql_get_byte4(data + MARIADB_CAP_OFFSET); + uint32_t caps = gw_mysql_get_byte4(data + MARIADB_CAP_OFFSET); + proto->extra_capabilities = caps & MXS_MARIADB_CAP_SERVER; } if (len > MYSQL_AUTH_PACKET_BASE_SIZE)