From 267d528d35ad887af48e58e65c66ec765ee2094d Mon Sep 17 00:00:00 2001 From: Alexander Justin Kerchum Date: Sun, 7 May 2023 23:11:01 +0000 Subject: [PATCH] Set default UserId and GroupId to 0:0 Update to match Dockerfile specifications when using ADD or COPY Previous functionality was to preserve the user and group from the source, which may not exist in the container. Fixes #1921 --- pkg/util/command_util.go | 2 +- pkg/util/command_util_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index 448a59236e..85b6bba1a8 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -347,7 +347,7 @@ Loop: func GetUserGroup(chownStr string, env []string) (int64, int64, error) { if chownStr == "" { - return DoNotChangeUID, DoNotChangeGID, nil + return 0, 0, nil } chown, err := ResolveEnvironmentReplacement(chownStr, env, false) diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index 3d83847711..cd00b18c40 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -561,8 +561,8 @@ func TestGetUserGroup(t *testing.T) { mockIDGetter: func(string, string, bool) (uint32, uint32, error) { return 0, 0, fmt.Errorf("should not be called") }, - expectedU: -1, - expectedG: -1, + expectedU: 0, + expectedG: 0, }, } for _, tc := range tests {