aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/sys/unix/openbsd_unveil.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/openbsd_unveil.go')
-rw-r--r--vendor/golang.org/x/sys/unix/openbsd_unveil.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/openbsd_unveil.go b/vendor/golang.org/x/sys/unix/openbsd_unveil.go
new file mode 100644
index 0000000..aebc2dc
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/openbsd_unveil.go
@@ -0,0 +1,44 @@
1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build openbsd
6
7package unix
8
9import (
10 "syscall"
11 "unsafe"
12)
13
14// Unveil implements the unveil syscall.
15// For more information see unveil(2).
16// Note that the special case of blocking further
17// unveil calls is handled by UnveilBlock.
18func Unveil(path string, flags string) error {
19 pathPtr, err := syscall.BytePtrFromString(path)
20 if err != nil {
21 return err
22 }
23 flagsPtr, err := syscall.BytePtrFromString(flags)
24 if err != nil {
25 return err
26 }
27 _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0)
28 if e != 0 {
29 return e
30 }
31 return nil
32}
33
34// UnveilBlock blocks future unveil calls.
35// For more information see unveil(2).
36func UnveilBlock() error {
37 // Both pointers must be nil.
38 var pathUnsafe, flagsUnsafe unsafe.Pointer
39 _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0)
40 if e != 0 {
41 return e
42 }
43 return nil
44}