legit/unveil.go

29 lines
488 B
Go
Raw Normal View History

2022-12-18 05:34:11 +00:00
//go:build openbsd
// +build openbsd
package main
import (
2022-12-21 14:17:33 +00:00
"golang.org/x/sys/unix"
2022-12-21 14:22:08 +00:00
"log"
2022-12-18 05:34:11 +00:00
)
func Unveil(path string, perms string) error {
2022-12-21 14:22:08 +00:00
log.Printf("unveil: \"%s\", %s", path, perms)
2022-12-21 14:17:33 +00:00
return unix.Unveil(path, perms)
}
func UnveilBlock() error {
2022-12-21 14:22:08 +00:00
log.Printf("unveil: block")
2022-12-21 14:17:33 +00:00
return unix.UnveilBlock()
}
2022-12-18 05:34:11 +00:00
2022-12-21 14:17:33 +00:00
func UnveilPaths(paths []string, perms string) error {
for _, path := range paths {
2022-12-22 05:52:47 +00:00
if err := Unveil(path, perms); err != nil {
2022-12-21 14:17:33 +00:00
return err
}
2022-12-18 05:34:11 +00:00
}
2022-12-21 14:17:33 +00:00
return UnveilBlock()
2022-12-18 05:34:11 +00:00
}