legit/unveil.go

30 lines
489 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 {
err := Unveil(path, perms)
if err != nil {
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
}