Revert "Remove pledge(2) support"

This reverts commit bc3215a8a6.
This commit is contained in:
Frank Denis 2018-08-15 17:56:33 +02:00
parent bc3215a8a6
commit a24cb0d900
4 changed files with 31 additions and 0 deletions

View File

@ -193,6 +193,9 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
flag.Parse() flag.Parse()
if *child {
PledgeChild()
}
if *svcFlag == "stop" || *svcFlag == "uninstall" { if *svcFlag == "stop" || *svcFlag == "uninstall" {
return nil return nil
} }

View File

@ -25,6 +25,8 @@ type App struct {
func main() { func main() {
dlog.Init("dnscrypt-proxy", dlog.SeverityNotice, "DAEMON") dlog.Init("dnscrypt-proxy", dlog.SeverityNotice, "DAEMON")
Pledge()
pwd, err := os.Getwd() pwd, err := os.Getwd()
if err != nil { if err != nil {
dlog.Fatal("Unable to find the path to the current directory") dlog.Fatal("Unable to find the path to the current directory")

View File

@ -0,0 +1,15 @@
// +build openbsd
package main
import (
"golang.org/x/sys/unix"
)
func Pledge() {
unix.Pledge("stdio rpath wpath cpath tmppath inet fattr flock dns getpw sendfd recvfd proc exec id", nil)
}
func PledgeChild() {
unix.Pledge("stdio rpath wpath cpath tmppath inet fattr flock dns recvfd", nil)
}

View File

@ -0,0 +1,11 @@
// +build !openbsd
package main
func Pledge() {
}
func PledgeChild() {
}