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>
Upstream-commit: 6cbff9505c992bd1e61ea7943737dac04ba665ea
Component: engine
This commit is contained in:
Kenfe-Mickael Laventure
2016-03-09 12:42:59 -08:00
parent 03dcde6cf7
commit f3e1cfee9f
2 changed files with 13 additions and 2 deletions
@@ -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)
@@ -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 {