Skip to content

Commit 228bc1c

Browse files
committed
Grant access to privileged SCC to system:admin user and members of system:masters group.
This change improves UX and allows to a member of the sudoer group to, for example, create a privileged pod using impersonation: $ oc create -f privileged.pod --as system:admin
1 parent 0c1e0ce commit 228bc1c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pkg/cmd/server/bootstrappolicy/securitycontextconstraints.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,15 @@ func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string
285285
// GetBoostrapSCCAccess provides the default set of access that should be passed to GetBootstrapSecurityContextConstraints.
286286
func GetBoostrapSCCAccess(infraNamespace string) (map[string][]string, map[string][]string) {
287287
groups := map[string][]string{
288-
SecurityContextConstraintPrivileged: {ClusterAdminGroup, NodesGroup},
288+
SecurityContextConstraintPrivileged: {ClusterAdminGroup, NodesGroup, MastersGroup},
289289
SecurityContextConstraintsAnyUID: {ClusterAdminGroup},
290290
SecurityContextConstraintRestricted: {AuthenticatedGroup},
291291
}
292292

293293
buildControllerUsername := serviceaccount.MakeUsername(infraNamespace, InfraBuildControllerServiceAccountName)
294294
pvRecyclerControllerUsername := serviceaccount.MakeUsername(infraNamespace, InfraPersistentVolumeRecyclerControllerServiceAccountName)
295295
users := map[string][]string{
296-
SecurityContextConstraintPrivileged: {buildControllerUsername},
296+
SecurityContextConstraintPrivileged: {SystemAdminUsername, buildControllerUsername},
297297
SecurityContextConstraintHostMountAndAnyUID: {pvRecyclerControllerUsername},
298298
}
299299
return groups, users

pkg/cmd/server/bootstrappolicy/securitycontextconstraints_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ func TestBootstrappedConstraintsWithAddedUser(t *testing.T) {
7575

7676
func getExpectedAccess() (map[string][]string, map[string][]string) {
7777
groups := map[string][]string{
78-
SecurityContextConstraintPrivileged: {ClusterAdminGroup, NodesGroup},
78+
SecurityContextConstraintPrivileged: {ClusterAdminGroup, NodesGroup, MastersGroup},
7979
SecurityContextConstraintsAnyUID: {ClusterAdminGroup},
8080
SecurityContextConstraintRestricted: {AuthenticatedGroup},
8181
}
8282

8383
buildControllerUsername := serviceaccount.MakeUsername(DefaultOpenShiftInfraNamespace, InfraBuildControllerServiceAccountName)
8484
pvRecyclerControllerUsername := serviceaccount.MakeUsername(DefaultOpenShiftInfraNamespace, InfraPersistentVolumeRecyclerControllerServiceAccountName)
8585
users := map[string][]string{
86-
SecurityContextConstraintPrivileged: {buildControllerUsername},
86+
SecurityContextConstraintPrivileged: {SystemAdminUsername, buildControllerUsername},
8787
SecurityContextConstraintHostMountAndAnyUID: {pvRecyclerControllerUsername},
8888
}
8989
return groups, users

test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ items:
3939
- users
4040
verbs:
4141
- impersonate
42+
- apiGroups:
43+
- ""
44+
- user.openshift.io
45+
resourceNames:
46+
- system:masters
47+
resources:
48+
- groups
49+
- systemgroups
50+
verbs:
51+
- impersonate
4252
- apiVersion: rbac.authorization.k8s.io/v1beta1
4353
kind: ClusterRole
4454
metadata:

0 commit comments

Comments
 (0)