This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
addon.cc
340 lines (255 loc) · 5.8 KB
/
addon.cc
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
// Copyright (C) 2019, Rory Bradford <[email protected]>
// MIT License
#include <node.h>
#include <seccomp.h>
#include "seccomp.h"
namespace seccomp {
using v8::Local;
using v8::Object;
void wrapError(const v8::FunctionCallbackInfo<v8::Value>& args) {
int type = args[0].As<v8::Number>()->Value();
args.GetReturnValue().Set(SCMP_ACT_ERRNO(type));
}
void InitAll(v8::Local<v8::Object> exports) {
NODE_DEFINE_CONSTANT(exports, SCMP_ACT_ALLOW);
NODE_DEFINE_CONSTANT(exports, SCMP_ACT_KILL_PROCESS);
NODE_SET_METHOD(exports, "SCMP_ACT_ERRNO", wrapError);
#ifdef EACCES
NODE_DEFINE_CONSTANT(exports, EACCES);
#endif
#ifdef EADDRINUSE
NODE_DEFINE_CONSTANT(exports, EADDRINUSE);
#endif
#ifdef EADDRNOTAVAIL
NODE_DEFINE_CONSTANT(exports, EADDRNOTAVAIL);
#endif
#ifdef EAFNOSUPPORT
NODE_DEFINE_CONSTANT(exports, EAFNOSUPPORT);
#endif
#ifdef EAGAIN
NODE_DEFINE_CONSTANT(exports, EAGAIN);
#endif
#ifdef EWOULDBLOCK
NODE_DEFINE_CONSTANT(exports, EWOULDBLOCK);
#endif
#ifdef EALREADY
NODE_DEFINE_CONSTANT(exports, EALREADY);
#endif
#ifdef EBADF
NODE_DEFINE_CONSTANT(exports, EBADF);
#endif
#ifdef EBADMSG
NODE_DEFINE_CONSTANT(exports, EBADMSG);
#endif
#ifdef EBUSY
NODE_DEFINE_CONSTANT(exports, EBUSY);
#endif
#ifdef ECANCELED
NODE_DEFINE_CONSTANT(exports, ECANCELED);
#endif
#ifdef ECHILD
NODE_DEFINE_CONSTANT(exports, ECHILD);
#endif
#ifdef ECONNABORTED
NODE_DEFINE_CONSTANT(exports, ECONNABORTED);
#endif
#ifdef ECONNREFUSED
NODE_DEFINE_CONSTANT(exports, ECONNREFUSED);
#endif
#ifdef ECONNRESET
NODE_DEFINE_CONSTANT(exports, ECONNRESET);
#endif
#ifdef EDEADLK
NODE_DEFINE_CONSTANT(exports, EDEADLK);
#endif
#ifdef EDESTADDRREQ
NODE_DEFINE_CONSTANT(exports, EDESTADDRREQ);
#endif
#ifdef EDOM
NODE_DEFINE_CONSTANT(exports, EDOM);
#endif
#ifdef EDQUOT
NODE_DEFINE_CONSTANT(exports, EDQUOT);
#endif
#ifdef EEXIST
NODE_DEFINE_CONSTANT(exports, EEXIST);
#endif
#ifdef EFAULT
NODE_DEFINE_CONSTANT(exports, EFAULT);
#endif
#ifdef EFBIG
NODE_DEFINE_CONSTANT(exports, EFBIG);
#endif
#ifdef EHOSTUNREACH
NODE_DEFINE_CONSTANT(exports, EHOSTUNREACH);
#endif
#ifdef EIDRM
NODE_DEFINE_CONSTANT(exports, EIDRM);
#endif
#ifdef EILSEQ
NODE_DEFINE_CONSTANT(exports, EILSEQ);
#endif
#ifdef EINPROGRESS
NODE_DEFINE_CONSTANT(exports, EINPROGRESS);
#endif
#ifdef EINTR
NODE_DEFINE_CONSTANT(exports, EINTR);
#endif
#ifdef EINVAL
NODE_DEFINE_CONSTANT(exports, EINVAL);
#endif
#ifdef EIO
NODE_DEFINE_CONSTANT(exports, EIO);
#endif
#ifdef EISCONN
NODE_DEFINE_CONSTANT(exports, EISCONN);
#endif
#ifdef EISDIR
NODE_DEFINE_CONSTANT(exports, EISDIR);
#endif
#ifdef ELOOP
NODE_DEFINE_CONSTANT(exports, ELOOP);
#endif
#ifdef EMFILE
NODE_DEFINE_CONSTANT(exports, EMFILE);
#endif
#ifdef EMLINK
NODE_DEFINE_CONSTANT(exports, EMLINK);
#endif
#ifdef EMSGSIZE
NODE_DEFINE_CONSTANT(exports, EMSGSIZE);
#endif
#ifdef EMULTIHOP
NODE_DEFINE_CONSTANT(exports, EMULTIHOP);
#endif
#ifdef ENAMETOOLONG
NODE_DEFINE_CONSTANT(exports, ENAMETOOLONG);
#endif
#ifdef ENETDOWN
NODE_DEFINE_CONSTANT(exports, ENETDOWN);
#endif
#ifdef ENETRESET
NODE_DEFINE_CONSTANT(exports, ENETRESET);
#endif
#ifdef ENETUNREACH
NODE_DEFINE_CONSTANT(exports, ENETUNREACH);
#endif
#ifdef ENFILE
NODE_DEFINE_CONSTANT(exports, ENFILE);
#endif
#ifdef ENOBUFS
NODE_DEFINE_CONSTANT(exports, ENOBUFS);
#endif
#ifdef ENODATA
NODE_DEFINE_CONSTANT(exports, ENODATA);
#endif
#ifdef ENODEV
NODE_DEFINE_CONSTANT(exports, ENODEV);
#endif
#ifdef ENOENT
NODE_DEFINE_CONSTANT(exports, ENOENT);
#endif
#ifdef ENOEXEC
NODE_DEFINE_CONSTANT(exports, ENOEXEC);
#endif
#ifdef ENOLINK
NODE_DEFINE_CONSTANT(exports, ENOLINK);
#endif
#ifdef ENOLCK
NODE_DEFINE_CONSTANT(exports, ENOLCK);
#endif
#ifdef ENOMEM
NODE_DEFINE_CONSTANT(exports, ENOMEM);
#endif
#ifdef ENOMSG
NODE_DEFINE_CONSTANT(exports, ENOMSG);
#endif
#ifdef ENOPROTOOPT
NODE_DEFINE_CONSTANT(exports, ENOPROTOOPT);
#endif
#ifdef ENOSPC
NODE_DEFINE_CONSTANT(exports, ENOSPC);
#endif
#ifdef ENOSR
NODE_DEFINE_CONSTANT(exports, ENOSR);
#endif
#ifdef ENOSTR
NODE_DEFINE_CONSTANT(exports, ENOSTR);
#endif
#ifdef ENOSYS
NODE_DEFINE_CONSTANT(exports, ENOSYS);
#endif
#ifdef ENOTCONN
NODE_DEFINE_CONSTANT(exports, ENOTCONN);
#endif
#ifdef ENOTDIR
NODE_DEFINE_CONSTANT(exports, ENOTDIR);
#endif
#ifdef ENOTEMPTY
NODE_DEFINE_CONSTANT(exports, ENOTEMPTY);
#endif
#ifdef ENOTSOCK
NODE_DEFINE_CONSTANT(exports, ENOTSOCK);
#endif
#ifdef ENOTSUP
NODE_DEFINE_CONSTANT(exports, ENOTSUP);
#else
#ifdef EOPNOTSUPP
NODE_DEFINE_CONSTANT(exports, EOPNOTSUPP);
#endif
#endif
#ifdef ENOTTY
NODE_DEFINE_CONSTANT(exports, ENOTTY);
#endif
#ifdef ENXIO
NODE_DEFINE_CONSTANT(exports, ENXIO);
#endif
#ifdef EOVERFLOW
NODE_DEFINE_CONSTANT(exports, EOVERFLOW);
#endif
#ifdef EPERM
NODE_DEFINE_CONSTANT(exports, EPERM);
#endif
#ifdef EPIPE
NODE_DEFINE_CONSTANT(exports, EPIPE);
#endif
#ifdef EPROTO
NODE_DEFINE_CONSTANT(exports, EPROTO);
#endif
#ifdef EPROTONOSUPPORT
NODE_DEFINE_CONSTANT(exports, EPROTONOSUPPORT);
#endif
#ifdef EPROTOTYPE
NODE_DEFINE_CONSTANT(exports, EPROTOTYPE);
#endif
#ifdef ERANGE
NODE_DEFINE_CONSTANT(exports, ERANGE);
#endif
#ifdef EROFS
NODE_DEFINE_CONSTANT(exports, EROFS);
#endif
#ifdef ESPIPE
NODE_DEFINE_CONSTANT(exports, ESPIPE);
#endif
#ifdef ESRCH
NODE_DEFINE_CONSTANT(exports, ESRCH);
#endif
#ifdef ESTALE
NODE_DEFINE_CONSTANT(exports, ESTALE);
#endif
#ifdef ETIME
NODE_DEFINE_CONSTANT(exports, ETIME);
#endif
#ifdef ETIMEDOUT
NODE_DEFINE_CONSTANT(exports, ETIMEDOUT);
#endif
#ifdef ETXTBSY
NODE_DEFINE_CONSTANT(exports, ETXTBSY);
#endif
#ifdef EXDEV
NODE_DEFINE_CONSTANT(exports, EXDEV);
#endif
NodeSeccomp::Init(exports);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, InitAll)
}