diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2019-02-15 18:55:45 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-02-15 19:24:37 +0000 |
| commit | 5fcc24074f8e48cd8404bd250c2c268aca2bc3d2 (patch) | |
| tree | 1c50805bcc8792055d091fb0980f74e9193a7d47 /src | |
| parent | 65c2069a9f30cb6fa2c512d17dc0ad654d621da9 (diff) | |
| download | go-5fcc24074f8e48cd8404bd250c2c268aca2bc3d2.tar.xz | |
syscall: skip TestSyscallNoError when temp dir is mounted nosuid
Fixes #30258
Change-Id: I73b63eb9d3aca00f562fdc3af010e96269bb6b9c
Reviewed-on: https://go-review.googlesource.com/c/162891
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/syscall/syscall_linux_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/syscall/syscall_linux_test.go b/src/syscall/syscall_linux_test.go index 293549a841..8a578639bd 100644 --- a/src/syscall/syscall_linux_test.go +++ b/src/syscall/syscall_linux_test.go @@ -360,10 +360,23 @@ func TestSyscallNoError(t *testing.T) { strconv.FormatUint(uint64(-uid), 10) + " / " + strconv.FormatUint(uint64(uid), 10) if got != want { + if filesystemIsNoSUID(tmpBinary) { + t.Skip("skipping test when temp dir is mounted nosuid") + } t.Errorf("expected %s, got %s", want, got) } } +// filesystemIsNoSUID reports whether the filesystem for the given +// path is mounted nosuid. +func filesystemIsNoSUID(path string) bool { + var st syscall.Statfs_t + if syscall.Statfs(path, &st) != nil { + return false + } + return st.Flags&syscall.MS_NOSUID != 0 +} + func syscallNoError() { // Test that the return value from SYS_GETEUID32 (which cannot fail) // doesn't get treated as an error (see https://golang.org/issue/22924) |
