[MDEV-19899] Multiple matching grants no longer stacked Created: 2019-06-28 Updated: 2019-08-22 Resolved: 2019-08-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Authentication and Privilege System |
| Affects Version/s: | 10.4 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | sjon | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | regression | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Since upgrading from 10.3.16 to 10.4.6 our grants no longer work the same. I suspect this is caused by the linked GRANT SELECT ON `%-development`.* TO 'user'@'127.0.0.1'; this used to work fine. It no longer does (for some users). Reproducible testcase: create user 'jtest'@'127.0.0.1' identified by 'jtest'; (as user jtest)
|
| Comments |
| Comment by Vladislav Vaintroub [ 2019-06-29 ] | |||||||||||||||||||||||||||||||||||||||||
|
The multiple matching grants were never stacked. I guess (in absence of full information), that you have both user@localhost accounts, as well as | |||||||||||||||||||||||||||||||||||||||||
| Comment by sjon [ 2019-07-02 ] | |||||||||||||||||||||||||||||||||||||||||
|
I only have @127.0.0.1 definitions on this server: both select count(*) from mysql.user where Host='localhost'; and select count(*) from mysql.db where Host='localhost'; return 0 I've updated the original report-description. I realize 'stacked' might not be the proper term - but can you confirm whether or not the behavior as described in the testcase is correct or not? | |||||||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2019-07-31 ] | |||||||||||||||||||||||||||||||||||||||||
|
Thanks! Reproduced as described on 10.4, test passes on 10.3:
| |||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2019-08-22 ] | |||||||||||||||||||||||||||||||||||||||||
|
This is not a bug. Old behavior was incorrect. The documentation states that all grants are sorted in order from most specific to least specific. And the first matching grant is applied. You have
and you expect INSERT INTO `j-test`.t1 to work (grant on j-% is applied, not grant on %test). This used to work because MariaDB incorrectly sorted %test grants after j-% grants, considering j-% grant as "more specific". This was incorrect, because there are fewer valid database names that match the %test pattern, so it is more specific and should've been sorted first. This bug was fixed in 10.4. Note, that if you swap your grants, like in
you'll get an opposite effect, INSERT INTO `j-test` will work in 10.4 and will fail in 10.3. |