github.com/criyle/go-sandbox@v0.10.3/pkg/forkexec/zsyscall_darwin.go (about)

     1  package forkexec
     2  
     3  import (
     4  	"syscall"
     5  	"unsafe"
     6  )
     7  
     8  // SandboxInit calls sandbox_init
     9  func SandboxInit(profile *byte, flags uint64, errorBuf **byte) (err error) {
    10  	var r1 uintptr
    11  	r1, _, err = syscall3(libc_sandbox_init_trampoline_addr, uintptr(unsafe.Pointer(profile)), uintptr(flags), uintptr(unsafe.Pointer(errorBuf)))
    12  	if r1 != 0 {
    13  		err = syscall.EINVAL
    14  	} else {
    15  		err = nil
    16  	}
    17  	return
    18  }
    19  
    20  // SandboxFreeError calls sandbox_free_error
    21  func SandboxFreeError(errorBuf *byte) {
    22  	syscall3(libc_sandbox_free_error_trampoline_addr, uintptr(unsafe.Pointer(errorBuf)), 0, 0)
    23  }
    24  
    25  var libc_sandbox_init_trampoline_addr uintptr
    26  
    27  //go:cgo_import_dynamic libc_sandbox_init sandbox_init "/usr/lib/libSystem.B.dylib"
    28  
    29  var libc_sandbox_free_error_trampoline_addr uintptr
    30  
    31  //go:cgo_import_dynamic libc_sandbox_free_error sandbox_free_error "/usr/lib/libSystem.B.dylib"