Skip to content

RFC: remove user/group name support from libcontainer #3998

@kolyshkin

Description

@kolyshkin

Description

There is a way to specify user, group, and additional groups in the OCI spec here. It is very clear from the spec that all the fields are numeric UIDs and GIDs.

Yet,

  1. In libcontainer these fields are strings:

    // User will set the uid and gid of the executing process running inside the container
    // local to the container's user and group configuration.
    User string
    // AdditionalGroups specifies the gids that should be added to supplementary groups
    // in addition to those that the user belongs to.
    AdditionalGroups []string

  2. So, runc converts from numeric UID and GID to a string (like "$UID:$GID"):

runc/utils_linux.go

Lines 51 to 52 in b322e31

// TODO: fix libcontainer's API to better support uid/gid in a typesafe way.
User: fmt.Sprintf("%d:%d", p.User.UID, p.User.GID),

and does the same for additional GIDs:

runc/utils_linux.go

Lines 72 to 74 in b322e31

for _, gid := range p.User.AdditionalGids {
lp.AdditionalGroups = append(lp.AdditionalGroups, strconv.FormatUint(uint64(gid), 10))
}

  1. libcontainer parses the whole nine yards of /etc/passwd and /etc/group to find out the numeric UID and GID back from the User string, and does the same for every additional GID.

I imagine that makes every runc run and runc exec slower than it could be, and is totally unnecessary.

I propose to remove this functionality of resolving user/group names from libcontainer, and only read /etc/passwd in case $HOME is not set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions