Merge lp:~james-page/charm-helpers/flush-after-grant into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 701
Proposed branch: lp:~james-page/charm-helpers/flush-after-grant
Merge into: lp:charm-helpers
Diff against target: 24 lines (+8/-0)
1 file modified
charmhelpers/contrib/database/mysql.py (+8/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/flush-after-grant
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Review via email: mp+318750@code.launchpad.net

Description of the change

Ensure that priviledges are flushed after creating new grants

After new grants are created in the database, all priviledges should
be flushed to ensure that the new grants actually work.

See https://dev.mysql.com/doc/refman/5.7/en/privilege-changes.html
See bug 1513239.

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/database/mysql.py'
2--- charmhelpers/contrib/database/mysql.py 2017-02-28 12:04:36 +0000
3+++ charmhelpers/contrib/database/mysql.py 2017-03-02 11:27:57 +0000
4@@ -142,6 +142,13 @@
5 finally:
6 cursor.close()
7
8+ def flush_priviledges(self):
9+ cursor = self.connection.cursor()
10+ try:
11+ cursor.execute("FLUSH PRIVILEGES")
12+ finally:
13+ cursor.close()
14+
15 def execute(self, sql):
16 """Execute arbitary SQL against the database."""
17 cursor = self.connection.cursor()
18@@ -323,6 +330,7 @@
19 self.create_grant(database, username, remote_ip, password)
20 else:
21 self.create_admin_grant(username, remote_ip, password)
22+ self.flush_priviledges()
23
24 return password
25

Subscribers

People subscribed via source and target branches