Skip to content

Commit 017a76d

Browse files
committed
BUG#33739995: Pluggable authentication plugins do not work using DEB and RPM packages
This patch fixes the pluggable authentication plugins that don't load when using DEB or RPM packages, due to the set of the rpath to `mysql/vendor`. But for these platforms they rely in the mysql client plugins and the system libraries.
1 parent c280267 commit 017a76d

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

cpydist/__init__.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@
9292
("extra-compile-args=", None,
9393
"extra compile args"),
9494
("extra-link-args=", None,
95-
"extra link args")
95+
"extra link args"),
96+
("skip-vendor", None,
97+
"Skip bundling vendor libraries"),
9698
]
9799

98100
LOGGER = logging.getLogger(__name__)
@@ -108,7 +110,7 @@ class BaseCommand(Command):
108110
"""Base command class for Connector/Python."""
109111

110112
user_options = COMMON_USER_OPTIONS + CEXT_OPTIONS
111-
boolean_options = ["debug", "byte_code_only", "keep-temp"]
113+
boolean_options = ["debug", "byte_code_only", "keep_temp", "skip_vendor"]
112114

113115
with_mysql_capi = None
114116
with_mysqlxpb_cext = False
@@ -128,6 +130,7 @@ class BaseCommand(Command):
128130
label = None
129131
debug = False
130132
keep_temp = False
133+
skip_vendor = False
131134
build_base = None
132135
log = LOGGER
133136
vendor_folder = os.path.join("lib", "mysql", "vendor")
@@ -152,6 +155,7 @@ def initialize_options(self):
152155
self.label = None
153156
self.debug = False
154157
self.keep_temp = False
158+
self.skip_vendor = False
155159

156160
def finalize_options(self):
157161
"""Finalize the options."""
@@ -192,7 +196,12 @@ def finalize_options(self):
192196
self.extra_link_args or
193197
os.environ.get("EXTRA_LINK_ARGS")
194198
)
195-
self._copy_vendor_libraries()
199+
cmd_build_ext.skip_vendor = (
200+
self.skip_vendor or
201+
os.environ.get("SKIP_VENDOR")
202+
)
203+
if not cmd_build_ext.skip_vendor:
204+
self._copy_vendor_libraries()
196205

197206
def remove_temp(self):
198207
"""Remove temporary build files."""
@@ -352,8 +361,6 @@ def _copy_vendor_libraries(self):
352361
if not os.path.exists(sasl_libs_path):
353362
self.log.info("sasl2 llibraries not found at %s",
354363
sasl_libs_path)
355-
self.distribution.package_data = {
356-
"mysql": ["vendor/*"]}
357364
sasl_libs = []
358365
sasl_plugin_libs_w = [
359366
"libsasl2.*.*", "libgssapi_krb5.*.*", "libgssapi_krb5.*.*",
@@ -391,8 +398,6 @@ def _copy_vendor_libraries(self):
391398
if not os.path.exists(sasl2_libs_path):
392399
self.log.info("sasl2 llibraries not found at %s",
393400
sasl2_libs_path)
394-
self.distribution.package_data = {"mysql": ["vendor/*"]}
395-
return
396401
sasl2_libs_w = [
397402
"libanonymous.*", "libcrammd5.*.*", "libdigestmd5.*.*.*.*",
398403
"libgssapiv2.*", "libplain.*.*", "libscram.*.*.*.*",
@@ -633,7 +638,7 @@ def run(self):
633638
if self.extra_link_args:
634639
ext.extra_link_args.extend(self.extra_link_args.split())
635640
# Add -rpath if the platform is Linux
636-
if platform.system() == "Linux":
641+
if platform.system() == "Linux" and not self.skip_vendor:
637642
ext.extra_link_args.extend([
638643
"-Wl,-rpath,$ORIGIN/mysql/vendor"])
639644
# Add include dirs

cpydist/bdist_deb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -316,6 +316,7 @@ def _make_dpkg(self):
316316
env["EXTRA_LINK_ARGS"] = self.extra_link_args or ""
317317
env["LABEL"] = self.label if self.label else "0"
318318
env["BYTE_CODE_ONLY"] = "1" if self.byte_code_only else ""
319+
env["SKIP_VENDOR"] = "1" if self.skip_vendor else ""
319320
proc = subprocess.Popen(cmd,
320321
stdout=subprocess.PIPE,
321322
stderr=subprocess.PIPE,

cpydist/data/deb/rules

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make -f
22

33

4-
# Copyright (c) 2014, 2021, Oracle and/or its affiliates.
4+
# Copyright (c) 2014, 2022, Oracle and/or its affiliates.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -80,6 +80,12 @@ else
8080
BYTE_CODE_ONLY_OPT =
8181
endif
8282

83+
ifneq ($(SKIP_VENDOR),)
84+
SKIP_VENDOR_OPT = --skip-vendor
85+
else
86+
SKIP_VENDOR_OPT =
87+
endif
88+
8389
%:
8490
dh $@ --with python3 --buildsystem=pybuild
8591

@@ -97,7 +103,7 @@ override_dh_auto_install:
97103
--with-protoc=$(MYSQLXPB_PROTOC) \
98104
--extra-compile-args="$(EXTRA_COMPILE_ARGS)" \
99105
--extra-link-args="$(EXTRA_LINK_ARGS)" $(OPENSSL_OPT) \
100-
--root $$DESTDIR $(BYTE_CODE_ONLY_OPT); \
106+
--root $$DESTDIR $(BYTE_CODE_ONLY_OPT) $(SKIP_VENDOR_OPT); \
101107
find $$DESTDIR -name 'mysql_connector_*.egg-info' -prune -exec rm -rf {} \;; \
102108
done
103109

lib/mysql/connector/connection_cext.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import os
3636
import socket
37-
import sysconfig
37+
import platform
3838

3939
from . import errors, version
4040
from .constants import (
@@ -78,6 +78,15 @@ def __init__(self, **kwargs):
7878
os.path.dirname(os.path.abspath(_mysql_connector.__file__)),
7979
"mysql", "vendor", "plugin"
8080
)
81+
if platform.system() == "Linux":
82+
# Use the authentication plugins from system if they aren't bundled
83+
if not os.path.exists(self._plugin_dir):
84+
self._plugin_dir = (
85+
"/usr/lib64/mysql/plugin"
86+
if os.path.exists("/usr/lib64/mysql/plugin")
87+
else "/usr/lib/mysql/plugin"
88+
)
89+
8190
self.converter = None
8291
super(CMySQLConnection, self).__init__(**kwargs)
8392

0 commit comments

Comments
 (0)