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

libcontainer: create Cwd when it does not exist #1604

Merged
merged 1 commit into from
Oct 5, 2017

Conversation

AkihiroSuda
Copy link
Member

The benefit for doing this within runc is that it works well with
userns.
Actually, runc already does the same thing for mount points.

discussed in containerd/containerd#1585 (cc @crosbymichael @estesp )

If this change is fine, I'll open a PR to runtime-spec correspondingly.

Signed-off-by: Akihiro Suda [email protected]

@@ -76,6 +77,13 @@ func prepareRootfs(pipe io.ReadWriter, config *configs.Config) (err error) {
}
}

// Setup Cwd before running the pre-start hooks, so that hooks can play with Cwd.
Copy link
Member

Choose a reason for hiding this comment

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

why not do this right before chdir to the cwd when the rootfs is already setup and every other mount is done and we are jailed inside the rootfs?

Copy link
Member

Choose a reason for hiding this comment

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

That's what I was about to comment 😉. That way we don't need to use CleanPath we can just use MkdirAll and nothing else. If a hook wants to mess with the cwd, they could create it themselves.

The benefit for doing this within runc is that it works well with
userns.
Actually, runc already does the same thing for mount points.

Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda
Copy link
Member Author

Updated PR. PTAL. @crosbymichael @cyphar

However, I didn't do this right before Chdir() in finalizeNamespace(), because the rootfs is remounted as read-only during finalize.Rootfs().

@cyphar
Copy link
Member

cyphar commented Oct 5, 2017

@AkihiroSuda That's fine, this should (semantically) be part of prepareRootfs anyway.

@cyphar
Copy link
Member

cyphar commented Oct 5, 2017

LGTM.

Approved with PullApprove

Copy link
Member

@crosbymichael crosbymichael left a comment

Choose a reason for hiding this comment

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

LGTM

@crosbymichael
Copy link
Member

crosbymichael commented Oct 5, 2017

LGTM

Approved with PullApprove

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

Successfully merging this pull request may close these issues.

3 participants