Fix init layer chown of existing dir ownership
This solves a bug where /etc may have pre-existing permissions from build time, but init layer setup (reworked for user namespaces) was assuming root ownership. Adds a test as well to catch this situation in the future. Minor fix to wrong ordering of chown/close on files created during the same initlayer setup. Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp) Upstream-commit: 23b771782ab7236ce5024ac5773a6ded9a2af753 Component: engine
This commit is contained in:
@@ -3762,6 +3762,29 @@ func (s *DockerSuite) TestRunInvalidReference(c *check.C) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test fix for issue #17854
|
||||
func (s *DockerSuite) TestRunInitLayerPathOwnership(c *check.C) {
|
||||
// Not applicable on Windows as it does not support Linux uid/gid ownership
|
||||
testRequires(c, DaemonIsLinux)
|
||||
name := "testetcfileownership"
|
||||
_, err := buildImage(name,
|
||||
`FROM busybox
|
||||
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
||||
RUN echo 'dockerio:x:1001:' >> /etc/group
|
||||
RUN chown dockerio:dockerio /etc`,
|
||||
true)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
// Test that dockerio ownership of /etc is retained at runtime
|
||||
out, _ := dockerCmd(c, "run", "--rm", name, "stat", "-c", "%U:%G", "/etc")
|
||||
out = strings.TrimSpace(out)
|
||||
if out != "dockerio:dockerio" {
|
||||
c.Fatalf("Wrong /etc ownership: expected dockerio:dockerio, got %q", out)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWithOomScoreAdj(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user