]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
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 | ||
15c0b25d AP |
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 | } |