From 5b69c4b693126f5fe62608eb96083dad7c6da8fd Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Thu, 21 Nov 2019 20:34:39 -0700 Subject: [PATCH] Make unveil bits OpenBSD specific --- main.go | 10 +++++----- pu/pu.go | 13 +++++++++++++ pu/pu_openbsd.go | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 pu/pu.go create mode 100644 pu/pu_openbsd.go 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() +}