From cb74130ca32803e67ad7fa14781494e82bea6174 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 4 Dec 2019 14:43:02 +0100 Subject: [PATCH] Compatibility between MySQL versions improved, ease compilation --- Makefile.decl | 17 +---------------- README.md | 35 +++++++++++++++++++++++++++++------ configure.ac | 2 -- proxy-auth/proxy-auth.cc | 18 ++++++------------ 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Makefile.decl b/Makefile.decl index 2818033..e5da287 100644 --- a/Makefile.decl +++ b/Makefile.decl @@ -4,29 +4,14 @@ mysql_CFLAGS = `mysql_config --cflags` vn_mysql_libdir = /usr/lib/mysql/plugin -if MYSQL8 - -MYSQLD_SOURCE = /var/mysql/mysql-8.0.15 vn_mysql_CFLAGS = \ -Wall -O3 \ - -DMYSQL8=1 \ -I$(MYSQLD_SOURCE)/include \ - -I$(MYSQLD_SOURCE) \ - -I$(MYSQLD_SOURCE)/bld/include \ - -I$(MYSQLD_SOURCE)libbinlogevents/export \ $(mysql_CFLAGS) -else - -vn_mysql_CFLAGS = \ - -Wall -O3 \ - $(mysql_CFLAGS) - -endif - vn_mysql_LDFLAGS = \ -no-undefined \ -module \ -avoid-version \ -export-dynamic \ - $(mysql_LIBS) \ No newline at end of file + $(mysql_LIBS) diff --git a/README.md b/README.md index 520ca34..7098b77 100644 --- a/README.md +++ b/README.md @@ -10,21 +10,37 @@ Install basic tools for compiling. $ apt-get install build-essential devscripts dh-autoreconf ``` -Install MySQL and GLib development libraries. +Install MySQL development libraries. ``` -$ apt-get install libmysqld-dev libglib2.0-dev +$ apt-get install libmysqld-dev ``` -Compile and generate Debian package for MySQL 5. +If MySQL development libraries are not available for your distribution or MySQL +version you can obtain MySQL server source code from apt sources repository or +from MySQL page. +``` +$ apt-get source mysql-community +``` + +Install GLib development libraries. +``` +$ apt-get install libglib2.0-dev +``` + +Run autogen. ``` $ ./autogen.sh +``` + +Compile and generate Debian package. +``` $ debuild -uc -us -b ``` -Compile and generate Debian package for MySQL 8. +If development libraries are not available and you have downloaded the server +source code, you can tell the build command it's location. ``` -$ ./autogen.sh -$ debuild --set-envvar MYSQL8=TRUE -uc -us -b +$ debuild --set-envvar MYSQLD_SOURCE=[mysqld_source_dir] -uc -us -b ``` ## Installing @@ -52,6 +68,13 @@ DROP FUNCTION IF EXISTS multimax; DROP FUNCTION IF EXISTS sql_printf; ``` +## Commands + +Obtain MySQL version from commandline. +``` +$ mysql_config --version | cut -d "." -f 1 +``` + ## Built with * [MySQL](https://dev.mysql.com/doc/refman/8.0/en/extending-mysql.html) diff --git a/configure.ac b/configure.ac index 7d0e995..6ca9b79 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,6 @@ AC_PROG_CXX AC_PROG_CC PKG_CHECK_MODULES([glib], [glib-2.0]) -AM_CONDITIONAL([MYSQL8], [test ! -z "$MYSQL8"]) - AC_CONFIG_FILES([ Makefile proxy-auth/Makefile diff --git a/proxy-auth/proxy-auth.cc b/proxy-auth/proxy-auth.cc index d74cdf5..9ed788b 100644 --- a/proxy-auth/proxy-auth.cc +++ b/proxy-auth/proxy-auth.cc @@ -20,22 +20,14 @@ #include #include -#ifndef MYSQL8 #define MYSQL_ABI_CHECK -#endif -//#include #include #include #include -#ifdef MYSQL8 -#include -#include -#endif - -#define CONFIG_FILE _CONFIG_DIR"/proxy-auth.ini" -#define SQL_FILE _SQL_DIR"/proxy-auth.sql" +#define CONFIG_FILE _CONFIG_DIR"/proxy-auth.ini" +#define SQL_FILE _SQL_DIR"/proxy-auth.sql" typedef struct { gboolean initialized; @@ -416,13 +408,15 @@ proxy_auth_handler = { MYSQL_AUTHENTICATION_INTERFACE_VERSION, "mysql_clear_password", // Cleartext plugin required in the client proxy_auth_plugin_main, +#if MYSQL_VERSION_ID >= 50700 generate_auth_string_hash, validate_auth_string_hash, set_salt, AUTH_FLAG_PRIVILEGED_USER_FOR_PASSWORD_CHANGE, -#ifdef MYSQL8 +#if MYSQL_VERSION_ID >= 80000 NULL #endif +#endif }; mysql_declare_plugin(proxy_auth) { @@ -433,7 +427,7 @@ mysql_declare_plugin(proxy_auth) { "Proxy user authentication server-side plugin", PLUGIN_LICENSE_GPL, proxy_auth_plugin_init, -#ifdef MYSQL8 +#if MYSQL_VERSION_ID >= 80000 NULL, #endif proxy_auth_plugin_deinit,