From 5ea7cae973e8329ae768c35bda41e656f974815d Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Sun, 18 Dec 2022 11:04:11 +0530 Subject: unveil: init --- unveil.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 unveil.go (limited to 'unveil.go') 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 +#include +*/ +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 +} -- cgit