Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 3f7bf34

Browse files
cypharthaJeztah
authored andcommitted
oci: correctly use user.GetExecUser interface
A nil interface in Go is not the same as a nil pointer that satisfies the interface. libcontainer/user has special handling for missing /etc/{passwd,group} files but this is all based on nil interface checks, which were broken by Docker's usage of the API. When combined with some recent changes in runc that made read errors actually be returned to the caller, this results in spurrious -EINVAL errors when we should detect the situation as "there is no passwd file". Signed-off-by: Aleksa Sarai <asarai@suse.de> (cherry picked from commit 3108ae62269aff1ee7ff20a7ff0b4d67cb44fcce) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 83baeafc3c4eaedc41efb47061eb530651d8ce04 Component: engine
1 parent 1d7d9d0 commit 3f7bf34

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

components/engine/daemon/oci_linux.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ func readUserFile(c *container.Container, p string) (io.ReadCloser, error) {
157157
if err != nil {
158158
return nil, err
159159
}
160-
return os.Open(fp)
160+
fh, err := os.Open(fp)
161+
if err != nil {
162+
// This is needed because a nil *os.File is different to a nil
163+
// io.ReadCloser and this causes GetExecUser to not detect that the
164+
// container file is missing.
165+
return nil, err
166+
}
167+
return fh, nil
161168
}
162169

163170
func getUser(c *container.Container, username string) (uint32, uint32, []uint32, error) {

0 commit comments

Comments
 (0)