Skip to content

Commit 9dbdd89

Browse files
committed
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 <query> must have \\ substituted with \.
1 parent 40dd180 commit 9dbdd89

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/puppet/provider/mysql_grant/mysql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def self.instances
2929
# Matching: GRANT (SELECT, UPDATE) PRIVILEGES ON (*.*) TO ('root')@('127.0.0.1') (WITH GRANT OPTION)
3030
if match = munged_grant.match(/^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$/)
3131
privileges, table, user, host, rest = match.captures
32+
table.gsub!('\\\\', '\\')
33+
3234
# split on ',' if it is not a non-'('-containing string followed by a
3335
# closing parenthesis ')'-char - e.g. only split comma separated elements not in
3436
# parentheses

0 commit comments

Comments
 (0)