Skip to content

Commit 6431577

Browse files
KerchumA222johnstcn
authored andcommitted
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 GoogleContainerTools#1921
1 parent dd2a42a commit 6431577

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/util/command_util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Loop:
354354

355355
func GetUserGroup(chownStr string, env []string) (int64, int64, error) {
356356
if chownStr == "" {
357-
return DoNotChangeUID, DoNotChangeGID, nil
357+
return 0, 0, nil
358358
}
359359

360360
chown, err := ResolveEnvironmentReplacement(chownStr, env, false)

pkg/util/command_util_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ func TestGetUserGroup(t *testing.T) {
567567
mockIDGetter: func(string, string) (uint32, uint32, error) {
568568
return 0, 0, fmt.Errorf("should not be called")
569569
},
570-
expectedU: -1,
571-
expectedG: -1,
570+
expectedU: 0,
571+
expectedG: 0,
572572
},
573573
}
574574
for _, tc := range tests {

0 commit comments

Comments
 (0)