Skip to content

libcontainer: create Cwd when it does not exist#1604

Merged
crosbymichael merged 1 commit intoopencontainers:masterfrom
AkihiroSuda:cwd
Oct 5, 2017
Merged

libcontainer: create Cwd when it does not exist#1604
crosbymichael merged 1 commit intoopencontainers:masterfrom
AkihiroSuda:cwd

Conversation

@AkihiroSuda
Copy link
Copy Markdown
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]

Comment thread libcontainer/rootfs_linux.go Outdated
}
}

// Setup Cwd before running the pre-start hooks, so that hooks can play with Cwd.
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

cyphar commented Oct 5, 2017

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

@cyphar
Copy link
Copy Markdown
Member

cyphar commented Oct 5, 2017

LGTM.

Approved with PullApprove

Copy link
Copy Markdown
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
Copy Markdown
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