Skip to content

Commit 5fcc240

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Katie Hockman <[email protected]>
1 parent 65c2069 commit 5fcc240

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/syscall/syscall_linux_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,23 @@ func TestSyscallNoError(t *testing.T) {
360360
strconv.FormatUint(uint64(-uid), 10) + " / " +
361361
strconv.FormatUint(uint64(uid), 10)
362362
if got != want {
363+
if filesystemIsNoSUID(tmpBinary) {
364+
t.Skip("skipping test when temp dir is mounted nosuid")
365+
}
363366
t.Errorf("expected %s, got %s", want, got)
364367
}
365368
}
366369

370+
// filesystemIsNoSUID reports whether the filesystem for the given
371+
// path is mounted nosuid.
372+
func filesystemIsNoSUID(path string) bool {
373+
var st syscall.Statfs_t
374+
if syscall.Statfs(path, &st) != nil {
375+
return false
376+
}
377+
return st.Flags&syscall.MS_NOSUID != 0
378+
}
379+
367380
func syscallNoError() {
368381
// Test that the return value from SYS_GETEUID32 (which cannot fail)
369382
// doesn't get treated as an error (see https://golang.org/issue/22924)

0 commit comments

Comments
 (0)