@@ -31,19 +31,21 @@ func Pledge(promises, execpromises string) error {
31
31
32
32
// OS support for execpromises is required only when execpromises is not
33
33
// the empty string.
34
- err = supportsExecpromises (maj , min , execpromises != "" )
35
- if err != nil {
36
- return err
34
+ if execpromises != "" {
35
+ err = supportsExecpromises (maj , min )
36
+ if err != nil {
37
+ return err
38
+ }
37
39
}
38
40
39
- _promises , err := BytePtrFromString (promises )
41
+ promisesBytes , err := BytePtrFromString (promises )
40
42
if err != nil {
41
43
return err
42
44
}
43
45
44
46
// This variable will hold either a nil pointer or a pointer to the
45
47
// NUL-terminated execpromises string.
46
- var _execpromises * byte
48
+ var execpromisesBytes * byte
47
49
48
50
// If we're running on OpenBSD >= 6.3, pass execpromises to the syscall.
49
51
// While an empty execpromises string is required by this API on
@@ -54,10 +56,10 @@ func Pledge(promises, execpromises string) error {
54
56
if err != nil {
55
57
return err
56
58
}
57
- _execpromises = exptr
59
+ execpromisesBytes = exptr
58
60
}
59
61
60
- return pledge (_promises , _execpromises )
62
+ return pledge (promisesBytes , execpromisesBytes )
61
63
}
62
64
63
65
// PledgePromises implements the pledge syscall.
@@ -66,12 +68,12 @@ func Pledge(promises, execpromises string) error {
66
68
//
67
69
// For more information see pledge(2).
68
70
func PledgePromises (promises string ) error {
69
- _promises , err := BytePtrFromString (promises )
71
+ promisesBytes , err := BytePtrFromString (promises )
70
72
if err != nil {
71
73
return err
72
74
}
73
75
74
- return pledge (_promises , nil )
76
+ return pledge (promisesBytes , nil )
75
77
}
76
78
77
79
// PledgeExecpromises implements the pledge syscall.
@@ -88,17 +90,17 @@ func PledgeExecpromises(execpromises string) error {
88
90
return err
89
91
}
90
92
91
- err = supportsExecpromises (maj , min , true )
93
+ err = supportsExecpromises (maj , min )
92
94
if err != nil {
93
95
return err
94
96
}
95
97
96
- _execpromises , err := BytePtrFromString (execpromises )
98
+ execpromisesBytes , err := BytePtrFromString (execpromises )
97
99
if err != nil {
98
100
return err
99
101
}
100
102
101
- return pledge (nil , _execpromises )
103
+ return pledge (nil , execpromisesBytes )
102
104
}
103
105
104
106
// majmin returns major and minor version number for an OpenBSD system.
@@ -126,10 +128,10 @@ func majmin() (major int, minor int, err error) {
126
128
127
129
// supportsExecpromises checks for availability of the execpromises argument to
128
130
// the pledge(2) syscall based on the running OpenBSD version.
129
- func supportsExecpromises (maj , min int , required bool ) error {
131
+ func supportsExecpromises (maj , min int ) error {
130
132
// If OpenBSD <= 6.2 and execpromises is not empty,
131
133
// return an error - execpromises is not available before 6.3
132
- if ( maj < 6 || (maj == 6 && min <= 2 )) && required {
134
+ if maj < 6 || (maj == 6 && min <= 2 ) {
133
135
return fmt .Errorf ("cannot use execpromises on OpenBSD %d.%d" , maj , min )
134
136
}
135
137
0 commit comments