summaryrefslogtreecommitdiffstats
path: root/unveil.go
diff options
context:
space:
mode:
authorLibravatar zak <e-zk@users.noreply.github.com>2022-12-22 00:17:33 +1000
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-22 11:17:59 +0530
commit4aa8cbff320b669fc07f356409b05d6b1795c342 (patch)
tree71b02d6bc99ba805d728b28d70023573233ce7a4 /unveil.go
parentd0f5d874c58abac60bd9145eb98c0305047c9d0f (diff)
downloadlegit-4aa8cbff320b669fc07f356409b05d6b1795c342.tar.gz
legit-4aa8cbff320b669fc07f356409b05d6b1795c342.tar.bz2
legit-4aa8cbff320b669fc07f356409b05d6b1795c342.zip
unveil: initial commit
Diffstat (limited to '')
-rw-r--r--unveil.go32
1 files changed, 14 insertions, 18 deletions
diff --git a/unveil.go b/unveil.go
index 242ce14..99b6629 100644
--- a/unveil.go
+++ b/unveil.go
@@ -1,30 +1,26 @@
//go:build openbsd
// +build openbsd
-// Doesn't do anything yet.
-
package main
-/*
-#include <stdlib.h>
-#include <unistd.h>
-*/
-import "C"
-
import (
- "fmt"
- "unsafe"
+ "golang.org/x/sys/unix"
)
func Unveil(path string, perms string) error {
- cpath := C.CString(path)
- defer C.free(unsafe.Pointer(cpath))
- cperms := C.CString(perms)
- defer C.free(unsafe.Pointer(cperms))
+ return unix.Unveil(path, perms)
+}
+
+func UnveilBlock() error {
+ return unix.UnveilBlock()
+}
- rv, err := C.unveil(cpath, cperms)
- if rv != 0 {
- return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err)
+func UnveilPaths(paths []string, perms string) error {
+ for _, path := range paths {
+ err := Unveil(path, perms)
+ if err != nil {
+ return err
+ }
}
- return nil
+ return UnveilBlock()
}