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

privileges: add SkipWithGrant check for RBAC methods #10681

Merged
merged 5 commits into from Jun 5, 2019

Conversation

Projects
None yet
4 participants
@imtbkcat
Copy link
Contributor

commented Jun 3, 2019

What problem does this PR solve?

RBAC methods in privileges package did not check SkipWithGrant. This cause panic when enable --skip-grant-table.

What is changed and how it works?

add check for SkipWithGrant, when SkipWithGrant is enabled, calling for RBAC method will be ignored.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
@codecov

This comment has been minimized.

Copy link

commented Jun 3, 2019

Codecov Report

❗️ No coverage uploaded for pull request base (master@f7a8f4e). Click here to learn what that means.
The diff coverage is 60%.

@@             Coverage Diff             @@
##             master     #10681   +/-   ##
===========================================
  Coverage          ?   79.6625%           
===========================================
  Files             ?        414           
  Lines             ?      87656           
  Branches          ?          0           
===========================================
  Hits              ?      69829           
  Misses            ?      12650           
  Partials          ?       5177
@@ -185,6 +185,10 @@ func (p *UserPrivileges) UserPrivilegesTable() [][]types.Datum {

// ShowGrants implements privilege.Manager ShowGrants interface.
func (p *UserPrivileges) ShowGrants(ctx sessionctx.Context, user *auth.UserIdentity, roles []*auth.RoleIdentity) (grants []string, err error) {
if SkipWithGrant {
grants, err = nil, errNonexistingGrant.GenWithStackByArgs()

This comment has been minimized.

Copy link
@jackysp

jackysp Jun 3, 2019

Member

why not

Suggested change
grants, err = nil, errNonexistingGrant.GenWithStackByArgs()
return nil, errNonexistingGrant.GenWithStackByArgs()

This comment has been minimized.

Copy link
@jackysp

jackysp Jun 3, 2019

Member

what will this error look like?

This comment has been minimized.

Copy link
@imtbkcat

imtbkcat Jun 4, 2019

Author Contributor

PTAL @jackysp

@jackysp
Copy link
Member

left a comment

Could you add some test cases?

imtbkcat added some commits Jun 4, 2019

@@ -185,6 +185,9 @@ func (p *UserPrivileges) UserPrivilegesTable() [][]types.Datum {

// ShowGrants implements privilege.Manager ShowGrants interface.
func (p *UserPrivileges) ShowGrants(ctx sessionctx.Context, user *auth.UserIdentity, roles []*auth.RoleIdentity) (grants []string, err error) {
if SkipWithGrant {
return nil, errNonexistingGrant.GenWithStackByArgs()

This comment has been minimized.

Copy link
@jackysp

jackysp Jun 4, 2019

Member

What will this error look like?

@tiancaiamao

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

LGTM

@jackysp

jackysp approved these changes Jun 4, 2019

Copy link
Member

left a comment

LGTM

@jackysp

This comment has been minimized.

Copy link
Member

commented Jun 4, 2019

/run-all-tests

@jackysp

This comment has been minimized.

Copy link
Member

commented Jun 4, 2019

Please cherry-pick this PR to release 3.0.

@jackysp

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

/run-unit-test

@jackysp

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

/run-integration-ddl-test

@zz-jason zz-jason merged commit e9ab859 into pingcap:master Jun 5, 2019

8 checks passed

ci/circleci Your tests passed on CircleCI!
Details
codecov/patch 60% of diff hit (target 0%)
Details
codecov/project No report found to compare against
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

imtbkcat added a commit to imtbkcat/tidb that referenced this pull request Jun 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.