fix(tlscert): make O_NOFOLLOW Windows-safe (unbreak cross-compile) - #56
Merged
Conversation
internal/tlscert opened key.pem with syscall.O_NOFOLLOW, which is not defined on Windows, so the cross-compiled Windows release binary failed to build. Move the flag behind a platform constant (syscall.O_NOFOLLOW on Unix, 0 on Windows); the symlink-redirect protection is unchanged on Unix.
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #54 (
--make-certs) openedkey.pemwithsyscall.O_NOFOLLOWto defeat a symlink-redirect attack. That constant is not defined on Windows, sointernal/tlscertno longer cross-compiles forGOOS=windows— the next release's Windows binary would fail to build. CI only builds Linux, so it slipped through.Fix: move the flag behind a platform constant —
syscall.O_NOFOLLOWon Unix,0(no-op) on Windows. The Unix symlink-redirect protection (and its pentest) is unchanged.Verified
go build ./...now succeeds for linux, windows/amd64 and darwin/arm64.Type of change
Checklist
go test -short ./...andgo vet ./...passgofmtgate is cleanCHANGELOG.mdentryNotes for reviewers
No behaviour change on Unix. Two tiny build-tagged files (
nofollow_unix.go/nofollow_windows.go) define theoNoFollowconstant.