Declare OpenBSD pledge(2) (#5)

This commit is contained in:
Maxim Baz
2018-04-12 23:37:59 +02:00
committed by GitHub
parent 90ca691ac9
commit b0f774585c
4 changed files with 27 additions and 6 deletions

2
Gopkg.lock generated
View File

@@ -25,6 +25,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "f0abeb920368b3b2e50d99f6e5705f0ad6ccd5f7e708f639b6c1fa0820364a22" inputs-digest = "559be3832a82b6c8884ca8103c92b2343135b96374cdf98f6cc294427bd26219"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

14
main.go
View File

@@ -2,8 +2,10 @@ package main
import ( import (
"flag" "flag"
"fmt"
"os" "os"
"github.com/maximbaz/browserpass-native/openbsd"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@@ -17,16 +19,18 @@ func main() {
flag.BoolVar(&version, "version", false, "print version and exit") flag.BoolVar(&version, "version", false, "print version and exit")
flag.Parse() flag.Parse()
if version {
fmt.Println("Browserpass host app version:", VERSION)
os.Exit(0)
}
openbsd.Pledge("stdio rpath proc exec")
log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
if verbose { if verbose {
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
} }
if version {
log.Info("Browserpass host app version: ", VERSION)
os.Exit(0)
}
log.Debugf("Starting browserpass host app v%v", VERSION) log.Debugf("Starting browserpass host app v%v", VERSION)
process() process()
} }

7
openbsd/generic.go Normal file
View File

@@ -0,0 +1,7 @@
// +build !openbsd
package openbsd
// Pledge allowed system calls, available only on OpenBSD systems
func Pledge(promises string) {
}

10
openbsd/openbsd.go Normal file
View File

@@ -0,0 +1,10 @@
// +build openbsd
package openbsd
import "golang.org/x/sys/unix"
// Pledge allowed system calls
func Pledge(promises string) {
unix.Pledge(promises, nil)
}