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

etcd/auth: fix range handling bugs. #6404

Merged
merged 1 commit into from
Sep 13, 2016
Merged

Conversation

glycerine
Copy link
Contributor

@glycerine glycerine commented Sep 12, 2016

As discussed in #6359, I found some range handling
bugs and fixed them while looking at how to add
prefix based auth. I had a few minutes and put
together this cherry picked pr that contains only
the bug fixes, and no prefix expansion.

Test 15, counting from zero, in TestGetMergedPerms
in etcd/auth/range_perm_cache_test.go, was trying
incorrectly assert that [a, b) merged with [b, "")
should be [a, b). Added a test specifically for
this. This patch also fixes the incorrect larger test
and the bugs in the code that it was hiding.

Fixes #6359

func isSubset(a, b *rangePerm) bool {
switch {
case len(a.end) == 0 && len(b.end) == 0:
// a, b are both keys
return bytes.Equal(a.begin, b.begin)
case len(b.end) == 0:
// b is a key, a is a range
// b is a key, a is a range (even a prefix range has infinite membership)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the part (even a prefix range has infinite membership) is outdated?

@mitake
Copy link
Contributor

mitake commented Sep 12, 2016

Thanks a lot! I commented on two points which would need to be fixed.

@mitake
Copy link
Contributor

mitake commented Sep 12, 2016

Also, please update the commit log title to auth: fix range handling bugs.

Test 15, counting from zero, in TestGetMergedPerms
in etcd/auth/range_perm_cache_test.go, was trying
incorrectly assert that [a, b) merged with [b, "")
should be [a, b). Added a test specifically for
this. This patch fixes the incorrect larger test
and the bugs in the code that it was hiding.

Fixes etcd-io#6359
@glycerine
Copy link
Contributor Author

all requested updates done.

@xiang90
Copy link
Contributor

xiang90 commented Sep 13, 2016

lgtm

@xiang90 xiang90 added this to the v3.1.0 milestone Sep 13, 2016
@xiang90 xiang90 merged commit 3df8838 into etcd-io:master Sep 13, 2016
@xiang90
Copy link
Contributor

xiang90 commented Sep 13, 2016

@glycerine Thanks a lot!

@mitake
Copy link
Contributor

mitake commented Sep 13, 2016

@glycerine thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

etcdctl/ctlv3: auth: how to create /home/ directory ?
4 participants