浏览代码

Update UserNamespaceInKernel test requirement to handle redhat

On redhat based distribution, checking that USER_NS is compiled in the
kernel is not sufficient, we also have to check that the feature as
been enabled.

With this commit, it is now done by checking the content of
`/sys/module/user_namespace/parameters/enable`.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Kenfe-Mickael Laventure 9 年之前
父节点
当前提交
6cbff9505c
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 1 1
      integration-cli/docker_cli_userns_test.go
  2. 12 1
      integration-cli/requirements.go

+ 1 - 1
integration-cli/docker_cli_userns_test.go

@@ -20,7 +20,7 @@ import (
 // 1. validate uid/gid maps are set properly
 // 2. verify that files created are owned by remapped root
 func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
-	testRequires(c, DaemonIsLinux, SameHostDaemon)
+	testRequires(c, DaemonIsLinux, SameHostDaemon, UserNamespaceInKernel)
 
 	c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), checker.IsNil)
 

+ 12 - 1
integration-cli/requirements.go

@@ -149,9 +149,20 @@ var (
 				 */
 				return false
 			}
+
+			// We need extra check on redhat based distributions
+			if f, err := os.Open("/sys/module/user_namespace/parameters/enable"); err == nil {
+				b := make([]byte, 1)
+				_, _ = f.Read(b)
+				if string(b) == "N" {
+					return false
+				}
+				return true
+			}
+
 			return true
 		},
-		"Kernel must have user namespaces configured.",
+		"Kernel must have user namespaces configured and enabled.",
 	}
 	NotUserNamespace = testRequirement{
 		func() bool {