Skip to content

api.go doesn't respect nsswitch.conf #1715

@eliasp

Description

@eliasp

Due to the implementation of api.go which reads only /etc/group, it is impossible to rely on other auth mechanisms (e.g. LDAP, NIS).

groups, err := ioutil.ReadFile("/etc/group")
if err != nil {
        return err
}
re := regexp.MustCompile("(^|\n)docker:.*?:([0-9]+)")
if gidMatch := re.FindStringSubmatch(string(groups)); gidMatch != nil {
        gid, err := strconv.Atoi(gidMatch[2])
        if err != nil {
                return err
        }
        utils.Debugf("docker group found. gid: %d", gid)
        if err := os.Chown(addr, 0, gid); err != nil {
                return err
        }
}

Instead, the getgrnam syscall should be used to determine, whether a docker group exists or not.

The implemenation of lookup_unix.go in the user Go package might serve as inspiration on how to do this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions