Skip to content

Commit aea228f

Browse files
wawa0210liggitt
authored andcommitted
fix no-new-privileges on windows
1 parent 886727a commit aea228f

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

pkg/kubelet/dockershim/docker_sandbox.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,6 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig,
666666
return createConfig, nil
667667
}
668668

669-
func (ds *dockerService) getSandBoxSecurityOpts(separator rune) []string {
670-
// run sandbox with no-new-privileges and using runtime/default
671-
// sending no "seccomp=" means docker will use default profile
672-
return []string{"no-new-privileges"}
673-
}
674-
675669
// networkNamespaceMode returns the network runtimeapi.NamespaceMode for this container.
676670
// Supports: POD, NODE
677671
func networkNamespaceMode(container *dockertypes.ContainerJSON) runtimeapi.NamespaceMode {

pkg/kubelet/dockershim/helpers_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
4848
return seccompSecurityOpts, nil
4949
}
5050

51+
func (ds *dockerService) getSandBoxSecurityOpts(separator rune) []string {
52+
// run sandbox with no-new-privileges and using runtime/default
53+
// sending no "seccomp=" means docker will use default profile
54+
return []string{"no-new-privileges"}
55+
}
56+
5157
func getSeccompDockerOpts(seccompProfile string) ([]dockerOpt, error) {
5258
if seccompProfile == "" || seccompProfile == v1.SeccompProfileNameUnconfined {
5359
// return early the default

pkg/kubelet/dockershim/helpers_unsupported.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
3636
return nil, nil
3737
}
3838

39+
func (ds *dockerService) getSandBoxSecurityOpts(separator rune) []string {
40+
klog.Warningf("getSandBoxSecurityOpts is unsupported in this build")
41+
return nil
42+
}
43+
3944
func (ds *dockerService) updateCreateConfig(
4045
createConfig *dockertypes.ContainerCreateConfig,
4146
config *runtimeapi.ContainerConfig,

pkg/kubelet/dockershim/helpers_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
4343
return nil, nil
4444
}
4545

46+
func (ds *dockerService) getSandBoxSecurityOpts(separator rune) []string {
47+
// Currently, Windows container does not support privileged mode, so no no-new-privileges flag can be returned directly like Linux
48+
// If the future Windows container has new support for privileged mode, we can adjust it here
49+
return nil
50+
}
51+
4652
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
4753
func applyExperimentalCreateConfig(createConfig *dockertypes.ContainerCreateConfig, annotations map[string]string) {
4854
if kubeletapis.ShouldIsolatedByHyperV(annotations) {

0 commit comments

Comments
 (0)