Skip to content

Commit

Permalink
Avoid returning the UID when resolving the GIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
gadiego92 committed Aug 19, 2023
1 parent 328c4d9 commit 7b86181
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/util/command_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,29 @@ func getUIDAndGID(userStr string, groupStr string, fallbackToUID bool) (uint32,
return 0, 0, err
}

gid, err := getGIDFromName(groupStr, fallbackToUID)
if groupStr == "" {
if user.Gid != "" {
gid32, err := getGID(user.Gid, fallbackToUID)

if err != nil {
if errors.Is(err, fallbackToUIDError) {
return uid32, uid32, nil
}
return 0, 0, err
}

return uid32, gid32, nil
}
}

gid32, err := getGIDFromName(groupStr, fallbackToUID)
if err != nil {
if errors.Is(err, fallbackToUIDError) {
return uid32, uid32, nil
}
return 0, 0, err
}
return uid32, gid, nil
return uid32, gid32, nil
}

// getGID tries to parse the gid or falls back to getGroupFromName if it's not an id
Expand Down

0 comments on commit 7b86181

Please sign in to comment.