From 331e542c09c7de13d9a4f1202347fa9e6ccae286 Mon Sep 17 00:00:00 2001 From: zhangzhenhao Date: Thu, 24 Aug 2017 23:29:45 +0800 Subject: [PATCH] add the user id support of runAsUser Signed-off-by: zhangzhenhao --- hack/test-cri.sh | 2 +- pkg/server/container_create.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hack/test-cri.sh b/hack/test-cri.sh index 4925481dd..c03184b32 100755 --- a/hack/test-cri.sh +++ b/hack/test-cri.sh @@ -21,7 +21,7 @@ source $(dirname "${BASH_SOURCE[0]}")/test-utils.sh # FOCUS focuses the test to run. FOCUS=${FOCUS:-} # SKIP skips the test to skip. -SKIP=${SKIP:-"RunAsUser"} +SKIP=${SKIP:-"RunAsUserName"} REPORT_DIR=${REPORT_DIR:-"/tmp/test-cri"} if [[ -z "${GOPATH}" ]]; then diff --git a/pkg/server/container_create.go b/pkg/server/container_create.go index 767a794c3..0a99ebd15 100644 --- a/pkg/server/container_create.go +++ b/pkg/server/container_create.go @@ -261,7 +261,11 @@ func (c *criContainerdService) generateContainerSpec(id string, sandboxPid uint3 // Set namespaces, share namespace with sandbox container. setOCINamespaces(&g, securityContext.GetNamespaceOptions(), sandboxPid) - // TODO(random-liu): [P1] Set user/username. + // TODO(random-liu): [P1] Set username. + runAsUser := securityContext.GetRunAsUser() + if runAsUser != nil { + g.SetProcessUID(uint32(runAsUser.GetValue())) + } supplementalGroups := securityContext.GetSupplementalGroups() for _, group := range supplementalGroups {