MDEV-37948 ALTER TABLE TRUNCATE PARTITION requires only DROP privilege#4601
MDEV-37948 ALTER TABLE TRUNCATE PARTITION requires only DROP privilege#4601FarihaIS wants to merge 1 commit intoMariaDB:12.2from
Conversation
|
|
| */ | ||
|
|
||
| if (check_one_table_access(thd, DROP_ACL, first_table)) | ||
| if (check_one_table_access(thd, DROP_ACL | ALTER_ACL, first_table)) |
There was a problem hiding this comment.
Please keep as is for now, but having DROP_ACL here looks misleading to my eye. DROP_ACL refers to table object, not partition object. OTOH DROP_ACL on a database implies DROP_ACL on all tables in that database.
Looks like it comes from https://bugs.mysql.com/bug.php?id=17139, but I believe ALTER_ACL gives many options to spoil table data.
There was a problem hiding this comment.
I see, please let me know what changes you would like me to make here, if any. For now, I've left it as is like you suggested, thank you
There was a problem hiding this comment.
This is more a note to other reviewers. Something to consider, I have no strong opinion on this.
ALTER TABLE ... TRUNCATE PARTITION only checks for DROP privilege, while ALTER TABLE ... DROP PARTITION correctly requires both DROP and ALTER privileges. This is inconsistent and a privilege issue since TRUNCATE PARTITION is an ALTER TABLE statement. Add ALTER privilege check to TRUNCATE PARTITION to match DROP PARTITION behavior and documentation. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
Description
ALTER TABLE ... TRUNCATE PARTITIONonly checks forDROPprivilege, whileALTER TABLE ... DROP PARTITIONcorrectly requires bothDROPandALTERprivileges. This is inconsistent and a privilege issue sinceTRUNCATE PARTITIONis anALTER TABLEstatement.Add
ALTERprivilege check toTRUNCATE PARTITIONto matchDROP PARTITIONbehavior and documentation.Release Notes
N/A
How can this PR be tested?
Execute the
main.partition_granttest in mysql-test-run. This commit adds a test inpartition_grant.test.Before the fix
A user with only
DROPprivilege can truncate partitions:After the fix
A user needs both
ALTERandDROPprivileges to truncate partitions:Basing the PR against the correct MariaDB version
Copyright
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.