Commit 5fcc2407 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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: default avatarKatie Hockman <katie@golang.org>
parent 65c2069a
...@@ -360,10 +360,23 @@ func TestSyscallNoError(t *testing.T) { ...@@ -360,10 +360,23 @@ func TestSyscallNoError(t *testing.T) {
strconv.FormatUint(uint64(-uid), 10) + " / " + strconv.FormatUint(uint64(-uid), 10) + " / " +
strconv.FormatUint(uint64(uid), 10) strconv.FormatUint(uint64(uid), 10)
if got != want { if got != want {
if filesystemIsNoSUID(tmpBinary) {
t.Skip("skipping test when temp dir is mounted nosuid")
}
t.Errorf("expected %s, got %s", want, got) 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() { func syscallNoError() {
// Test that the return value from SYS_GETEUID32 (which cannot fail) // Test that the return value from SYS_GETEUID32 (which cannot fail)
// doesn't get treated as an error (see https://golang.org/issue/22924) // doesn't get treated as an error (see https://golang.org/issue/22924)
......
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