diff options
Diffstat (limited to 'vendor/golang.org/x/sys/unix/unveil_openbsd.go')
-rw-r--r-- | vendor/golang.org/x/sys/unix/unveil_openbsd.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/unveil_openbsd.go b/vendor/golang.org/x/sys/unix/unveil_openbsd.go new file mode 100644 index 0000000..168d5ae --- /dev/null +++ b/vendor/golang.org/x/sys/unix/unveil_openbsd.go | |||
@@ -0,0 +1,42 @@ | |||
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 | package unix | ||
6 | |||
7 | import ( | ||
8 | "syscall" | ||
9 | "unsafe" | ||
10 | ) | ||
11 | |||
12 | // Unveil implements the unveil syscall. | ||
13 | // For more information see unveil(2). | ||
14 | // Note that the special case of blocking further | ||
15 | // unveil calls is handled by UnveilBlock. | ||
16 | func Unveil(path string, flags string) error { | ||
17 | pathPtr, err := syscall.BytePtrFromString(path) | ||
18 | if err != nil { | ||
19 | return err | ||
20 | } | ||
21 | flagsPtr, err := syscall.BytePtrFromString(flags) | ||
22 | if err != nil { | ||
23 | return err | ||
24 | } | ||
25 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) | ||
26 | if e != 0 { | ||
27 | return e | ||
28 | } | ||
29 | return nil | ||
30 | } | ||
31 | |||
32 | // UnveilBlock blocks future unveil calls. | ||
33 | // For more information see unveil(2). | ||
34 | func UnveilBlock() error { | ||
35 | // Both pointers must be nil. | ||
36 | var pathUnsafe, flagsUnsafe unsafe.Pointer | ||
37 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) | ||
38 | if e != 0 { | ||
39 | return e | ||
40 | } | ||
41 | return nil | ||
42 | } | ||