# HG changeset patch # User Daniele Nicolodi # Date 1321888213 -3600 # Node ID 66de4aa7d53ac8ddf93e68ef2c8c8f384fa74289 # Parent 5b749cb6aa22ea5fbd846c80ee1c0d51585cca28 Fix unprivileged user permissions in upgrade step. diff -r 5b749cb6aa22 -r 66de4aa7d53a src/ltpdarepo/upgrade.py --- a/src/ltpdarepo/upgrade.py Mon Nov 21 16:10:12 2011 +0100 +++ b/src/ltpdarepo/upgrade.py Mon Nov 21 16:10:13 2011 +0100 @@ -82,9 +82,19 @@ def upgrade_24_to_25(conn, **kwargs): curs = conn.cursor() + username = kwargs.get('USERNAME') + database = kwargs.get('DATABASE') + # make mysql beheave: use sql strict mode curs.execute("""SET GLOBAL SQL_MODE='STRICT_TRANS_TABLES'""") + # update permissions for super user + if username != 'root': + curs.execute("""REVOKE RELOAD, ALTER + ON *.* FROM %s@'localhost'""", username) + curs.execute("""GRANT EXECUTE, CREATE TEMPORARY TABLES + ON `%s`.* TO %%s@'localhost'""" % database, username) + # consolidate privileges: there is no need to specify grants # both for 'localhost' and for '%' hosts. drop privileges granted # for hosts different than '%'