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:10.6from
Conversation
|
|
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution. This is a preliminary review.
First things first: PLEASE sign the CLA. Click on the button saying "CLA not signed yet" and make sure it is signed.
Next, rebase your diff to the 10.6 branch. This is a bug, not a feature. And it needs to be fixed as such.
Then please take a look at the comments below and (at least) fix the tests and the check to be an OR check.
mysql-test/main/partition_grant.test
Outdated
| revoke all privileges on mysqltest_1.* from mysqltest_1@localhost; | ||
| grant drop on mysqltest_1.* to mysqltest_1@localhost; | ||
|
|
||
| connect (conn6,localhost,mysqltest_1,,mysqltest_1); |
There was a problem hiding this comment.
Typically mysqltest would continue right after getting the OK from the server. The server sends the OK as early as humanely possible so that it doesn't slow the client down. But the session can linger on for some time until the server eventually clears it up at the background. This can account for nasty sporadic failures in testing.
This is why, as a rule of thumb, we always source include/count_sessions.inc at the start of a test that executes connect() and then, when cleaning up, we source include/wait_until_count_sessions.inc to ensure that all the sessions created by the test are properly disposed of before we continue.
Please use the above .inc files as described. Plenty of examples of that throughout the test suite to copy from.
There was a problem hiding this comment.
No, please don't. This concept has proven to be broken, we mustn't spread it further.
There was a problem hiding this comment.
Onee problem is that count_sessions.inc itself can be affected by such lingering connections. Be that connections from preceding tests or mysqltest utility connections. Or even valid connections that were created before count_sessions.inc was included and then went away in the middle of the test.
The most common case that I observed was lingering mysqltest "check testcase" connection making count_sessions.inc record value of "2" instead of expected "1". Which makes wait_until_count_sessions.inc in preceding tests meaningless.
Instead we either filter out unwanted connections in affected tests by adding WHERE clause or add let $count_sessions= 1; and then wait_until_count_sessions.inc when it is impossible (like SHOW PROCESSLIST).
There was a problem hiding this comment.
true. But even in that case it won't hurt I guess. It'd be a no-op at best, right? And it still has the potential to improve the stability of the test in case count_sessions.inc worked as expected.
So, in my book, there's still some benefit in having these. And it might even increase with time if we fix count_sesisons to be more robust. But this will happen only if we keep including these.
There was a problem hiding this comment.
Sorry, but this sounds like "false feeling of safety" in OCD terms. :)
It is just a garbage, it doesn't bring any value.
There was a problem hiding this comment.
So you do not agree that there's added value in having these in case count_sessions.inc works? What makes you think that? It will work most of the times.
There was a problem hiding this comment.
There was a problem hiding this comment.
let's leave this for the final reviewer then. It looks like you and me disagree on the topic.
ALTER TABLE ... TRUNCATE PARTITION only checks for DROP privilege, which is inconsistent with the expectation that ALTER TABLE statements should require ALTER privilege. This creates a privilege gap since users with only DROP can truncate partitions without ALTER rights. Add ALTER privilege check to TRUNCATE PARTITION, allowing either DROP or ALTER privilege for backwards compatibility. This matches the intended behavior while preserving existing functionality. 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.
We are currently reviewing whether we can sign the CLA bot as per our internal contribution procedures, so I will hold off on this for a moment.
Done, the PR is now targeting the 10.6 branch. I have also updated the PR description to reflect this.
I believe all the comments (except the one that reads like below) have been addressed. I fixed the tests and also modified the check to be an OR check. Do you think the diff looks good now? If not, please let me know and I can make further changes, thank you!
|
@FarihaIS, don't worry about CLA, you do not need to sign it. The rule always was CLA or BSD You wrote above that this PR is contributed under BSD (as AWS contributions always are), this is sufficient. Thank you! |
gkodinov
left a comment
There was a problem hiding this comment.
LGTM. thank you for working on this. Please stand by for the final review.
Description
ALTER TABLE ... TRUNCATE PARTITIONonly checks for DROP privilege, which is inconsistent with the expectation thatALTER TABLEstatements should requireALTERprivilege. This creates a privilege gap since users with onlyDROPcan truncate partitions withoutALTERrights.Add
ALTERprivilege check toTRUNCATE PARTITION, allowing eitherDROPorALTERprivilege for backwards compatibility. This matches the intended behavior while preserving existing functionality.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
ALTERprivilege cannot truncate partitions (only DROP works):After the fix
A user needs either
ALTERorDROPprivilege to truncate partitions. Users with neither privilege are denied: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.