all repos — elgit @ 4aa8cbff320b669fc07f356409b05d6b1795c342

fork of legit: web frontend for git, written in go

unveil: initial commit

zak
commit

4aa8cbff320b669fc07f356409b05d6b1795c342

parent

d0f5d874c58abac60bd9145eb98c0305047c9d0f

1 file changed, 14 insertions(+), 18 deletions(-)

changed files
M unveil.gounveil.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) +} - rv, err := C.unveil(cpath, cperms) - if rv != 0 { - return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err) +func UnveilBlock() error { + return unix.UnveilBlock() +} + +func UnveilPaths(paths []string, perms string) error { + for _, path := range paths { + err := Unveil(path, perms) + if err != nil { + return err + } } - return nil + return UnveilBlock() }