Skip to content

Commit 3d358c9

Browse files
committed
[cri] don't clear base security settings
When a base runtime spec is being used, admins can configure defaults for the spec so that default ulimits or other security related settings get applied for all containers launched. Signed-off-by: Michael Crosby <[email protected]>
1 parent 7126310 commit 3d358c9

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/cri/server/container_create_linux.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,20 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3
114114

115115
specOpts := []oci.SpecOpts{
116116
customopts.WithoutRunMount,
117-
customopts.WithoutDefaultSecuritySettings,
117+
}
118+
// only clear the default security settings if the runtime does not have a custom
119+
// base runtime spec spec. Admins can use this functionality to define
120+
// default ulimits, seccomp, or other default settings.
121+
if ociRuntime.BaseRuntimeSpec == "" {
122+
specOpts = append(specOpts, customopts.WithoutDefaultSecuritySettings)
123+
}
124+
specOpts = append(specOpts,
118125
customopts.WithRelativeRoot(relativeRootfsPath),
119126
customopts.WithProcessArgs(config, imageConfig),
120127
oci.WithDefaultPathEnv,
121128
// this will be set based on the security context below
122129
oci.WithNewPrivileges,
123-
}
130+
)
124131
if config.GetWorkingDir() != "" {
125132
specOpts = append(specOpts, oci.WithProcessCwd(config.GetWorkingDir()))
126133
} else if imageConfig.WorkingDir != "" {

0 commit comments

Comments
 (0)