]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: fix skip condition in skipUnprivilegedUserClone
authorMeng Zhuo <mengzhuo1203@gmail.com>
Thu, 6 Jun 2019 11:17:01 +0000 (19:17 +0800)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 6 Jun 2019 11:40:17 +0000 (11:40 +0000)
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: Tobias Klauser <tobias.klauser@gmail.com>
src/syscall/exec_linux_test.go

index 8759775fccd9c841d163c48153b24586606ed73a..cc2140f811202964f14d0f5298714eb37c01714a 100644 (file)
@@ -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")
        }
 }