User Manager and database with dot "." in database name

mrforsythexeter's profile image mrforsythexeter posted 11 years ago in General Permalink
It appears the user manager will allow you set permissions for a user to a database correctly, however it wont show you the permissions later if the database has a dot in the name.
ansgar's profile image ansgar posted 11 years ago Permalink
Yes that's probably a limitation caused by my regular expression logic on the results of SHOW GRANTS FOR XYZ.
mrforsythexeter's profile image mrforsythexeter posted 11 years ago Permalink
Looking at the source of usermanger.pas around line 499. I think the regular expression is simply not expecting the result I am getting from the show grants user@host. I have hidden detail in the lines below, but as you can see you from regex, only one matches.

Grants for user@localhost
GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD '*****************************************'
GRANT ALL PRIVILEGES ON `database.name`.* TO 'user'@'localhost'
GRANT ALL PRIVILEGES ON `database.name`.* TO 'user'@'localhost'

I am trying to fix the regular expression.. but maybe there is a better way to query the information?




mrforsythexeter's profile image mrforsythexeter posted 11 years ago Permalink
This may help, but you should look at your matches offset

^GRANT\s+(.+)(\s+|PRIVILEGES)?ON\s+((TABLE|FUNCTION|PROCEDURE|ON)\s+)?`?(.*?)`?\sTO\s'(.*?)'@'(.*?)'($|(\s+IDENTIFIED\s+BY\s+(PASSWORD)?\s+''?([^'']+)''?)?(\s+.+)?$)

it may also not be as safe as yours, as you understand the different database's in play. Hope it helps in some small way since I don't understand the language you have coded it in.
jfalch's profile image jfalch posted 11 years ago Permalink
hmm.
Code modification/commit from ansgar.becker, 11 years ago, revision 7.0.0.4392
Expect dots in database and table names, when parsing SHOW GRANTS results. See http://www.heidisql.com/forum.php?t=12640
ansgar's profile image ansgar posted 11 years ago Permalink
Do never use ".*?" - that means "probably 0 of any char, but probably 0 of these chars". If you insert question marks at random positions you will get ambiguous matches.

However, I modified the regex so it expects an unquoted "*", or a must-quoted identifier. This way, I can proceed to the next backtick, and dots are included in identifiers. Please update to r4392.

Please login to leave a reply, or register at first.