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

Apply more structure to pod data dirs #3403

Merged
merged 1 commit into from
Jan 12, 2015

Conversation

thockin
Copy link
Member

@thockin thockin commented Jan 12, 2015

This is makes it possible to read back "known" pods from disk without
getting other (non-pod) kubelet dirs in the mix. Ditto for containers
within a pod. This is just saner overall. Pods now nest in a pods/
dir. Likewise containers. Backwards compat code for now, but should
be stripped out before 1.0.

This is makes it possible to read back "known" pods from disk without
getting other (non-pod) kubelet dirs in the mix.  Ditto for containers
within a pod.  This is just saner overall.  Pods now nest in a pods/
dir.  Likewise containers.
func (kl *Kubelet) GetPodsDir() string {
return kl.GetRootDir()
return path.Join(kl.GetRootDir(), "pods")
}

// GetPodDir returns the full path to the per-pod data directory for the
// specified pod. This directory may not exist if the pod does not exist.
func (kl *Kubelet) GetPodDir(podUID string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry about security here. A sanity check that there are no special characters here would help. This is the type of code that can often lead to a directory traversal attack.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I follow. GetRootDir() is controlled by kubelet, so any trickery would have to come through the flag that controls root dir. If you are setting flags you are already root. The joining of pod UID and container name predicate on the validation done before we accept a pod.

Can you clarify what sort of attack you are conceiving of? Caveat, I suck at security analysis.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm mostly worried about the container name (and perhaps the UID). While I know we validate that higher up, defense in depth is the name of the game.

@jbeda
Copy link
Contributor

jbeda commented Jan 12, 2015

LGTM -- the extra security check would be good but the code already is missing it so this is a no-op from that point of view.

Feel free to add something or self merge.

thockin added a commit that referenced this pull request Jan 12, 2015
Apply more structure to pod data dirs
@thockin thockin merged commit af0e2fd into kubernetes:master Jan 12, 2015
@thockin thockin deleted the klet-dirs-structure branch March 2, 2015 05:26
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.

2 participants