[packages/python3-mysql-connector] Build against mysql 9.7 LTS; use the real client plugin dir
arekm
arekm at pld-linux.org
Tue Sep 1 13:02:17 CEST 2026
commit ab3035ddbc80aaa7e8ebc8447c060c2178bf50c5
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Tue Sep 1 10:52:43 2026 +0200
Build against mysql 9.7 LTS; use the real client plugin dir
9.x made mysql_native_password a loadable client plugin, and upstream
overrides the plugin dir with a path PLD never had - let libmysqlclient
keep its own, and drop the insecure "." default while at it.
plugin-dir.patch | 57 ++++++++++++++++++++++++++++++++++++++++++++
python3-mysql-connector.spec | 6 +++--
2 files changed, 61 insertions(+), 2 deletions(-)
---
diff --git a/python3-mysql-connector.spec b/python3-mysql-connector.spec
index 9fc1d86..4e6fbae 100644
--- a/python3-mysql-connector.spec
+++ b/python3-mysql-connector.spec
@@ -5,7 +5,7 @@
%bcond_with tests # build with tests (requires mysql server)
%ifarch %{x8664}
-%define mysql_ver 8.4
+%define mysql_ver 9.7
%else
%define mysql_ver 8.0
%endif
@@ -17,7 +17,7 @@ Name: python3-%{pname}
# check documentation to see which version is GA (we don't want devel releases)
# https://dev.mysql.com/downloads/connector/python/
Version: 9.7.0
-Release: 1
+Release: 2
License: GPL v2
Group: Libraries/Python
Source0: http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-%{version}-src.tar.gz
@@ -25,6 +25,7 @@ Source0: http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-
#Source0: https://pypi.debian.net/mysql-connector-python/mysql-connector-python-%{version}.tar.gz
Patch0: force-capi.patch
Patch1: tests.patch
+Patch2: plugin-dir.patch
URL: http://dev.mysql.com/doc/connector-python/en/
BuildRequires: mysql%{mysql_ver}-devel
BuildRequires: protobuf-devel >= 3.0.0
@@ -50,6 +51,7 @@ MySQL Connector/Python to protokół klient-serwer MySQL-a.
%setup -q -n mysql-connector-python-%{version}-src
%patch -P0 -p1
%patch -P1 -p1
+%patch -P2 -p1
%build
export MYSQL_CAPI=%{_bindir}/mysql_config%{mysql_ver}
diff --git a/plugin-dir.patch b/plugin-dir.patch
new file mode 100644
index 0000000..4763268
--- /dev/null
+++ b/plugin-dir.patch
@@ -0,0 +1,57 @@
+MySQL 9.x turned the client-side mysql_native_password into a loadable plugin,
+so libmysqlclient has to find it in its own plugin directory. Upstream instead
+forces MYSQL_PLUGIN_DIR to a hardcoded /usr/lib64/mysql/plugin, falling back to
+/usr/lib/mysql/plugin - PLD installs plugins versioned, as
+/usr/lib64/mysqlX.Y/plugin, so neither path exists and every connection using
+that auth method fails. The override is only meaningful for the vendor plugins
+bundled in upstream's own wheels, which this build does not ship, so leave the
+directory unset and let libmysqlclient use the one it was built with.
+
+The C extension made that impossible: it defaulted the directory to "." and
+called mysql_options() unconditionally. "." is a plugin search path in the
+working directory - anyone who can write to the cwd of a process linked against
+libmysqlclient can have a .so of their choosing dlopen()ed - so drop that
+default too. An explicit plugin_dir="." still works if someone really wants it.
+
+--- a/mysql-connector-python/lib/mysql/connector/connection_cext.py
++++ b/mysql-connector-python/lib/mysql/connector/connection_cext.py
+@@ -126,13 +126,10 @@
+ "plugin",
+ )
+ if platform.system() == "Linux":
+- # Use the authentication plugins from system if they aren't bundled
++ # nothing bundled: leave it unset so libmysqlclient looks in the
++ # plugin directory it was built with
+ if not os.path.exists(self._plugin_dir):
+- self._plugin_dir = (
+- "/usr/lib64/mysql/plugin"
+- if os.path.exists("/usr/lib64/mysql/plugin")
+- else "/usr/lib/mysql/plugin"
+- )
++ self._plugin_dir = ""
+
+ self.converter: Optional[MySQLConverter] = None
+ super().__init__()
+--- a/mysql-connector-python/src/mysql_capi.c
++++ b/mysql-connector-python/src/mysql_capi.c
+@@ -368,7 +368,7 @@
+ self->fields = NULL;
+ self->use_unicode = 1;
+ self->auth_plugin = PyUnicode_FromString("");
+- self->plugin_dir = PyUnicode_FromString(".");
++ self->plugin_dir = PyUnicode_FromString("");
+ self->converter_str_fallback = Py_False;
+
+ return (PyObject *)self;
+@@ -1267,7 +1267,10 @@
+ }
+
+ plugin_dir = PyUnicode_AsUTF8(self->plugin_dir);
+- mysql_options(&self->session, MYSQL_PLUGIN_DIR, plugin_dir);
++ /* unset: keep the plugin directory libmysqlclient was built with */
++ if (plugin_dir && *plugin_dir) {
++ mysql_options(&self->session, MYSQL_PLUGIN_DIR, plugin_dir);
++ }
+ mysql_options(&self->session, MYSQL_OPT_PROTOCOL, (char *)&protocol);
+ mysql_options(&self->session, MYSQL_SET_CHARSET_NAME, PyBytes_AsString(charset_name));
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python3-mysql-connector.git/commitdiff/53e6e6257bb0f299a9ad70fad02b4955eeb989d4
More information about the pld-cvs-commit
mailing list