This commit is contained in:
Josh Rickmar
2023-10-24 14:35:32 +00:00
parent ab98739231
commit d03d157e76
2 changed files with 7 additions and 14 deletions

View File

@@ -20,8 +20,7 @@ import (
//
// For more information see pledge(2).
func Pledge(promises, execpromises string) error {
err := pledgeAvailable()
if err != nil {
if err := pledgeAvailable(); err != nil {
return err
}
@@ -50,8 +49,7 @@ func Pledge(promises, execpromises string) error {
//
// For more information see pledge(2).
func PledgePromises(promises string) error {
err := pledgeAvailable()
if err != nil {
if err := pledgeAvailable(); err != nil {
return err
}
@@ -78,8 +76,7 @@ func PledgePromises(promises string) error {
//
// For more information see pledge(2).
func PledgeExecpromises(execpromises string) error {
err := pledgeAvailable()
if err != nil {
if err := pledgeAvailable(); err != nil {
return err
}
@@ -133,8 +130,7 @@ func pledgeAvailable() error {
// Require OpenBSD 6.4 as a minimum.
if maj < 6 || (maj == 6 && min <= 3) {
return fmt.Errorf("cannot call Pledge on OpenBSD %d.%d", maj,
min)
return fmt.Errorf("cannot call Pledge on OpenBSD %d.%d", maj, min)
}
return nil

View File

@@ -15,8 +15,7 @@ import (
// Note that the special case of blocking further
// unveil calls is handled by UnveilBlock.
func Unveil(path string, flags string) error {
err := supportsUnveil()
if err != nil {
if err := supportsUnveil(); err != nil {
return err
}
pathPtr, err := syscall.BytePtrFromString(path)
@@ -37,8 +36,7 @@ func Unveil(path string, flags string) error {
// UnveilBlock blocks future unveil calls.
// For more information see unveil(2).
func UnveilBlock() error {
err := supportsUnveil()
if err != nil {
if err := supportsUnveil(); err != nil {
return err
}
// Both pointers must be nil.
@@ -60,8 +58,7 @@ func supportsUnveil() error {
// unveil is not available before 6.4
if maj < 6 || (maj == 6 && min <= 3) {
return fmt.Errorf("cannot call Unveil on OpenBSD %d.%d", maj,
min)
return fmt.Errorf("cannot call Unveil on OpenBSD %d.%d", maj, min)
}
return nil