diff options
Diffstat (limited to '')
-rw-r--r-- | unveil.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/unveil.go b/unveil.go new file mode 100644 index 0000000..389dfeb --- /dev/null +++ b/unveil.go @@ -0,0 +1,28 @@ +//go:build openbsd +// +build openbsd + +package main + +/* +#include <stdlib.h> +#include <unistd.h> +*/ +import "C" + +import ( + "fmt" + "unsafe" +) + +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)) + + rv, err := C.unveil(cpath, cperms) + if rv != 0 { + return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err) + } + return nil +} |