remove pledge - twitch-go - twitch.tv web application in Go
 (HTM) git clone git://git.codemadness.org/twitch-go
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 5046e93ea1144424eba2028bc87f804a33c66ce6
 (DIR) parent db4b6465bea75111fdb48fb65cb01e621e3b3cc0
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon,  4 Feb 2019 20:11:07 +0100
       
       remove pledge
       
       pledge(2) itself is awesome, but the Go interface is unstable unfortunately.
       
       Diffstat:
         D asm.s                               |       8 --------
         M main.go                             |      29 -----------------------------
         D openbsd_pledge.go                   |      39 -------------------------------
       
       3 files changed, 0 insertions(+), 76 deletions(-)
       ---
 (DIR) diff --git a/asm.s b/asm.s
       @@ -1,8 +0,0 @@
       -// +build openbsd
       -// +build 386 amd64 arm
       -// Everything below this line is ripped from the standard library source
       -
       -#include "textflag.h"
       -
       -TEXT ·use(SB),NOSPLIT,$0
       -        RET
 (DIR) diff --git a/main.go b/main.go
       @@ -227,18 +227,6 @@ func main() {
                        os.Exit(1)
                }
        
       -        if config_addrtype == "unix" {
       -                err := Pledge("stdio rpath cpath wpath dns unix fattr", nil)
       -                if err != nil {
       -                        log.Fatalln(err)
       -                }
       -        } else {
       -                err := Pledge("stdio rpath cpath wpath dns inet", nil)
       -                if err != nil {
       -                        log.Fatalln(err)
       -                }
       -        }
       -
                // Remove previous UDS if it exists.
                if config_addrtype == "unix" {
                        os.Remove(config_addr)
       @@ -255,10 +243,6 @@ func main() {
                        if err != nil {
                                log.Fatalln(err)
                        }
       -                err := Pledge("stdio rpath cpath wpath dns unix", nil)
       -                if err != nil {
       -                        log.Fatalln(err)
       -                }
                }
        
                if config_datadir != "" {
       @@ -300,18 +284,5 @@ func main() {
                        WriteTimeout:   10 * time.Second,
                        MaxHeaderBytes: 1 << 20,
                }
       -
       -        if config_addrtype == "unix" {
       -                err := Pledge("stdio rpath dns unix", nil)
       -                if err != nil {
       -                        log.Fatalln(err)
       -                }
       -        } else {
       -                err := Pledge("stdio rpath dns inet", nil)
       -                if err != nil {
       -                        log.Fatalln(err)
       -                }
       -        }
       -
                s.Serve(l)
        }
 (DIR) diff --git a/openbsd_pledge.go b/openbsd_pledge.go
       @@ -1,39 +0,0 @@
       -// +build openbsd
       -// +build 386 amd64 arm
       -
       -package main
       -
       -import (
       -        "syscall"
       -        "unsafe"
       -)
       -
       -const (
       -        SYS_PLEDGE = 108
       -)
       -
       -//go:noescape
       -func use(p unsafe.Pointer)
       -
       -// Pledge implements its respective syscall. For more information see pledge(2).
       -func Pledge(promises string, paths []string) (err error) {
       -        promisesPtr, err := syscall.BytePtrFromString(promises)
       -        if err != nil {
       -                return
       -        }
       -        promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil)
       -        if paths != nil {
       -                var pathsPtr []*byte
       -                if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil {
       -                        return
       -                }
       -                pathsUnsafe = unsafe.Pointer(&pathsPtr[0])
       -        }
       -        _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0)
       -        use(promisesUnsafe)
       -        use(pathsUnsafe)
       -        if e != 0 {
       -                err = e
       -        }
       -        return err
       -}