Skip to content

starting container process caused: setup user: unable to find <user>: bufio.Scanner: token too long: unknown. #3036

@erict-square

Description

@erict-square

Problem

I'm running into the following problem when I run docker run --network=host --hostname=<hostname> --user <user> -v /etc/group:/etc/group:ro <image>.

docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: setup user: unable to find groups for spec <user>: bufio.Scanner: token too long: unknown.

My current finding shows me that this error is only thrown if a line in /etc/group exceeds 65536 characters.

Diagnosis

I'm not familiar with runc code or golang, but i tried my best to find what's going on. I was able to find where this error message is thrown unable to find groups for spec in

return nil, fmt.Errorf("unable to find groups for spec %v: %v", matchedUserName, err)

And from there, I find that the error likely came from running ParseGroupFilter function in

groups, err := ParseGroupFilter(group, func(g Group) bool {

Reading ParseGroupFilter function,

func ParseGroupFilter(r io.Reader, filter func(Group) bool) ([]Group, error) {
if r == nil {
return nil, fmt.Errorf("nil source for group-formatted data")
}
var (
s = bufio.NewScanner(r)
out = []Group{}
)
for s.Scan() {
text := s.Text()
if text == "" {
continue
}
// see: man 5 group
// group_name:password:GID:user_list
// Name:Pass:Gid:List
// root:x:0:root
// adm:x:4:root,adm,daemon
p := Group{}
parseLine(text, &p.Name, &p.Pass, &p.Gid, &p.List)
if filter == nil || filter(p) {
out = append(out, p)
}
}
if err := s.Err(); err != nil {
return nil, err
}
return out, nil
}
, I suspect that we're hitting a token limit in bufio.NewScanner (which happens to be 65536 according to https://golang.org/pkg/bufio/#pkg-constants). This is likely given that another project sirupsen/logrus#564 has hit a similar issue as well.

1.0 backport: #3079

Metadata

Metadata

Assignees

No one assigned

    Labels

    backport/1.0-doneA PR in main branch which has been backported to release-1.0kind/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions