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

Merged
merged 4 commits into from
Aug 28, 2020

Conversation

imtbkcat
Copy link

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.

@imtbkcat imtbkcat requested review from lysu and tiancaiamao August 28, 2020 06:23
@imtbkcat imtbkcat requested a review from a team as a code owner August 28, 2020 06:23
@imtbkcat imtbkcat requested review from wshwsh12 and removed request for a team August 28, 2020 06:23
@github-actions github-actions bot added the sig/execution SIG execution label Aug 28, 2020
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 Aug 28, 2020
@lysu lysu requested a review from bb7133 August 28, 2020 07:05
@tiancaiamao
Copy link
Contributor

LGTM

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

/merge

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

Your auto merge job has been accepted, waiting for:

  • 19482

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@imtbkcat merge failed.

@imtbkcat
Copy link
Author

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@imtbkcat merge failed.

@lysu
Copy link
Contributor

lysu commented Aug 28, 2020

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 6fdd609 into pingcap:master Aug 28, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 28, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-3.0 in PR #19587

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 28, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #19588

ti-srebot added a commit that referenced this pull request Sep 3, 2020
…heck for `show grants` (#19568) (#19587)

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
ti-srebot added a commit that referenced this pull request Sep 4, 2020
…heck for `show grants` (#19568) (#19588)

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tidb v4.0.3 select user information will change after show grants is executed
4 participants