diff --git a/main.go b/main.go index 7891647..f3a91c6 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,9 @@ import ( "path/filepath" "time" + "github.com/qbit/gavin/pu" "golang.org/x/crypto/bcrypt" "golang.org/x/net/webdav" - "golang.org/x/sys/unix" ) var ( @@ -39,10 +39,10 @@ func init() { flag.StringVar(&staticDir, "static", dir, "Directory to serve static resources from.") flag.Parse() - unix.Unveil(staticDir, "r") - unix.Unveil(passPath, "r") - unix.Unveil(davDir, "rwc") - err = unix.UnveilBlock() + pu.U(staticDir, "r") + pu.U(passPath, "r") + pu.U(davDir, "rwc") + err = pu.UBlock() if err != nil { log.Fatal(err) } diff --git a/pu/pu.go b/pu/pu.go new file mode 100644 index 0000000..c5b008f --- /dev/null +++ b/pu/pu.go @@ -0,0 +1,13 @@ +// +build !openbsd + +package pu + +import "fmt" + +func U(path string, perms string) { + fmt.Printf("WARNING: no unveil (%s, %s)\n", path, perms) +} + +func UBlock() error { + return nil +} diff --git a/pu/pu_openbsd.go b/pu/pu_openbsd.go new file mode 100644 index 0000000..4b18e2d --- /dev/null +++ b/pu/pu_openbsd.go @@ -0,0 +1,15 @@ +// +build openbsd + +package pu + +import ( + "golang.org/x/sys/unix" +) + +func U(path string, perms string) { + unix.Unveil(path, perms) +} + +func UBlock() error { + return unix.UnveilBlock() +}