Bläddra i källkod

Merge pull request #36808 from justincormack/sys-rw-priv-always

Always make sysfs read-write with privileged
Akihiro Suda 7 år sedan
förälder
incheckning
fb08a5c6c3
2 ändrade filer med 5 tillägg och 7 borttagningar
  1. 4 6
      daemon/oci_linux.go
  2. 1 1
      integration-cli/docker_cli_run_test.go

+ 4 - 6
daemon/oci_linux.go

@@ -685,12 +685,10 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c
 	}
 	}
 
 
 	if c.HostConfig.Privileged {
 	if c.HostConfig.Privileged {
-		if !s.Root.Readonly {
-			// clear readonly for /sys
-			for i := range s.Mounts {
-				if s.Mounts[i].Destination == "/sys" {
-					clearReadOnly(&s.Mounts[i])
-				}
+		// clear readonly for /sys
+		for i := range s.Mounts {
+			if s.Mounts[i].Destination == "/sys" {
+				clearReadOnly(&s.Mounts[i])
 			}
 			}
 		}
 		}
 		s.Linux.ReadonlyPaths = nil
 		s.Linux.ReadonlyPaths = nil

+ 1 - 1
integration-cli/docker_cli_run_test.go

@@ -2688,7 +2688,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
 	if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
 	if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
 		testPriv = false
 		testPriv = false
 	}
 	}
-	testReadOnlyFile(c, testPriv, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel")
+	testReadOnlyFile(c, testPriv, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname")
 }
 }
 
 
 func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
 func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {