Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
76518f15
Unverified
Commit
76518f15
authored
Sep 18, 2018
by
k8s-ci-robot
Committed by
GitHub
Sep 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68803 from dims/avoid-setting-masked-read-only-when-pod-is-privilged
Avoid setting Masked/ReadOnly paths when pod is privileged
parents
9a5857b1
02489f89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
security_context.go
pkg/kubelet/dockershim/security_context.go
+4
-2
security_context_test.go
pkg/kubelet/dockershim/security_context_test.go
+21
-0
No files found.
pkg/kubelet/dockershim/security_context.go
View file @
76518f15
...
@@ -137,8 +137,10 @@ func modifyHostConfig(sc *runtimeapi.LinuxContainerSecurityContext, hostConfig *
...
@@ -137,8 +137,10 @@ func modifyHostConfig(sc *runtimeapi.LinuxContainerSecurityContext, hostConfig *
hostConfig
.
SecurityOpt
=
append
(
hostConfig
.
SecurityOpt
,
"no-new-privileges"
)
hostConfig
.
SecurityOpt
=
append
(
hostConfig
.
SecurityOpt
,
"no-new-privileges"
)
}
}
hostConfig
.
MaskedPaths
=
sc
.
MaskedPaths
if
!
hostConfig
.
Privileged
{
hostConfig
.
ReadonlyPaths
=
sc
.
ReadonlyPaths
hostConfig
.
MaskedPaths
=
sc
.
MaskedPaths
hostConfig
.
ReadonlyPaths
=
sc
.
ReadonlyPaths
}
return
nil
return
nil
}
}
...
...
pkg/kubelet/dockershim/security_context_test.go
View file @
76518f15
...
@@ -110,11 +110,27 @@ func TestModifyContainerConfig(t *testing.T) {
...
@@ -110,11 +110,27 @@ func TestModifyContainerConfig(t *testing.T) {
func
TestModifyHostConfig
(
t
*
testing
.
T
)
{
func
TestModifyHostConfig
(
t
*
testing
.
T
)
{
setNetworkHC
:=
&
dockercontainer
.
HostConfig
{}
setNetworkHC
:=
&
dockercontainer
.
HostConfig
{}
// When we have Privileged pods, we do not need to use the
// Masked / Readonly paths.
setPrivSC
:=
&
runtimeapi
.
LinuxContainerSecurityContext
{}
setPrivSC
:=
&
runtimeapi
.
LinuxContainerSecurityContext
{}
setPrivSC
.
Privileged
=
true
setPrivSC
.
Privileged
=
true
setPrivSC
.
MaskedPaths
=
[]
string
{
"/hello/world/masked"
}
setPrivSC
.
ReadonlyPaths
=
[]
string
{
"/hello/world/readonly"
}
setPrivHC
:=
&
dockercontainer
.
HostConfig
{
setPrivHC
:=
&
dockercontainer
.
HostConfig
{
Privileged
:
true
,
Privileged
:
true
,
}
}
unsetPrivSC
:=
&
runtimeapi
.
LinuxContainerSecurityContext
{}
unsetPrivSC
.
Privileged
=
false
unsetPrivSC
.
MaskedPaths
=
[]
string
{
"/hello/world/masked"
}
unsetPrivSC
.
ReadonlyPaths
=
[]
string
{
"/hello/world/readonly"
}
unsetPrivHC
:=
&
dockercontainer
.
HostConfig
{
Privileged
:
false
,
MaskedPaths
:
[]
string
{
"/hello/world/masked"
},
ReadonlyPaths
:
[]
string
{
"/hello/world/readonly"
},
}
setCapsHC
:=
&
dockercontainer
.
HostConfig
{
setCapsHC
:=
&
dockercontainer
.
HostConfig
{
CapAdd
:
[]
string
{
"addCapA"
,
"addCapB"
},
CapAdd
:
[]
string
{
"addCapA"
,
"addCapB"
},
CapDrop
:
[]
string
{
"dropCapA"
,
"dropCapB"
},
CapDrop
:
[]
string
{
"dropCapA"
,
"dropCapB"
},
...
@@ -149,6 +165,11 @@ func TestModifyHostConfig(t *testing.T) {
...
@@ -149,6 +165,11 @@ func TestModifyHostConfig(t *testing.T) {
expected
:
setPrivHC
,
expected
:
setPrivHC
,
},
},
{
{
name
:
"container.SecurityContext.NoPrivileges"
,
sc
:
unsetPrivSC
,
expected
:
unsetPrivHC
,
},
{
name
:
"container.SecurityContext.Capabilities"
,
name
:
"container.SecurityContext.Capabilities"
,
sc
:
&
runtimeapi
.
LinuxContainerSecurityContext
{
sc
:
&
runtimeapi
.
LinuxContainerSecurityContext
{
Capabilities
:
inputCapabilities
(),
Capabilities
:
inputCapabilities
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment