aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_linux_test.go
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2022-07-14 19:40:23 -0700
committerGopher Robot <gobot@golang.org>2022-09-03 18:21:45 +0000
commita0f05823e4953d137310de164b2544e41dd767d2 (patch)
treea2878759c4138736e90f7f649183bb53143db966 /src/syscall/exec_linux_test.go
parent32964f9dce9615f7c1072e5ead9e11e6db5d2237 (diff)
downloadgo-a0f05823e4953d137310de164b2544e41dd767d2.tar.xz
syscall: fix skipping some tests on Linux
The kernel knob /proc/sys/kernel/unprivileged_userns_clone is only available in Debian (and Ubuntu) kernels, so if the tests are run on e.g. Fedora, skipUnprivilegedUserClone() skips a lot of tests. Modify it to treat ENOENT as "it should work". Change-Id: I959201ede139ede989cc8ab646c9bf51e0539ada Reviewed-on: https://go-review.googlesource.com/c/go/+/417694 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/syscall/exec_linux_test.go')
-rw-r--r--src/syscall/exec_linux_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go
index 0ec9c4db0f..8a9258d116 100644
--- a/src/syscall/exec_linux_test.go
+++ b/src/syscall/exec_linux_test.go
@@ -65,6 +65,10 @@ func skipUnprivilegedUserClone(t *testing.T) {
// Skip the test if the sysctl that prevents unprivileged user
// from creating user namespaces is enabled.
data, errRead := os.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
+ if os.IsNotExist(errRead) {
+ // This file is only available in some Debian/Ubuntu kernels.
+ return
+ }
if errRead != nil || len(data) < 1 || data[0] == '0' {
t.Skip("kernel prohibits user namespace in unprivileged process")
}