fix MySQL tls_requires not removed from user passed as empty

This commit is contained in:
Laurent Indermuehle 2024-04-11 19:07:42 +02:00
parent d77be1ba03
commit d7997f83b0
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09

View file

@ -45,7 +45,6 @@ def get_tls_requires(cursor, user, host):
Returns: Dictionary containing current TLS required
"""
if user:
if not use_old_user_mgmt(cursor):
query = "SHOW CREATE USER '%s'@'%s'" % (user, host)
else:
@ -64,10 +63,14 @@ def get_tls_requires(cursor, user, host):
requires_match = re.search(pattern, grants_str)
requires = requires_match.group().strip() if requires_match else ""
if any((requires.startswith(req) for req in ('SSL', 'X509', 'NONE'))):
requires = requires.split()[0]
if requires == 'NONE':
requires = None
if requires.startswith('NONE'):
return None
if requires.startswith('SSL'):
return {'SSL': None}
if requires.startswith('X509'):
return {'X509': None}
items = iter(shlex.split(requires))
requires = dict(zip(items, items))