Make unveil bits OpenBSD specific
This commit is contained in:
parent
819278a3ca
commit
5b69c4b693
10
main.go
10
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)
|
||||
}
|
||||
|
13
pu/pu.go
Normal file
13
pu/pu.go
Normal 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
15
pu/pu_openbsd.go
Normal 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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user