Make unveil bits OpenBSD specific

This commit is contained in:
Aaron Bieber 2019-11-21 20:34:39 -07:00
parent 819278a3ca
commit 5b69c4b693
Signed by: qbit
GPG Key ID: 279160AB1BE1236B
3 changed files with 33 additions and 5 deletions

10
main.go
View File

@ -11,9 +11,9 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"github.com/qbit/gavin/pu"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"golang.org/x/net/webdav" "golang.org/x/net/webdav"
"golang.org/x/sys/unix"
) )
var ( var (
@ -39,10 +39,10 @@ func init() {
flag.StringVar(&staticDir, "static", dir, "Directory to serve static resources from.") flag.StringVar(&staticDir, "static", dir, "Directory to serve static resources from.")
flag.Parse() flag.Parse()
unix.Unveil(staticDir, "r") pu.U(staticDir, "r")
unix.Unveil(passPath, "r") pu.U(passPath, "r")
unix.Unveil(davDir, "rwc") pu.U(davDir, "rwc")
err = unix.UnveilBlock() err = pu.UBlock()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

13
pu/pu.go Normal file
View File

@ -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
}

15
pu/pu_openbsd.go Normal file
View File

@ -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()
}