Skip to content

Commit 8f637d9

Browse files
committed
WL14110: Add support for SCRAM-SHA-1
The purpose of this Worklog is to add support for the SASL authentication protocol using the SCRAM-SHA-1 authentication method.
1 parent 1fef461 commit 8f637d9

File tree

17 files changed

+940
-18
lines changed

17 files changed

+940
-18
lines changed

cpydist/__init__.py

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class BaseCommand(Command):
128128
build_base = None
129129
log = LOGGER
130130
vendor_folder = os.path.join("lib", "mysql", "vendor")
131+
private_folder = os.path.join("lib", "mysql", "private")
131132

132133
_mysql_info = {}
133134
_build_mysql_lib_dir = None
@@ -178,6 +179,9 @@ def remove_temp(self):
178179
vendor_folder = os.path.join(os.getcwd(), self.vendor_folder)
179180
if os.path.exists(vendor_folder):
180181
remove_tree(vendor_folder)
182+
private_folder = os.path.join(os.getcwd(), self.private_folder)
183+
if os.path.exists(private_folder):
184+
remove_tree(private_folder)
181185
elif os.name == "nt":
182186
if ARCH == "64-bit":
183187
libraries = ["libmysql.dll", "libssl-1_1-x64.dll",
@@ -210,6 +214,25 @@ def _copy_vendor_libraries(self):
210214
vendor_libs.append(
211215
(self.with_openssl_lib_dir, [libssl, libcrypto]))
212216

217+
# Plugins
218+
bundle_plugin_libs = False
219+
if self.with_mysql_capi:
220+
plugin_ext = "dll" if os.name == "nt" else "so"
221+
plugin_path = os.path.join(self.with_mysql_capi, "lib", "plugin")
222+
plugin_name = ("authentication_ldap_sasl_client.{}"
223+
"".format(plugin_ext))
224+
225+
if os.path.exists(plugin_name):
226+
bundle_plugin_libs = True
227+
vendor_libs.append(
228+
(plugin_path, [plugin_name]))
229+
230+
if bundle_plugin_libs and os.name == "nt":
231+
sasl_libs_path = os.path.join(self.with_mysql_capi, "bin")
232+
sasl_plugin_libs = ["libsasl.dll", "saslSCRAM.dll",
233+
"libcrypto-1_1-x64.dll"]
234+
vendor_libs.append((sasl_libs_path, sasl_plugin_libs))
235+
213236
if not vendor_libs:
214237
return
215238

@@ -219,13 +242,102 @@ def _copy_vendor_libraries(self):
219242
# Copy vendor libraries to 'mysql/vendor' folder
220243
self.log.info("Copying vendor libraries")
221244
for src_folder, files in vendor_libs:
245+
self.log.info("Copying folder: %s", src_folder)
222246
for filename in files:
223247
src = os.path.join(src_folder, filename)
224248
dst = os.path.join(os.getcwd(), self.vendor_folder)
225249
self.log.info("copying %s -> %s", src, dst)
226250
shutil.copy(src, dst)
227251

228-
self.distribution.package_data = {"mysql": ["vendor/*"]}
252+
if os.name == "nt":
253+
self.distribution.package_data = {"mysql": ["vendor/*"]}
254+
return
255+
elif bundle_plugin_libs:
256+
# Bundle SASL libs
257+
sasl_libs_path = os.path.join(self.with_mysql_capi, "lib",
258+
"private")
259+
if not os.path.exists(sasl_libs_path):
260+
self.log.info("sasl2 llibraries not found at %s",
261+
sasl_libs_path)
262+
self.distribution.package_data = {
263+
"mysql": ["vendor/*"]}
264+
sasl_libs = []
265+
sasl_plugin_libs_w = [
266+
"libsasl2.*.*", "libgssapi_krb5.*.*", "libgssapi_krb5.*.*",
267+
"libkrb5.*.*", "libk5crypto.*.*", "libkrb5support.*.*",
268+
"libcrypto.*.*.*", "libssl.*.*.*", "libcom_err.*.*"]
269+
sasl_plugin_libs = []
270+
for sasl_lib in sasl_plugin_libs_w:
271+
lib_path_entries = glob(os.path.join(
272+
sasl_libs_path, sasl_lib))
273+
for lib_path_entry in lib_path_entries:
274+
sasl_plugin_libs.append(os.path.basename(lib_path_entry))
275+
sasl_libs.append((sasl_libs_path, sasl_plugin_libs))
276+
277+
if not os.path.exists(os.path.join(self.private_folder)):
278+
mkpath(os.path.join(os.getcwd(), self.private_folder))
279+
280+
# Copy vendor libraries to 'mysql/private' folder
281+
self.log.info("Copying vendor libraries")
282+
for src_folder, files in sasl_libs:
283+
self.log.info("Copying folder: %s", src_folder)
284+
for filename in files:
285+
src = os.path.join(src_folder, filename)
286+
if not os.path.exists(src):
287+
self.log.warn("Library not found: %s", src)
288+
continue
289+
dst = os.path.join(os.getcwd(),
290+
os.path.join(self.private_folder))
291+
self.log.info("copying %s -> %s", src, dst)
292+
shutil.copy(src, dst)
293+
294+
# include sasl2 libs
295+
sasl2_libs = []
296+
sasl2_libs_path = os.path.join(self.with_mysql_capi, "lib",
297+
"private", "sasl2")
298+
if not os.path.exists(sasl2_libs_path):
299+
self.log.info("sasl2 llibraries not found at %s",
300+
sasl2_libs_path)
301+
self.distribution.package_data = {
302+
"mysql": ["vendor/*", "private/*"]}
303+
return
304+
sasl2_libs_w = [
305+
"libanonymous.*", "libcrammd5.*.*", "libdigestmd5.*.*.*.*",
306+
"libgssapiv2.*", "libplain.*.*", "libscram.*.*.*.*",
307+
"libanonymous.*.*", "libcrammd5.*.*.*.*", "libgs2.*",
308+
"libgssapiv2.*.*", "libplain.*.*.*.*", "libanonymous.*.*.*.*",
309+
"libdigestmd5.*", "libgs2.*.*", "libgssapiv2.*.*.*.*",
310+
"libscram.*", "libcrammd5.*", "libdigestmd5.*.*",
311+
"libgs2.*.*.*.*", "libplain.*", "libscram.*.*"]
312+
313+
sasl2_scram_libs = []
314+
for sasl2_lib in sasl2_libs_w:
315+
lib_path_entries = glob(os.path.join(
316+
sasl2_libs_path, sasl2_lib))
317+
for lib_path_entry in lib_path_entries:
318+
sasl2_scram_libs.append(os.path.basename(lib_path_entry))
319+
320+
sasl2_libs.append((sasl2_libs_path, sasl2_scram_libs))
321+
322+
if not os.path.exists(os.path.join(self.private_folder, "sasl2")):
323+
mkpath(os.path.join(os.getcwd(), self.private_folder, "sasl2"))
324+
325+
# Copy vendor libraries to 'mysql/vendor/sasl2' folder
326+
self.log.info("Copying vendor libraries")
327+
for src_folder, files in sasl2_libs:
328+
self.log.info("Copying folder: %s", src_folder)
329+
for filename in files:
330+
src = os.path.join(src_folder, filename)
331+
if not os.path.exists(src):
332+
self.log.warn("Library not found: %s", src)
333+
continue
334+
dst = os.path.join(os.getcwd(),
335+
os.path.join(self.private_folder, "sasl2"))
336+
self.log.info("copying %s -> %s", src, dst)
337+
shutil.copy(src, dst)
338+
339+
self.distribution.package_data = {
340+
"mysql": ["vendor/*", "private/*", "private/sasl2/*"]}
229341

230342

231343
class BuildExt(build_ext, BaseCommand):

cpydist/bdist_msi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ def _create_msi(self, dry_run=0):
389389
params["CExtXPBName{}{}".format(*ver)] = \
390390
"_mysqlxpb{}".format(pyd_ext)
391391
params["HaveCExt{}{}".format(*ver)] = 0
392+
params["HaveLdapLibs{}{}".format(*ver)] = 0
392393

393394
if py_ver in self.pyver_bdist_paths:
394395
params["BDist{}{}".format(*ver)] = \
@@ -397,6 +398,11 @@ def _create_msi(self, dry_run=0):
397398
os.path.join(self.pyver_bdist_paths[py_ver],
398399
params["CExtLibName{}{}".format(*ver)])):
399400
params["HaveCExt{}{}".format(*ver)] = 1
401+
if os.path.exists(
402+
os.path.join(self.pyver_bdist_paths[py_ver],
403+
"mysql", "vendor",
404+
"authentication_ldap_sasl_client.dll")):
405+
params["HaveLdapLibs{}{}".format(*ver)] = 1
400406

401407
self.log.info("### wixer params:")
402408
for param in params:

cpydist/data/msi/PY35.wxs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@
136136
</Component>
137137
</DirectoryRef>
138138

139+
<DirectoryRef Id="VendorDir35">
140+
<?if $(var.HaveLdapLibs38) = 1 ?>
141+
<Component Id="Vendor35" Guid="9fe7ee59-be3b-11ea-9f7e-04ea56793316" Win64="$(var.Win64)">
142+
<File Id="authentication_ldap_sasl_client35" Name="authentication_ldap_sasl_client.dll"
143+
Source="$(var.BDist35)\mysql\vendor\authentication_ldap_sasl_client.dll" DiskId="1"/>
144+
<File Id="libsasl35" Name="libsasl.dll"
145+
Source="$(var.BDist35)\mysql\vendor\libsasl.dll" DiskId="1"/>
146+
<File Id="libcrypto_1_135" Name="libcrypto-1_1-x64.dll"
147+
Source="$(var.BDist35)\mysql\vendor\libcrypto-1_1-x64.dll" DiskId="1"/>
148+
<File Id="saslSCRAM35" Name="saslSCRAM.dll"
149+
Source="$(var.BDist35)\mysql\vendor\saslSCRAM.dll" DiskId="1"/>
150+
</Component>
151+
<?endif?>
152+
</DirectoryRef>
153+
139154
<DirectoryRef Id="ConnectorPackageDir35">
140155
<Component Id="ConnectorPackage35" Guid="279d4008-b5ea-45bb-b642-ba0e9a6886aa" Win64="$(var.Win64)">
141156
<File Id="initpy35" Name="__init__.$(var.PyExt)"

cpydist/data/msi/PY36.wxs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@
136136
</Component>
137137
</DirectoryRef>
138138

139+
<DirectoryRef Id="VendorDir36">
140+
<?if $(var.HaveLdapLibs36) = 1 ?>
141+
<Component Id="Vendor36" Guid="3fdebba4-be39-11ea-b0cc-04ea56793316" Win64="$(var.Win64)">
142+
<File Id="authentication_ldap_sasl_client36" Name="authentication_ldap_sasl_client.dll"
143+
Source="$(var.BDist36)\mysql\vendor\authentication_ldap_sasl_client.dll" DiskId="1"/>
144+
<File Id="libsasl36" Name="libsasl.dll"
145+
Source="$(var.BDist36)\mysql\vendor\libsasl.dll" DiskId="1"/>
146+
<File Id="libcrypto_1_136" Name="libcrypto-1_1-x64.dll"
147+
Source="$(var.BDist36)\mysql\vendor\libcrypto-1_1-x64.dll" DiskId="1"/>
148+
<File Id="saslSCRAM36" Name="saslSCRAM.dll"
149+
Source="$(var.BDist36)\mysql\vendor\saslSCRAM.dll" DiskId="1"/>
150+
</Component>
151+
<?endif?>
152+
</DirectoryRef>
153+
139154
<DirectoryRef Id="ConnectorPackageDir36">
140155
<Component Id="ConnectorPackage36" Guid="412d7a24-a28e-4d08-a9f8-bf059ea4a802" Win64="$(var.Win64)">
141156
<File Id="initpy36" Name="__init__.$(var.PyExt)"

cpydist/data/msi/PY37.wxs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@
136136
</Component>
137137
</DirectoryRef>
138138

139+
<DirectoryRef Id="VendorDir37">
140+
<?if $(var.HaveLdapLibs37) = 1 ?>
141+
<Component Id="Vendor37" Guid="103f2914-be39-11ea-98b1-04ea56793316" Win64="$(var.Win64)">
142+
<File Id="authentication_ldap_sasl_client37" Name="authentication_ldap_sasl_client.dll"
143+
Source="$(var.BDist37)\mysql\vendor\authentication_ldap_sasl_client.dll" DiskId="1"/>
144+
<File Id="libsasl37" Name="libsasl.dll"
145+
Source="$(var.BDist37)\mysql\vendor\libsasl.dll" DiskId="1"/>
146+
<File Id="libcrypto_1_137" Name="libcrypto-1_1-x64.dll"
147+
Source="$(var.BDist37)\mysql\vendor\libcrypto-1_1-x64.dll" DiskId="1"/>
148+
<File Id="saslSCRAM37" Name="saslSCRAM.dll"
149+
Source="$(var.BDist37)\mysql\vendor\saslSCRAM.dll" DiskId="1"/>
150+
</Component>
151+
<?endif?>
152+
</DirectoryRef>
153+
139154
<DirectoryRef Id="ConnectorPackageDir37">
140155
<Component Id="ConnectorPackage37" Guid="d74397aa-96b6-4e0d-9db8-6873b296489e" Win64="$(var.Win64)">
141156
<File Id="initpy37" Name="__init__.$(var.PyExt)"

cpydist/data/msi/PY38.wxs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@
136136
</Component>
137137
</DirectoryRef>
138138

139+
<DirectoryRef Id="VendorDir38">
140+
<?if $(var.HaveLdapLibs38) = 1 ?>
141+
<Component Id="Vendor38" Guid="681a48cd-be38-11ea-84eb-04ea56793316" Win64="$(var.Win64)">
142+
<File Id="authenticationldapsaslclient38" Name="authentication_ldap_sasl_client.dll"
143+
Source="$(var.BDist38)\mysql\vendor\authentication_ldap_sasl_client.dll" DiskId="1"/>
144+
<File Id="libsasl38" Name="libsasl.dll"
145+
Source="$(var.BDist38)\mysql\vendor\libsasl.dll" DiskId="1"/>
146+
<File Id="libcrypto_1_138" Name="libcrypto-1_1-x64.dll"
147+
Source="$(var.BDist38)\mysql\vendor\libcrypto-1_1-x64.dll" DiskId="1"/>
148+
<File Id="saslSCRAM38" Name="saslSCRAM.dll"
149+
Source="$(var.BDist38)\mysql\vendor\saslSCRAM.dll" DiskId="1"/>
150+
</Component>
151+
<?endif?>
152+
</DirectoryRef>
153+
139154
<DirectoryRef Id="ConnectorPackageDir38">
140155
<Component Id="ConnectorPackage38" Guid="9915296f-c91c-4df0-b6bf-2e0686fedc3a" Win64="$(var.Win64)">
141156
<File Id="initpy38" Name="__init__.$(var.PyExt)"

cpydist/data/msi/product.wxs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
</Directory>
274274
</Directory>
275275
<Directory Id="MySQLPackageDir35" Name="mysql">
276+
<Directory Id="VendorDir35" Name="vendor"/>
276277
<Directory Id="ConnectorPackageDir35" Name="connector">
277278
<Directory Id="DjangoDir35" Name="django"/>
278279
<Directory Id="ConnectorLocalesDir35" Name="locales">
@@ -295,6 +296,7 @@
295296
</Directory>
296297
</Directory>
297298
<Directory Id="MySQLPackageDir36" Name="mysql">
299+
<Directory Id="VendorDir36" Name="vendor"/>
298300
<Directory Id="ConnectorPackageDir36" Name="connector">
299301
<Directory Id="DjangoDir36" Name="django"/>
300302
<Directory Id="ConnectorLocalesDir36" Name="locales">
@@ -317,6 +319,7 @@
317319
</Directory>
318320
</Directory>
319321
<Directory Id="MySQLPackageDir37" Name="mysql">
322+
<Directory Id="VendorDir37" Name="vendor"/>
320323
<Directory Id="ConnectorPackageDir37" Name="connector">
321324
<Directory Id="DjangoDir37" Name="django"/>
322325
<Directory Id="ConnectorLocalesDir37" Name="locales">
@@ -339,6 +342,7 @@
339342
</Directory>
340343
</Directory>
341344
<Directory Id="MySQLPackageDir38" Name="mysql">
345+
<Directory Id="VendorDir38" Name="vendor"/>
342346
<Directory Id="ConnectorPackageDir38" Name="connector">
343347
<Directory Id="DjangoDir38" Name="django"/>
344348
<Directory Id="ConnectorLocalesDir38" Name="locales">
@@ -465,6 +469,9 @@
465469
<Condition Level='0'>Not PYTHON35INSTALLPATH_ALL AND Not PYTHON35INSTALLPATH_CURRENT AND Not Installed</Condition>
466470
<ComponentRef Id="EggInfo35"/>
467471
<ComponentRef Id="MySQLPackage35"/>
472+
<?if $(var.HaveLdapLibs35) = 1 ?>
473+
<ComponentRef Id="Vendor35"/>
474+
<?endif?>
468475
<ComponentRef Id="ConnectorPackage35"/>
469476
<ComponentRef Id="ConnectorLocales35"/>
470477
<ComponentRef Id="LocalesEng35"/>
@@ -486,6 +493,9 @@
486493
<Condition Level='0'>Not PYTHON36INSTALLPATH_ALL AND Not PYTHON36INSTALLPATH_CURRENT AND Not Installed</Condition>
487494
<ComponentRef Id="EggInfo36"/>
488495
<ComponentRef Id="MySQLPackage36"/>
496+
<?if $(var.HaveLdapLibs36) = 1 ?>
497+
<ComponentRef Id="Vendor36"/>
498+
<?endif?>
489499
<ComponentRef Id="ConnectorPackage36"/>
490500
<ComponentRef Id="ConnectorLocales36"/>
491501
<ComponentRef Id="LocalesEng36"/>
@@ -507,6 +517,9 @@
507517
<Condition Level='0'>Not PYTHON37INSTALLPATH_ALL AND Not PYTHON37INSTALLPATH_CURRENT AND Not Installed</Condition>
508518
<ComponentRef Id="EggInfo37"/>
509519
<ComponentRef Id="MySQLPackage37"/>
520+
<?if $(var.HaveLdapLibs37) = 1 ?>
521+
<ComponentRef Id="Vendor37"/>
522+
<?endif?>
510523
<ComponentRef Id="ConnectorPackage37"/>
511524
<ComponentRef Id="ConnectorLocales37"/>
512525
<ComponentRef Id="LocalesEng37"/>
@@ -528,6 +541,9 @@
528541
<Condition Level='0'>Not PYTHON38INSTALLPATH_ALL AND Not PYTHON38INSTALLPATH_CURRENT AND Not Installed</Condition>
529542
<ComponentRef Id="EggInfo38"/>
530543
<ComponentRef Id="MySQLPackage38"/>
544+
<?if $(var.HaveLdapLibs38) = 1 ?>
545+
<ComponentRef Id="Vendor38"/>
546+
<?endif?>
531547
<ComponentRef Id="ConnectorPackage38"/>
532548
<ComponentRef Id="ConnectorLocales38"/>
533549
<ComponentRef Id="LocalesEng38"/>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy