File tree 1 file changed +30
-0
lines changed 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
package unix
6
6
7
+ import "fmt"
8
+
7
9
// Unveil implements the unveil syscall.
8
10
// For more information see unveil(2).
9
11
// Note that the special case of blocking further
10
12
// unveil calls is handled by UnveilBlock.
13
+ //
14
+ // Unveil requires OpenBSD 6.4 or later.
11
15
func Unveil (path string , flags string ) error {
16
+ err := supportsUnveil ()
17
+ if err != nil {
18
+ return err
19
+ }
12
20
pathBytes , err := BytePtrFromString (path )
13
21
if err != nil {
14
22
return err
@@ -22,6 +30,28 @@ func Unveil(path string, flags string) error {
22
30
23
31
// UnveilBlock blocks future unveil calls.
24
32
// For more information see unveil(2).
33
+ //
34
+ // Unveil requires OpenBSD 6.4 or later.
25
35
func UnveilBlock () error {
36
+ err := supportsUnveil ()
37
+ if err != nil {
38
+ return err
39
+ }
26
40
return unveil (nil , nil )
27
41
}
42
+
43
+ // supportsUnveil checks for availability of the unveil(2) system call based
44
+ // on the running OpenBSD version.
45
+ func supportsUnveil () error {
46
+ maj , min , err := majmin ()
47
+ if err != nil {
48
+ return err
49
+ }
50
+
51
+ // unveil is not available before 6.4
52
+ if maj < 6 || (maj == 6 && min <= 3 ) {
53
+ return fmt .Errorf ("cannot use execpromises on OpenBSD %d.%d" , maj , min )
54
+ }
55
+
56
+ return nil
57
+ }
You can’t perform that action at this time.
0 commit comments