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

Added bool return value to RequireSuperUser function #38124

Closed
wants to merge 1 commit into from
Closed

Added bool return value to RequireSuperUser function #38124

wants to merge 1 commit into from

Conversation

mgm702
Copy link

@mgm702 mgm702 commented Jun 10, 2019

Hello, I'm looking to make a contribution to your codebase. I was able to find a relatively simple issue that I can tackle (#32662). I've made the changes for the RequireSuperUser function and if this is still needed in the codebase I'd love to help with that.

@mgm702 mgm702 requested review from a team June 10, 2019 06:57
@mgm702 mgm702 requested a review from a team as a code owner June 10, 2019 06:57
@mgm702 mgm702 requested review from a team June 10, 2019 06:57
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Jun 10, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Hi and thank you for you contribution!

The new interface doesn't really solve the problem. If I get false and an error, is it because I'm not superuser or is it because some other error was hit? I think the interface should return false and no error if we are not super user. (and the name should be changed to something like IsSuperUser). For the common use-case we can have a shared RequireSuperUser wrapper which only returns an error and generates the "insufficient privilege" error as needed.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@RaduBerinde RaduBerinde requested a review from knz June 10, 2019 11:25
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz and @mgm702)


pkg/ccl/roleccl/role.go, line 74 at r1 (raw file):

	}

	if _, err := p.RequireSuperUser(ctx, "grant role"); err != nil {

This is an example of what Radu explained: in this code block, the err object returned by RequireSuperUser is silently dropped. This code block (and others) should:

  1. test the error; if non-nil, always return the error
  2. if no error, test the boolean
  3. only if the boolean is true (the user is a super-user) do the privileged operation

Also, if the function merely tests whether the user is a super-user, the name RequireSuperUser is not appropriate any more. I think the name IsSuperUser would be better.

@Gurio
Copy link
Contributor

Gurio commented Jun 24, 2019

@mgm702: do you plan to continue on that task? otherwise I could take over

craig bot pushed a commit that referenced this pull request Jun 30, 2019
38454: sql: require super user return status r=knz a=Gurio

Resolves #32662 as discussed with @knz (hopefully correctly)
First commit is taken from #38124 which helped to find all the necessary places where code should be changed
I didn’t check if it builds with the last fix-commit, so please don’t review until TeamCity succeeds.

Co-authored-by: Arseni Lapunov <re.stage00101@gmail.com>
@tbg tbg added the X-noremind Bots won't notify about PRs with X-noremind label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
X-noremind Bots won't notify about PRs with X-noremind
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants