Skip to content

Commit f10780a

Browse files
committed
Do not add capabilities when privileged: false
Previously, the test-operator was spawning pods with NET_ADMIN and NET_RAW capabilities even when privileged: false. Setting these two capabilities requires elevated securitycontextconstraint. This commit addresses this issue by using extra capabilities only when privileged: true.
1 parent 362e28c commit f10780a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/util/common.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ func GetSecurityContext(
1616
RunAsUser: &runAsUser,
1717
RunAsGroup: &runAsUser,
1818
AllowPrivilegeEscalation: &falseVar,
19-
Capabilities: &corev1.Capabilities{
20-
Add: addCapabilities,
21-
},
19+
Capabilities: &corev1.Capabilities{},
2220
SeccompProfile: &corev1.SeccompProfile{
2321
Type: corev1.SeccompProfileTypeRuntimeDefault,
2422
},
@@ -28,6 +26,7 @@ func GetSecurityContext(
2826
// We need to run pods with AllowPrivilegedEscalation: true to remove
2927
// nosuid from the pod (in order to be able to run sudo)
3028
securityContext.AllowPrivilegeEscalation = &trueVar
29+
securityContext.Capabilities.Add = addCapabilities
3130
}
3231

3332
if !privileged {

0 commit comments

Comments
 (0)