Skip to content

Fix escaped backslashes in grants #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2014

Conversation

skroll
Copy link
Contributor

@skroll skroll commented Nov 5, 2014

  • 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 .

* 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 \.
@igalic
Copy link
Contributor

igalic commented Nov 6, 2014

and I presume it's not enough to quote?

@skroll
Copy link
Contributor Author

skroll commented Nov 6, 2014

Unfortunately no, if you quote it, a _ is still a wildcard.

You can also pass --raw/-r to the shell command, but that will also cause \n, \t, and \0 to not be escaped. I highly doubt there will be NUL or tabs in grant tables, but that seems downright dangerous.

igalic added a commit that referenced this pull request Nov 7, 2014
Fix escaped backslashes in grants
@igalic igalic merged commit 8dd37ae into puppetlabs:master Nov 7, 2014
@igalic
Copy link
Contributor

igalic commented Nov 7, 2014

okay, thanks for the explanation and the patch @skroll!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants