about summary refs log tree commit diff stats
path: root/openbsd
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd')
-rw-r--r--openbsd/__init__.py12
-rw-r--r--openbsd/openbsd_builder.py2
2 files changed, 3 insertions, 11 deletions
diff --git a/openbsd/__init__.py b/openbsd/__init__.py
index 1aab185..a688661 100644
--- a/openbsd/__init__.py
+++ b/openbsd/__init__.py
@@ -1,10 +1,10 @@
 
 import sys
+import os
 from cffi import FFI
 from ._openbsd import lib as _lib
 
 __all__ = ["pledge", "unveil"]
-
 _ffi = FFI()
 
 
@@ -14,7 +14,7 @@ def pledge(promises=None, execpromises=None):
     ret = _lib.pledge(promises, execpromises)
     if ret < 0:
         errno = _ffi.errno
-        raise OSError(errno, _decode(_ffi.string(_lib.strerror(errno), 256)))
+        raise OSError(errno, os.strerror(errno))
 
 
 def unveil(path=None, permissions=None):
@@ -23,7 +23,7 @@ def unveil(path=None, permissions=None):
     ret = _lib.unveil(path, permissions)
     if ret < 0:
         errno = _ffi.errno
-        raise OSError(errno, _decode(_ffi.string(_lib.strerror(errno), 256)))
+        raise OSError(errno, os.strerror(errno))
 
 
 if isinstance(b"openbsd", str):
@@ -32,9 +32,6 @@ if isinstance(b"openbsd", str):
         if isinstance(text, unicode):
             return text.encode("ascii")
         return text
-
-    def _decode(text):
-        return text
 else:
     # Python 3
     def _encode(text):
@@ -42,7 +39,4 @@ else:
             return text.encode("ascii")
         return text
 
-    def _decode(text):
-        return text.decode("ascii")
-
 
diff --git a/openbsd/openbsd_builder.py b/openbsd/openbsd_builder.py
index a8720c1..7778796 100644
--- a/openbsd/openbsd_builder.py
+++ b/openbsd/openbsd_builder.py
@@ -5,13 +5,11 @@ ffibuilder = FFI()
 ffibuilder.cdef('''
     int pledge(const char *promises, const char *execpromises);
     int unveil(const char *path, const char *permissions);
-    char *strerror(int errnum);
 ''')
 
 ffibuilder.set_source("openbsd._openbsd",
 """
     #include <unistd.h>
-    #include <string.h>
 """)
 
 if __name__ == "__main__":
div>
f07bb12f ^
4c13e1f2 ^

f07bb12f ^







4c13e1f2 ^
f07bb12f ^





















4c13e1f2 ^
f07bb12f ^
34a60763 ^
f07bb12f ^


62cd83ba ^

f07bb12f ^






4c13e1f2 ^

f07bb12f ^


4c13e1f2 ^

f07bb12f ^



4c13e1f2 ^


f07bb12f ^











f07bb12f ^















4c13e1f2 ^




34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^



f07bb12f ^
62cd83ba ^
f07bb12f ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145