Skip to content

Commit

Permalink
Set default UserId and GroupId to 0:0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KerchumA222 authored and johnstcn committed May 15, 2024
1 parent dd2a42a commit 6431577
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/util/command_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/command_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ func TestGetUserGroup(t *testing.T) {
mockIDGetter: func(string, string) (uint32, uint32, error) {
return 0, 0, fmt.Errorf("should not be called")
},
expectedU: -1,
expectedG: -1,
expectedU: 0,
expectedG: 0,
},
}
for _, tc := range tests {
Expand Down

0 comments on commit 6431577

Please sign in to comment.