Skip to content

Commit

Permalink
Merge pull request #5981 from scuzhanglei/release-1.5-privileged-device
Browse files Browse the repository at this point in the history
  • Loading branch information
fuweid committed Sep 20, 2021
2 parents 980646e + 514137a commit 3f4f6bc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/cri/server/container_create_linux.go
Expand Up @@ -213,21 +213,17 @@ func (c *criService) containerSpec(
}
}

specOpts = append(specOpts, customopts.WithDevices(c.os, config),
customopts.WithCapabilities(securityContext, c.allCaps))

if securityContext.GetPrivileged() {
if !sandboxConfig.GetLinux().GetSecurityContext().GetPrivileged() {
return nil, errors.New("no privileged container allowed in sandbox")
}
specOpts = append(specOpts, oci.WithPrivileged)
if !ociRuntime.PrivilegedWithoutHostDevices {
specOpts = append(specOpts, oci.WithHostDevices, oci.WithAllDevicesAllowed)
} else {
// add requested devices by the config as host devices are not automatically added
specOpts = append(specOpts, customopts.WithDevices(c.os, config),
customopts.WithCapabilities(securityContext, c.allCaps))
}
} else { // not privileged
specOpts = append(specOpts, customopts.WithDevices(c.os, config),
customopts.WithCapabilities(securityContext, c.allCaps))
}

// Clear all ambient capabilities. The implication of non-root + caps
Expand Down

0 comments on commit 3f4f6bc

Please sign in to comment.