Description
LookupGroupsWith in src/user/user.go (lines 49-63) splits the --groups value on commas without filtering out empty entries:
func LookupGroupsWith(groupPath, groupList string) ([]int, error) {
var gids []int
for _, grp := range strings.Split(groupList, ",") {
if g, err := strconv.Atoi(grp); err == nil {
gids = append(gids, g)
} else {
g, err := findGIDByNameWith(groupPath, grp)
if err != nil {
return nil, fmt.Errorf("group %q not found", grp)
}
gids = append(gids, g)
}
}
return gids, nil
}
If the list has a trailing (or leading, or doubled) comma, e.g. --groups=1000,, strings.Split produces ["1000", ""]. The empty string is then looked up as a group name and fails, producing the misleading error group "" not found instead of a message that points at the actual problem (an empty/malformed entry in the list).
Steps to reproduce
./warproot --userspec=1000 --groups=1000, /path/to/root
Expected behavior
Either skip empty entries produced by splitting, or return a clear error such as invalid --groups value: empty group name in list %q, so the user understands the list itself is malformed rather than thinking a group literally named "" doesn't exist.
Description
LookupGroupsWithinsrc/user/user.go(lines 49-63) splits the--groupsvalue on commas without filtering out empty entries:If the list has a trailing (or leading, or doubled) comma, e.g.
--groups=1000,,strings.Splitproduces["1000", ""]. The empty string is then looked up as a group name and fails, producing the misleading errorgroup "" not foundinstead of a message that points at the actual problem (an empty/malformed entry in the list).Steps to reproduce
Expected behavior
Either skip empty entries produced by splitting, or return a clear error such as
invalid --groups value: empty group name in list %q, so the user understands the list itself is malformed rather than thinking a group literally named""doesn't exist.