Added support for FUNCTION and PROCEDURE privileges to mysql_user (#23223)

This commit is contained in:
mklassen 2018-11-09 00:56:30 -05:00 committed by Tim Rupp
parent 7290bc23b8
commit 2fce8010b4

View file

@ -461,12 +461,20 @@ def privileges_unpack(priv, mode):
for item in priv.strip().split('/'): for item in priv.strip().split('/'):
pieces = item.strip().rsplit(':', 1) pieces = item.strip().rsplit(':', 1)
dbpriv = pieces[0].rsplit(".", 1) dbpriv = pieces[0].rsplit(".", 1)
# Check for FUNCTION or PROCEDURE object types
parts = dbpriv[0].split(" ", 1)
object_type = ''
if len(parts) > 1 and (parts[0] == 'FUNCTION' or parts[0] == 'PROCEDURE'):
object_type = parts[0] + ' '
dbpriv[0] = parts[1]
# Do not escape if privilege is for database or table, i.e. # Do not escape if privilege is for database or table, i.e.
# neither quote *. nor .* # neither quote *. nor .*
for i, side in enumerate(dbpriv): for i, side in enumerate(dbpriv):
if side.strip('`') != '*': if side.strip('`') != '*':
dbpriv[i] = '%s%s%s' % (quote, side.strip('`'), quote) dbpriv[i] = '%s%s%s' % (quote, side.strip('`'), quote)
pieces[0] = '.'.join(dbpriv) pieces[0] = object_type + '.'.join(dbpriv)
if '(' in pieces[1]: if '(' in pieces[1]:
output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper()) output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper())