This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
tests: fix when $HOME is only accessible by current user #3559
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lucab
changed the title
Test/CommandsNeedRoot: Fix when ~/ is only accesible by current user
tests: fix when ~/ is only accesible by current user
Jan 25, 2017
lucab
changed the title
tests: fix when ~/ is only accesible by current user
tests: fix when $HOME is only accesible by current user
Jan 25, 2017
jonboulle
changed the title
tests: fix when $HOME is only accesible by current user
tests: fix when $HOME is only accessible by current user
Jan 25, 2017
It looks like the flakes are related to #3477. |
It looks like there are some more cases not covered here, so deferring review to next iteration. |
mxinden
force-pushed
the
master
branch
2 times, most recently
from
January 26, 2017 10:12
4e7d548
to
e9993b0
Compare
Fixes #1737 |
s-urbaniak
approved these changes
Jan 26, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fedora24 failure is a known flake, this LGTM, thanks 🎉!
Leaving the last word to @lucab
lucab
suggested changes
Jan 26, 2017
@@ -220,6 +221,19 @@ func (ctx *RktRunCtx) rktBin() string { | |||
return abs | |||
} | |||
|
|||
func (ctx *RktRunCtx) GetUidGidRktBinOwnerNotRoot() (int, int) { | |||
s, _ := os.Stat(ctx.rktBin()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may error out for some reason, in which case we implicitly panic here below. Better to check for error and fallback to GetUnprivilegedUidGid() in that case.
Previously tested by executing rkt binary with user "nobody". This fails when the $HOME folder of the user is only accessible by the user itself. Now the tests first choose the owner of the rkt binary file and if that is root they use the "nobody" user as a fallback.
lucab
approved these changes
Jan 30, 2017
This fixes that test for me: diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go
index 5794424..98546f9 100644
--- a/tests/rkt_non_root_test.go
+++ b/tests/rkt_non_root_test.go
@@ -38,7 +38,9 @@ func TestNonRootReadInfo(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
- gid, err := common.LookupGid(common.RktGroup)
+ uid, _ := ctx.GetUidGidRktBinOwnerNotRoot()
+
+ rktGid, err := common.LookupGid(common.RktGroup)
if err != nil {
t.Skipf("Skipping the test because there's no %q group", common.RktGroup)
}
@@ -82,7 +84,7 @@ func TestNonRootReadInfo(t *testing.T) {
imgListCmd := fmt.Sprintf("%s image list", ctx.Cmd())
t.Logf("Running %s", imgListCmd)
- runRktAsGidAndCheckOutput(t, imgListCmd, "inspect-", false, gid)
+ runRktAsUidGidAndCheckOutput(t, imgListCmd, "inspect-", false, uid, rktGid)
} |
Fix is waiting in #3580 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously CommandsNeedRoot tested by executing rkt binary with user
"nobody". This fails when the ~/ folder of the user is only accessible
by the user itself. Now the test first chooses the owner of the rkt
binary file and if that is root it uses the "nobody" user as a fallback.
Fixes #1737