Skip to content

Commit 6cbff95

Browse files
committed
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>
1 parent f97ab35 commit 6cbff95

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

integration-cli/docker_cli_userns_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
// 1. validate uid/gid maps are set properly
2121
// 2. verify that files created are owned by remapped root
2222
func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
23-
testRequires(c, DaemonIsLinux, SameHostDaemon)
23+
testRequires(c, DaemonIsLinux, SameHostDaemon, UserNamespaceInKernel)
2424

2525
c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), checker.IsNil)
2626

integration-cli/requirements.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,20 @@ var (
149149
*/
150150
return false
151151
}
152+
153+
// We need extra check on redhat based distributions
154+
if f, err := os.Open("/sys/module/user_namespace/parameters/enable"); err == nil {
155+
b := make([]byte, 1)
156+
_, _ = f.Read(b)
157+
if string(b) == "N" {
158+
return false
159+
}
160+
return true
161+
}
162+
152163
return true
153164
},
154-
"Kernel must have user namespaces configured.",
165+
"Kernel must have user namespaces configured and enabled.",
155166
}
156167
NotUserNamespace = testRequirement{
157168
func() bool {

0 commit comments

Comments
 (0)