Commit 5ec14065 authored by Meng Zhuo's avatar Meng Zhuo Committed by Tobias Klauser

syscall: fix skip condition in skipUnprivilegedUserClone

This is a follow up CL of CL 180877:
It will skip test create user namespaces under 3 conditions:

1. sysctl file is missing
2. file reads nothing
3. user don't have permission to create namespaces

Change-Id: I25f00a6b67213bf98d654972388637789978e1fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/180937
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
parent 037ac2bd
......@@ -46,7 +46,7 @@ func skipUnprivilegedUserClone(t *testing.T) {
// Skip the test if the sysctl that prevents unprivileged user
// from creating user namespaces is enabled.
data, errRead := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
if errRead != nil || len(data) < 1 && data[0] == '0' {
if errRead != nil || len(data) < 1 || data[0] == '0' {
t.Skip("kernel prohibits user namespace in unprivileged process")
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment