// Copyright (C) 2018 Marius Schellenberger

// +build openbsd

package godrop

import (
	"errors"
	"golang.org/x/sys/unix"
)

// Pledge is a wrapper for x/sys/unix Pledge.
//
// See https://go.googlesource.com/sys/+/master/unix/openbsd_pledge.go for usage.
func Pledge(promises, execpromises string) (err error) {
	err = unix.Pledge(promises, execpromises)
	if err != nil {
		err = errors.New("pledge: " + err.Error())
	}
	return
}

// PledgePromises is a wrapper for x/sys/unix PledgePromises.
//
// See https://go.googlesource.com/sys/+/master/unix/openbsd_pledge.go for usage.
func PledgePromises(promises string) (err error) {
	err = unix.PledgePromises(promises)
	if err != nil {
		err = errors.New("pledge: " + err.Error())
	}
	return
}

// PledgeExecpromises is a wrapper for x/sys/unix PledgeExecpromises.
//
// See https://go.googlesource.com/sys/+/master/unix/openbsd_pledge.go for usage.
func PledgeExecpromises(execpromises string) (err error) {
	err = unix.PledgeExecpromises(execpromises)
	if err != nil {
		err = errors.New("pledge: " + err.Error())
	}
	return
}
