From f60a31b5a89b5143008eb3d0f04a6412dfa53eff Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Thu, 21 Apr 2022 11:59:14 +0200 Subject: [PATCH 1/7] Debug information for tests: Print tls releated server variables --- unittest/libmariadb/my_test.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/unittest/libmariadb/my_test.h b/unittest/libmariadb/my_test.h index 58765a9b..17907a9e 100644 --- a/unittest/libmariadb/my_test.h +++ b/unittest/libmariadb/my_test.h @@ -655,6 +655,33 @@ void run_tests(struct my_tests_st *test) { total++; plan(total); + /* display TLS stats */ + mysql= mysql_init(NULL); + mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL); + + if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0)) + { + BAIL_OUT("Can't establish TLS connection to server."); + } + + if (!mysql_query(mysql, "SHOW VARIABLES LIKE '%ssl%'")) + { + MYSQL_RES *res; + MYSQL_ROW row; + + diag("TLS server variables"); + diag("--------------------"); + + res= mysql_store_result(mysql); + while ((row= mysql_fetch_row(res))) + diag("%s: %s", row[0], row[1]); + mysql_free_result(res); + diag("Cipher in use: %s", mysql_get_ssl_cipher(mysql)); + diag("--------------------"); + } + mysql_close(mysql); + + if ((mysql_default= test_connect(NULL))) { diag("Testing against MySQL Server %s", mysql_get_server_info(mysql_default)); From 2638faea0a5f943c7abbd317734c38d098e520af Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Thu, 21 Apr 2022 12:48:39 +0200 Subject: [PATCH 2/7] travis fix: Copy Connector/C source dir into server subdirectory to retrieve latest commit or pull request. --- travis.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/travis.sh b/travis.sh index ea65dfe3..b2c7de13 100755 --- a/travis.sh +++ b/travis.sh @@ -2,6 +2,7 @@ set -e +export CC_DIR=/home/travis/build/mariadb-corporation/mariadb-connector-c if [ -n "$server_branch" ] ; then ################################################################################################################### @@ -17,6 +18,8 @@ if [ -n "$server_branch" ] ; then git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server cd ../workdir-server + export SERVER_DIR=$pwd + # don't pull in submodules. We want the latest C/C as libmariadb # build latest server with latest C/C as libmariadb # skip to build some storage engines to speed up the build @@ -26,18 +29,19 @@ if [ -n "$server_branch" ] ; then if [ -n "$TRAVIS_PULL_REQUEST" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then # fetching pull request echo "fetching PR" - git fetch origin pull/${TRAVIS_PULL_REQUEST}/head:PR_${TRAVIS_PULL_REQUEST} echo "checkout PR" - git checkout PR_${TRAVIS_PULL_REQUEST} else echo "checkout commit" - git checkout ${TRAVIS_COMMIT} fi - cd .. + cp $CC_DIR/* $SERVER_DIR/libmariadb -r + cd $SERVER_DIR git add libmariadb + + cd $SERVER_DIR/bld make -j9 + cd mysql-test/ ./mysql-test-run.pl --suite=main ${TEST_OPTION} --parallel=auto --skip-test=session_tracker_last_gtid From 5e354f11a94c9fa8edeb2cc2748e2421536bd9b5 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Thu, 21 Apr 2022 17:32:59 +0200 Subject: [PATCH 3/7] fix typo: environment variable PWD needs to be specified in uppercase --- travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index b2c7de13..9fbcc88d 100755 --- a/travis.sh +++ b/travis.sh @@ -18,7 +18,7 @@ if [ -n "$server_branch" ] ; then git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server cd ../workdir-server - export SERVER_DIR=$pwd + export SERVER_DIR=$PWD # don't pull in submodules. We want the latest C/C as libmariadb # build latest server with latest C/C as libmariadb From 4436685ba3ca61b10babc5472fa329ca502824d7 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 22 Apr 2022 07:26:21 +0200 Subject: [PATCH 4/7] travis fix: don't build server in source directory --- travis.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis.sh b/travis.sh index 9fbcc88d..4144a749 100755 --- a/travis.sh +++ b/travis.sh @@ -18,6 +18,8 @@ if [ -n "$server_branch" ] ; then git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server cd ../workdir-server + mkdir bld + cd bld export SERVER_DIR=$PWD # don't pull in submodules. We want the latest C/C as libmariadb @@ -41,7 +43,6 @@ if [ -n "$server_branch" ] ; then cd $SERVER_DIR/bld make -j9 - cd mysql-test/ ./mysql-test-run.pl --suite=main ${TEST_OPTION} --parallel=auto --skip-test=session_tracker_last_gtid From f33017c19a5b02394de5d0816513d2e2c9d1767c Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 22 Apr 2022 14:28:38 +0200 Subject: [PATCH 5/7] travis: clone server tree with depth=1 --- travis.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/travis.sh b/travis.sh index 4144a749..cbd8fc0c 100755 --- a/travis.sh +++ b/travis.sh @@ -15,17 +15,18 @@ if [ -n "$server_branch" ] ; then sudo tail /etc/hosts # get latest server - git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server + git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server --depth=1 cd ../workdir-server - mkdir bld - cd bld export SERVER_DIR=$PWD # don't pull in submodules. We want the latest C/C as libmariadb # build latest server with latest C/C as libmariadb # skip to build some storage engines to speed up the build - cmake -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_SPIDER=NO -DPLUGIN_TOKUDB=NO + + mkdir bld + cd bld + cmake .. -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_SPIDER=NO -DPLUGIN_TOKUDB=NO cd libmariadb echo "PR:${TRAVIS_PULL_REQUEST} TRAVIS_COMMIT:${TRAVIS_COMMIT}" if [ -n "$TRAVIS_PULL_REQUEST" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then From f75a819efd2fef76018e92da19daaf364c09639f Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 29 Apr 2022 16:30:27 +0200 Subject: [PATCH 6/7] Post fix for CONC-588 Instead to allocate procy header string the poiter was assigned to extended options. --- libmariadb/mariadb_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 095d1cb5..a650aad2 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -3252,7 +3252,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) case MARIADB_OPT_PROXY_HEADER: { size_t arg2 = va_arg(ap, size_t); - OPT_SET_EXTENDED_VALUE(&mysql->options, proxy_header, (char *)arg1); + OPT_SET_EXTENDED_VALUE_STR(&mysql->options, proxy_header, (char *)arg1); OPT_SET_EXTENDED_VALUE(&mysql->options, proxy_header_len, arg2); } break; From ab7a81e79e4be4324a2d09d19d4f5249801ef665 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sat, 30 Apr 2022 05:37:31 +0200 Subject: [PATCH 7/7] Added new macro OPT_SET_EXTENDED_VALUE_BIN OPT_SET_EXTENDED_VALUE_BIN can be used to set binary values for options: OPT_SET_EXTENDED_VALUE_BIN(options, key, key_len, val, len) --- libmariadb/mariadb_lib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index a650aad2..8dc2ec0e 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -674,6 +674,18 @@ struct st_default_options mariadb_defaults[] = (OPTS)->extension= (struct st_mysql_options_extension *) \ calloc(1, sizeof(struct st_mysql_options_extension)); +#define OPT_SET_EXTENDED_VALUE_BIN(OPTS, KEY, KEY_LEN, VAL, LEN) \ + CHECK_OPT_EXTENSION_SET(OPTS) \ + free((gptr)(OPTS)->extension->KEY); \ + if((VAL) && (LEN)) { \ + if (((OPTS)->extension->KEY= malloc((LEN)))) { \ + memcpy((OPTS)->extension->KEY, (VAL), (LEN)); \ + (OPTS)->extension->KEY_LEN= (LEN); \ + } \ + } \ + else \ + (OPTS)->extension->KEY= NULL + #define OPT_SET_EXTENDED_VALUE_STR(OPTS, KEY, VAL) \ CHECK_OPT_EXTENSION_SET(OPTS) \ free((gptr)(OPTS)->extension->KEY); \ @@ -3252,8 +3264,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) case MARIADB_OPT_PROXY_HEADER: { size_t arg2 = va_arg(ap, size_t); - OPT_SET_EXTENDED_VALUE_STR(&mysql->options, proxy_header, (char *)arg1); - OPT_SET_EXTENDED_VALUE(&mysql->options, proxy_header_len, arg2); + OPT_SET_EXTENDED_VALUE_BIN(&mysql->options, proxy_header, proxy_header_len, (char *)arg1, arg2); } break; case MARIADB_OPT_TLS_VERSION: