8000 stage1/fly: make run/enter honour uid/gid/suppGids by tesujimath · Pull Request #3717 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

stage1/fly: make run/enter honour uid/gid/suppGids #3717

Merged
merged 4 commits into from
Jun 26, 2017

Conversation

tesujimath
Copy link
Contributor

Refactored common functionality out of run.

Fixes #3392, fixes #3716.

Refactored common functionality out of run.

Fixes rkt#3392, fixes rkt#3716.
@ghost
Copy link
ghost commented Jun 19, 2017

Can one of the admins verify this patch?

@tesujimath
Copy link
Contributor Author

@lucab PTAL

@lucab
Copy link
Member
lucab commented Jun 19, 2017

ok to test

@lucab
Copy link
Member
lucab commented Jun 19, 2017

It looks like this introduced a new file which is missing the license boilerplate, thus failing travis (I didn't perform a review pass yet).

@lucab lucab added this to the 1.28.0 milestone Jun 19, 2017
@tesujimath
Copy link
Contributor Author

@lucab Oops, sorry, should be OK now.

Copy link
Member
@lucab lucab left a comment

Choose a reason for hiding this comment

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

Thanks! I did a first pass on it, I think there is a bit of duplicate logic which can be reworked.


func getRuntimeApp(pm *schema.PodManifest) (*schema.RuntimeApp, error) {
if len(pm.Apps) != 1 {
return nil, fmt.Errorf("flavor %q only supports 1 application per Pod for now", flavor)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this needs to be generic on flavor name, as this directory/subtree is specific to fly.

@@ -47,6 +55,33 @@ func getRootDir(pid string) (string, error) {
return os.Readlink(rootLink)
}

func getPodManifest() (*schema.PodManifest, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this has quite a lot in common with common/types.LoadPod() and can probably just use that, or refactor/expose/move some logic from there.

)

const (
flavor = "fly"
Copy link
Member

Choose a reason for hiding this comment

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

See comment below about removing this.

// lock the current goroutine to its current OS thread.
// This will force the subsequent syscalls to be executed in the same OS thread as Setresuid, and Setresgid,
// see https://github.com/golang/go/issues/1435#issuecomment-66054163.
runtime.LockOSThread()
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be moved as one of the first steps in "enter" and "run" and here just mention that it affects only the current thread and may misbehave with free goroutines.

supplementaryGIDs []int
}

func LookupProcessCredentials(ra *schema.RuntimeApp, rfs string) (*ProcessCredentials, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to re-use parseUserGroup here (after exporting it)?

@tesujimath
Copy link
Contributor Author

@lucab I'm pretty sure I addressed all your comments now. Thanks for the review.

Copy link
Member
@lucab lucab left a comment

Choose a reason for hiding this comment

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

Thanks, just two minor comments, in general it looks almost ready to go.

}

func SetProcessCredentials(c *ProcessCredentials, diag *rktlog.Logger) error {
diag.Printf("setting credentials: uid=%d, gid=%d, suppGids=%v", c.uid, c.gid, c.supplementaryGIDs)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can move this debug logging to the caller and completely remove the logger from this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

var err error

// mock up a pod so we can call ParseUserGroup
pod := &stage1commontypes.Pod{
Copy link
Member

Choose a reason for hiding this comment

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

Why do you want to mock a pod here instead of using the real one you got in main? This is generally dangerous because of parameters implicitely initialized to their default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realized I only needed to mock the pod in enter (where we don't have one). For run, I'm now using the real one.

@tesujimath
Copy link
Contributor Author

@lucab If you're happy with the mocking of a pod just for enter (where we don't have one available), this should be good to go.

Copy link
Member
@lucab lucab left a comment

Choose a reason for hiding this comment

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

LGTM

@lucab lucab changed the title stage1/fly run/enter: honour uid/gid/suppGids. stage1/fly: make run/enter honour uid/gid/suppGids Jun 26, 2017
@lucab lucab merged commit eebaa51 into rkt:master Jun 26, 2017
@tesujimath tesujimath deleted the fly-uid-gid-for-enter branch June 26, 2017 20:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stage1/fly run should honour supplementary groups fly: enter should honor uid/gid/supp-gid
2 participants
0