web frontend for git (tangled's grandpa)

unveil: initial commit

authored by

zak and committed by anirudh.fi 4aa8cbff d0f5d874

+36 -22
+1 -1
go.mod
··· 8 8 github.com/dustin/go-humanize v1.0.0 9 9 github.com/go-git/go-git/v5 v5.5.1 10 10 github.com/sosedoff/gitkit v0.3.0 11 + golang.org/x/sys v0.3.0 11 12 gopkg.in/yaml.v3 v3.0.0 12 13 ) 13 14 ··· 30 31 golang.org/x/crypto v0.4.0 // indirect 31 32 golang.org/x/mod v0.7.0 // indirect 32 33 golang.org/x/net v0.4.0 // indirect 33 - golang.org/x/sys v0.3.0 // indirect 34 34 golang.org/x/tools v0.4.0 // indirect 35 35 gopkg.in/warnings.v0 v0.1.2 // indirect 36 36 )
+3 -3
main.go
··· 20 20 log.Fatal(err) 21 21 } 22 22 23 - // for path := range []string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates} { 24 - // Unveil(path, "r") 25 - // } 23 + if err = UnveilPaths([]string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates}, "r"); err != nil { 24 + log.Fatal(err) 25 + } 26 26 27 27 mux := routes.Handlers(c) 28 28 addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
+14 -18
unveil.go
··· 1 1 //go:build openbsd 2 2 // +build openbsd 3 3 4 - // Doesn't do anything yet. 5 - 6 4 package main 7 - 8 - /* 9 - #include <stdlib.h> 10 - #include <unistd.h> 11 - */ 12 - import "C" 13 5 14 6 import ( 15 - "fmt" 16 - "unsafe" 7 + "golang.org/x/sys/unix" 17 8 ) 18 9 19 10 func Unveil(path string, perms string) error { 20 - cpath := C.CString(path) 21 - defer C.free(unsafe.Pointer(cpath)) 22 - cperms := C.CString(perms) 23 - defer C.free(unsafe.Pointer(cperms)) 11 + return unix.Unveil(path, perms) 12 + } 24 13 25 - rv, err := C.unveil(cpath, cperms) 26 - if rv != 0 { 27 - return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err) 14 + func UnveilBlock() error { 15 + return unix.UnveilBlock() 16 + } 17 + 18 + func UnveilPaths(paths []string, perms string) error { 19 + for _, path := range paths { 20 + err := Unveil(path, perms) 21 + if err != nil { 22 + return err 23 + } 28 24 } 29 - return nil 25 + return UnveilBlock() 30 26 }
+18
unveil_stub.go
··· 1 + //go:build !openbsd 2 + // +build !openbsd 3 + 4 + // Stub functions for GOOS that don't support unix.Unveil() 5 + 6 + package main 7 + 8 + func Unveil(path string, perms string) error { 9 + return nil 10 + } 11 + 12 + func UnveilBlock() error { 13 + return nil 14 + } 15 + 16 + func UnveilPaths(paths []string, perms string) error { 17 + return nil 18 + }