Merge pull request #2170 from mvdriel/fix-add-user-with-require-ssl

Fix add user with require ssl
This commit is contained in:
Brian Coca 2016-01-12 10:45:51 -05:00
commit 30559b71dd

View file

@ -407,9 +407,9 @@ def privileges_unpack(priv):
if '*.*' not in output: if '*.*' not in output:
output['*.*'] = ['USAGE'] output['*.*'] = ['USAGE']
# if we are only specifying something like REQUIRESSL in *.* we still need # if we are only specifying something like REQUIRESSL and/or GRANT (=WITH GRANT OPTION) in *.*
# to add USAGE as a privilege to avoid syntax errors # we still need to add USAGE as a privilege to avoid syntax errors
if priv.find('REQUIRESSL') != -1 and 'USAGE' not in output['*.*']: if 'REQUIRESSL' in priv and not set(output['*.*']).difference(set(['GRANT', 'REQUIRESSL'])):
output['*.*'].append('USAGE') output['*.*'].append('USAGE')
return output return output
@ -435,10 +435,10 @@ def privileges_grant(cursor, user,host,db_table,priv):
priv_string = ",".join([p for p in priv if p not in ('GRANT', 'REQUIRESSL')]) priv_string = ",".join([p for p in priv if p not in ('GRANT', 'REQUIRESSL')])
query = ["GRANT %s ON %s" % (priv_string, mysql_quote_identifier(db_table, 'table'))] query = ["GRANT %s ON %s" % (priv_string, mysql_quote_identifier(db_table, 'table'))]
query.append("TO %s@%s") query.append("TO %s@%s")
if 'GRANT' in priv:
query.append("WITH GRANT OPTION")
if 'REQUIRESSL' in priv: if 'REQUIRESSL' in priv:
query.append("REQUIRE SSL") query.append("REQUIRE SSL")
if 'GRANT' in priv:
query.append("WITH GRANT OPTION")
query = ' '.join(query) query = ' '.join(query)
cursor.execute(query, (user, host)) cursor.execute(query, (user, host))