Skip to content

Commit

Permalink
Add pledge(2) support for OpenBSD (gopasspw#469)
Browse files Browse the repository at this point in the history
Pledge (OpenBSD only) is a way to restrict the operations an
application can make use of on OpenBSD. Applications declare
their intent by specifying the system calls they will use,
after which point, any use outside of the pledge'd calls will
result in the kernel killing the process.

More info on pledge can be found here: http://man.openbsd.org/pledge
  • Loading branch information
qbit authored and dominikschulz committed Nov 17, 2017
1 parent d30ad5d commit 0a9d99c
Show file tree
Hide file tree
Showing 198 changed files with 56,774 additions and 24,779 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/justwatchcom/gopass/store/sub"
"github.com/justwatchcom/gopass/utils/ctxutil"
"github.com/justwatchcom/gopass/utils/out"
"github.com/justwatchcom/gopass/utils/protect"
colorable "github.com/mattn/go-colorable"
"github.com/urfave/cli"
)
Expand All @@ -38,6 +39,7 @@ var (
)

func main() {
protect.Pledge("stdio rpath tty proc exec")
ctx := context.Background()

// trap Ctrl+C and call cancel on the context
Expand Down
8 changes: 8 additions & 0 deletions utils/protect/protect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build !openbsd

package protect

// Pledge on any other system than OpenBSD doesn't do anything
func Pledge(s string) {
return
}
11 changes: 11 additions & 0 deletions utils/protect/protect_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build openbsd

package protect

import "golang.org/x/sys/unix"

// Pledge on OpenBSD lets us "promise" to only run a subset of
// system calls: http://man.openbsd.org/pledge
func Pledge(s string) {
_ = unix.Pledge(s, nil)
}
173 changes: 173 additions & 0 deletions vendor/golang.org/x/sys/unix/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions vendor/golang.org/x/sys/unix/asm.s

This file was deleted.

31 changes: 31 additions & 0 deletions vendor/golang.org/x/sys/unix/asm_linux_mipsx.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions vendor/golang.org/x/sys/unix/asm_openbsd_arm.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/golang.org/x/sys/unix/asm_solaris_amd64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0a9d99c

Please sign in to comment.