10BC0 Use idtools.LookupGroup instead of parsing /etc/group file for docker… · moby/moby@a2e3846 · GitHub
[go: up one dir, main page]

Skip to content

Commit a2e3846

Browse files
committed
Use idtools.LookupGroup instead of parsing /etc/group file for docker.sock ownership
Signed-off-by: James Watkins-Harvey <jwatkins@progi-media.com>
1 parent 46652b0 commit a2e3846

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

daemon/listeners/group_unix.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,15 @@ import (
66
"fmt"
77
"strconv"
88

9-
"github.com/opencontainers/runc/libcontainer/user"
10-
"github.com/pkg/errors"
9+
"github.com/docker/docker/pkg/idtools"
1110
)
1211

1312
const defaultSocketGroup = "docker"
1413

1514
func lookupGID(name string) (int, error) {
16-
groupFile, err := user.GetGroupPath()
17-
if err != nil {
18-
return -1, errors.Wrap(err, "error looking up groups")
19-
}
20-
groups, err := user.ParseGroupFileFilter(groupFile, func(g user.Group) bool {
21-
return g.Name == name || strconv.Itoa(g.Gid) == name
22-
})
23-
if err != nil {
24-
return -1, errors.Wrapf(err, "error parsing groups for %s", name)
25-
}
26-
if len(groups) > 0 {
27-
return groups[0].Gid, nil
15+
group, err := idtools.LookupGroup(name)
16+
if err == nil {
17+
return group.Gid, nil
2818
}
2919
gid, err := strconv.Atoi(name)
3020
if err == nil {

0 commit comments

Comments
 (0)
0