openshim

Source ยป

openshim is a shim for OpenBSD pledge and unveil syscalls using cgo.

openshim.go

Example

package main

import (
	"fmt"
	"log"

	"github.com/esote/openshim"
)

func main() {
	if _, err := openshim.Pledge("stdio rpath unveil", ""); err != nil {
		log.Fatal(err)
	}

	if _, err := openshim.Unveil("/tmp/program_metadata", "r"); err != nil {
		log.Fatal(err)
	}

	if _, err := openshim.Pledge("stdio rpath", ""); err != nil {
		log.Fatal(err)
	}

	fmt.Println("Hello")
}