From 9dbdd89c7ab35783981948e3802f8c57d213a5b7 Mon Sep 17 00:00:00 2001 From: Scott Kroll Date: Wed, 5 Nov 2014 14:53:14 -0500 Subject: [PATCH] Fix escaped backslashes in grants * Mysql uses the underscore character to represent a single character wildcard. * A grant on table `the_database`.* would match `theAdatabase`.*, so underscores must be escaped to avoid this match. * The output from mysql escapes special characters (\n, \t, \0, and \\), but the input does not need to be escaped. * In order for the provider to compare the tables, the output of mysql -NBe must have \\ substituted with \. --- lib/puppet/provider/mysql_grant/mysql.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puppet/provider/mysql_grant/mysql.rb b/lib/puppet/provider/mysql_grant/mysql.rb index 32211e36a..a44ade4dd 100644 --- a/lib/puppet/provider/mysql_grant/mysql.rb +++ b/lib/puppet/provider/mysql_grant/mysql.rb @@ -29,6 +29,8 @@ def self.instances # Matching: GRANT (SELECT, UPDATE) PRIVILEGES ON (*.*) TO ('root')@('127.0.0.1') (WITH GRANT OPTION) if match = munged_grant.match(/^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$/) privileges, table, user, host, rest = match.captures + table.gsub!('\\\\', '\\') + # split on ',' if it is not a non-'('-containing string followed by a # closing parenthesis ')'-char - e.g. only split comma separated elements not in # parentheses