26 lines
955 B
Go
26 lines
955 B
Go
//go:build !windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
// openNoFollow centralizes the O_NOFOLLOW flag used by every safeOpen*/
|
|
// safeWrite* containment open in main.go (see opennofollow.go /
|
|
// opennofollow_windows.go). The windows stub is a build-tag typo away from
|
|
// winning on a unix build, which would silently turn the flag into 0 and make
|
|
// every open follow a planted symlink's final component again - this pins the
|
|
// unix contract. (The windows side cannot be pinned here: the constant is 0
|
|
// there by design, and the windows compile itself is verified by
|
|
// GOOS=windows go build.)
|
|
func TestOpenNoFollowIsRealOnUnixBuilds(t *testing.T) {
|
|
if openNoFollow != syscall.O_NOFOLLOW {
|
|
t.Fatalf("openNoFollow = %d, want syscall.O_NOFOLLOW (%d) on this platform", openNoFollow, syscall.O_NOFOLLOW)
|
|
}
|
|
if openNoFollow == 0 {
|
|
t.Fatal("openNoFollow is 0: the windows stub leaked into a build where syscall defines O_NOFOLLOW")
|
|
}
|
|
}
|