Merge pull request #1272 from bdflemin/issue1120
allows to privileges using columns in mysql_user
This commit is contained in:
commit
4ee18957dc
1 changed files with 10 additions and 3 deletions
|
@ -157,6 +157,7 @@ password=n<_665{vS43y
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import re
|
||||||
try:
|
try:
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -316,13 +317,19 @@ def privileges_unpack(priv):
|
||||||
not specified in the string, as MySQL will always provide this by default.
|
not specified in the string, as MySQL will always provide this by default.
|
||||||
"""
|
"""
|
||||||
output = {}
|
output = {}
|
||||||
|
privs = []
|
||||||
for item in priv.strip().split('/'):
|
for item in priv.strip().split('/'):
|
||||||
pieces = item.strip().split(':')
|
pieces = item.strip().split(':')
|
||||||
dbpriv = pieces[0].rsplit(".", 1)
|
dbpriv = pieces[0].rsplit(".", 1)
|
||||||
pieces[0] = "`%s`.%s" % (dbpriv[0].strip('`'), dbpriv[1])
|
pieces[0] = "`%s`.%s" % (dbpriv[0].strip('`'), dbpriv[1])
|
||||||
|
if '(' in pieces[1]:
|
||||||
output[pieces[0]] = [s.strip() for s in pieces[1].upper().split(',')]
|
output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper())
|
||||||
new_privs = frozenset(output[pieces[0]])
|
for i in output[pieces[0]]:
|
||||||
|
privs.append(re.sub(r'\(.*\)','',i))
|
||||||
|
else:
|
||||||
|
output[pieces[0]] = pieces[1].upper().split(',')
|
||||||
|
privs = output[pieces[0]]
|
||||||
|
new_privs = frozenset(privs)
|
||||||
if not new_privs.issubset(VALID_PRIVS):
|
if not new_privs.issubset(VALID_PRIVS):
|
||||||
raise InvalidPrivsError('Invalid privileges specified: %s' % new_privs.difference(VALID_PRIVS))
|
raise InvalidPrivsError('Invalid privileges specified: %s' % new_privs.difference(VALID_PRIVS))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue