Skip to content

Commit 3f4f6bc

Browse files
authored
Merge pull request containerd#5981 from scuzhanglei/release-1.5-privileged-device
2 parents 980646e + 514137a commit 3f4f6bc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pkg/cri/server/container_create_linux.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,21 +213,17 @@ func (c *criService) containerSpec(
213213
}
214214
}
215215

216+
specOpts = append(specOpts, customopts.WithDevices(c.os, config),
217+
customopts.WithCapabilities(securityContext, c.allCaps))
218+
216219
if securityContext.GetPrivileged() {
217220
if !sandboxConfig.GetLinux().GetSecurityContext().GetPrivileged() {
218221
return nil, errors.New("no privileged container allowed in sandbox")
219222
}
220223
specOpts = append(specOpts, oci.WithPrivileged)
221224
if !ociRuntime.PrivilegedWithoutHostDevices {
222225
specOpts = append(specOpts, oci.WithHostDevices, oci.WithAllDevicesAllowed)
223-
} else {
224-
// add requested devices by the config as host devices are not automatically added
225-
specOpts = append(specOpts, customopts.WithDevices(c.os, config),
226-
customopts.WithCapabilities(securityContext, c.allCaps))
227226
}
228-
} else { // not privileged
229-
specOpts = append(specOpts, customopts.WithDevices(c.os, config),
230-
customopts.WithCapabilities(securityContext, c.allCaps))
231227
}
232228

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

0 commit comments

Comments
 (0)