distal-attribute
distal-attribute
distal-attribute
distal-attribute

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

mrforsythexeter posted 1 year ago in General
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 posted 1 year ago
Yes that's probably a limitation caused by my regular expression logic on the results of SHOW GRANTS FOR XYZ.
mrforsythexeter posted 1 year ago
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 posted 1 year ago
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 posted 1 year ago
hmm.

ansgar posted 1 year ago
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.