all repos — legit @ 08255439fb30e5262794344f4a83bd4538c8606f

web frontend for git

unveil.go (view raw)

 1//go:build openbsd
 2// +build openbsd
 3
 4package main
 5
 6/*
 7#include <stdlib.h>
 8#include <unistd.h>
 9*/
10import "C"
11
12import (
13	"fmt"
14	"unsafe"
15)
16
17func Unveil(path string, perms string) error {
18	cpath := C.CString(path)
19	defer C.free(unsafe.Pointer(cpath))
20	cperms := C.CString(perms)
21	defer C.free(unsafe.Pointer(cperms))
22
23	rv, err := C.unveil(cpath, cperms)
24	if rv != 0 {
25		return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err)
26	}
27	return nil
28}