You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libct: do not parse passwd and group on every run/exec
OCI runtime spec states [1] that the UID, primary GID, and additional
GIDs are all specified as numbers, and also adds that symbolic names
resolution "are left to upper levels to derive". Meaning, runc should
not care about user and group names.
Yet, runc tries to be clever than that, always parsing container's
/etc/passwd and /etc/group. It results in a few things:
1. If UID (or GID) specified can't be found inside container's /etc/passwd
(or /etc/group), runc (run or exec) errors out.
2. Any additional GIDs specified in container's /etc/group are
automatically prepended to the list for setgroups(2). Meaning, a user
can either specify additional GIDs in OCI runtime spec, or
container's /etc/group entry for a given user.
Looks like (1) is questionable (on a normal Linux system, I can run
programs under any UID (GID), not limited to those listed in /etc/passwd
(/etc/group), and (2) is just an extra mechanism of specifying
additional GIDs.
Let's remove those, hopefully increasing runc performance as well as OCI
spec conformance. With that, also remove most of libcontainer/user
parsers.
The only remaining need to parse /etc/passwd is to set HOME environment
variable for a specified UID, in case it is not. For that, we can use
standard os/user package, which has both libc-based and own ("pure Go")
/etc/passwd parsers.
PS Note that the structures being changed (initConfig and Process) are
never saved to disk as JSON by runc, so there is no compatibility issue
for runc users. This is a breaking change in libcontainer, but we never
promised that libcontainer API will be stable.
[1] https://github.com/opencontainers/runtime-spec/blob/v1.0.2/config.md#posix-platform-user
Signed-off-by: Kir Kolyshkin <[email protected]>
0 commit comments