Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Build the tree for Windows and name the platform seams

215f8aebc38e69e621eb6f739e0cfea2ba07fd9a · Keenan Nemetz · 2d ago · parent 416739b1

Build the tree for Windows and name the platform seams

`go build` for windows/amd64 failed on five unix syscall uses, and the tree had
nowhere to say what a platform can and cannot do. Each unix-only site now lives
in a `_unix.go` file with a Windows counterpart: disk capacity through
GetDiskFreeSpaceEx, allocated bytes through GetCompressedFileSize, hard-link
identity through GetFileInformationByHandle, the runner's cache lock through
LockFileEx, a liveness probe through OpenProcess, and a command's process group
through a helper that has no group to signal yet.

Two sites cannot be ported without weakening them, so they refuse rather than
pretend. File modes are a unix control and Windows needs ACLs instead, so
`internal/secure` will not create or accept a secret there, and `internal/audit`
will not verify a log it cannot check. The front door says the same about exec,
which Windows does not have: sshd gets an explanation instead of a process that
returns EWINDOWS.

A CI step cross-compiles windows/amd64 and vets it, and `go vet` is what
type-checks the test files that `go build` skips, so a unix-only call fails a
push instead of a port nobody can start.

Part of 01M8S9B86B36PE0MY8MMCRCMYA.

internal/secure/secure.go +2−17

@@ -48,15 +48,7 @@ func HardenDir(path string) (bool, error) {
48 48 if !st.IsDir() {
49 49 return false, fmt.Errorf("%s is not a directory", path)
50 50 }
51 mode := st.Mode().Perm()
52 if mode&0o007 == 0 {
53 return false, nil
54 }
55 want := mode &^ 0o007
56 if err := os.Chmod(path, want); err != nil {
57 return false, fmt.Errorf("%s is %04o and cannot be tightened to %04o: %w", path, mode, want, err)
58 }
59 return true, nil
51 return tightenDir(path, st.Mode().Perm())
60 52 }
61 53
62 54 // HardenFile forces an existing secret file to FileMode and reports whether it
@@ -69,14 +61,7 @@ func HardenFile(path string) (bool, error) {
69 61 if st.IsDir() {
70 62 return false, fmt.Errorf("%s is a directory, expected a file", path)
71 63 }
72 if st.Mode().Perm() == FileMode {
73 return false, nil
74 }
75 had := st.Mode().Perm()
76 if err := os.Chmod(path, FileMode); err != nil {
77 return false, fmt.Errorf("%s is %04o and cannot be tightened to %04o: %w", path, had, FileMode, err)
78 }
79 return true, nil
64 return tightenFile(path, st.Mode().Perm())
80 65 }
81 66
82 67 // HardenFileIfExists is HardenFile for a file that may not exist yet.