Skip to content

Commit

Permalink
container_create: honor readonly and masked paths from the CRI
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
  • Loading branch information
runcom committed Oct 18, 2018
1 parent 8474b0f commit b1f9231
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/container_create_linux.go
Expand Up @@ -496,6 +496,8 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,

if containerConfig.GetLinux().GetSecurityContext() != nil &&
!containerConfig.GetLinux().GetSecurityContext().Privileged {
// TODO(runcom): have just one of this var at the top of the function
securityContext := containerConfig.GetLinux().GetSecurityContext()
for _, mp := range []string{
"/proc/acpi",
"/proc/kcore",
Expand All @@ -509,6 +511,12 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
} {
specgen.AddLinuxMaskedPaths(mp)
}
if securityContext.GetMaskedPaths() != nil {
specgen.Spec().Linux.MaskedPaths = nil
for _, path := range securityContext.GetMaskedPaths() {
specgen.AddLinuxMaskedPaths(path)
}
}

for _, rp := range []string{
"/proc/asound",
Expand All @@ -520,6 +528,12 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
} {
specgen.AddLinuxReadonlyPaths(rp)
}
if securityContext.GetReadonlyPaths() != nil {
specgen.Spec().Linux.ReadonlyPaths = nil
for _, path := range securityContext.GetReadonlyPaths() {
specgen.AddLinuxReadonlyPaths(path)
}
}
}
}
// Join the namespace paths for the pod sandbox container.
Expand Down

0 comments on commit b1f9231

Please sign in to comment.