Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

privilege: fix user change after show grants and add user existed check for show grants (#19568) #19588

Merged
merged 3 commits into from
Sep 4, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #19568 to release-4.0


What problem does this PR solve?

Issue Number: close #18878

Problem Summary:

  • select user() returns different result after execute show grants
  • show grants can show grants on not existed user.

What is changed and how it works?

What's Changed:

  • Do not use auth.UserIdentity pointer on show grants.
  • Add check in showGrants to avoid executed on not existed user.

How it Works:

Because of SHOW GRANTS change the content in auth.Identity, when execute SHOW GRANTS, it will change the host of User in session variable. The result of select user() will changed.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • None

Release note

  • Fix SHOW GRANTS can show grants for not existed user.

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@imtbkcat please accept the invitation then you can push to the cherry-pick pull requests.
https://github.com/ti-srebot/tidb/invitations

@bb7133
Copy link
Member

bb7133 commented Sep 1, 2020

Please resolve the conflicts @imtbkcat

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 2, 2020
@tiancaiamao
Copy link
Contributor

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 3, 2020
@zz-jason
Copy link
Member

zz-jason commented Sep 4, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 4, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit 5f03307 into pingcap:release-4.0 Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/privilege sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants