]> iEval git - linux-seccomp.git/blame - Seccomp.xs
Initial commit
[linux-seccomp.git] / Seccomp.xs
CommitLineData
bcf524c1
MG
1#define PERL_NO_GET_CONTEXT
2#include "EXTERN.h"
3#include "perl.h"
4#include "XSUB.h"
5
6#include "ppport.h"
7
8#include <seccomp.h>
9#include <stdio.h>
10
11#include "const-c.inc"
12
13#define die_check_errno if(RETVAL < 0) \
14 croak("Failed with error %d (%s)\n", RETVAL, strerror(RETVAL))
15
16#define die_if_error if(RETVAL == __NR_SCMP_ERROR) \
17 croak("Failed to resolve system call %s", name);
18
19MODULE = Linux::Seccomp PACKAGE = Linux::Seccomp PREFIX = seccomp_
20
21INCLUDE: const-xs.inc
22PROTOTYPES: ENABLE
23
24struct scmp_arg_cmp
25seccomp_make_arg_cmp(arg, op, datum_a, datum_b = (scmp_datum_t) 0)
26 unsigned int arg;
27 enum scmp_compare op;
28 scmp_datum_t datum_a;
29 scmp_datum_t datum_b;
30PROTOTYPE: DISABLE
31CODE:
32 RETVAL = SCMP_CMP(arg, op, datum_a, datum_b);
33OUTPUT:
34 RETVAL
35
36U32 SCMP_ACT_ERRNO(I16 errno1)
37
38U32 SCMP_ACT_TRACE(I16 msg_num)
39
40
41NO_OUTPUT int
42seccomp_arch_add(ctx, arch_token)
43 scmp_filter_ctx ctx
44 U32 arch_token
45POSTCALL:
46 die_check_errno;
47
48bool
49seccomp_arch_exist(ctx, arch_token)
50 scmp_filter_ctx ctx
51 U32 arch_token
52PREINIT:
53 int ret;
54CODE:
55 ret = seccomp_arch_exist(ctx, arch_token);
56 if(ret != -EEXIST)
57 die_check_errno;
58 RETVAL = (ret != -EEXIST);
59OUTPUT:
60 RETVAL
61
62U32
63seccomp_arch_native()
64
65NO_OUTPUT int
66seccomp_arch_remove(ctx, arch_token)
67 scmp_filter_ctx ctx
68 U32 arch_token
69POSTCALL:
70 die_check_errno;
71
72U32
73seccomp_arch_resolve_name(arch_name)
74 const char *arch_name
75POSTCALL:
76 die_check_errno;
77
78NO_OUTPUT int
79seccomp_attr_get(ctx, attr, OUTLIST value)
80 scmp_filter_ctx ctx
81 enum scmp_filter_attr attr
82 U32 value
83POSTCALL:
84 die_check_errno;
85
86NO_OUTPUT int
87seccomp_attr_set(ctx, attr, value)
88 scmp_filter_ctx ctx
89 enum scmp_filter_attr attr
90 U32 value
91POSTCALL:
92 die_check_errno;
93
94NO_OUTPUT int
95seccomp_export_bpf(ctx, fd)
96 scmp_filter_ctx ctx
97 FILE *fd
98INTERFACE:
99 seccomp_export_bpf seccomp_export_pfc
100C_ARGS:
101 ctx, fileno(fd)
102POSTCALL:
103 die_check_errno;
104
105scmp_filter_ctx
106seccomp_init(def_action)
107 U32 def_action
108
109int
110seccomp_load(ctx)
111 scmp_filter_ctx ctx
112
113NO_OUTPUT int
114seccomp_merge(ctx_dst, ctx_src)
115 scmp_filter_ctx ctx_dst
116 scmp_filter_ctx ctx_src
117POSTCALL:
118 die_check_errno;
119
120void
121seccomp_release(ctx)
122 scmp_filter_ctx ctx
123
124NO_OUTPUT int
125seccomp_reset(ctx, def_action)
126 scmp_filter_ctx ctx
127 U32 def_action
128POSTCALL:
129 die_check_errno;
130
131NO_OUTPUT int
132seccomp_rule_add_array(ctx, action, syscall, args)
133 scmp_filter_ctx ctx
134 U32 action
135 int syscall
136 AV* args
137PREINIT:
138 unsigned int arg_cnt, i;
139 struct scmp_arg_cmp *arg_array;
140 SV **sv;
141 char *intermediate;
142INIT:
143 arg_cnt = av_len(args) + 1;
144 Newx(arg_array, arg_cnt, struct scmp_arg_cmp);
145 for(i = 0 ; i < arg_cnt ; i++){
146 sv = av_fetch(args, i, 0);
147 if(sv == NULL)
148 croak("Bad input array (av_fetch returned NULL)");
149 arg_array[i] = *((struct scmp_arg_cmp*) SvPV_nolen(*sv));
150 }
151C_ARGS:
152 ctx, action, syscall, arg_cnt, arg_array
153INTERFACE:
154 seccomp_rule_add_array seccomp_rule_add_exact_array
155POSTCALL:
156 Safefree(arg_array);
157 die_check_errno;
158
159
160NO_OUTPUT int
161seccomp_syscall_priority(ctx, syscall, priority)
162 scmp_filter_ctx ctx
163 int syscall
164 I8 priority
165POSTCALL:
166 die_check_errno;
167
168int
169seccomp_syscall_resolve_name(name)
170 const char *name
171POSTCALL:
172 die_if_error;
173
174int
175seccomp_syscall_resolve_name_arch(arch_token, name)
176 U32 arch_token
177 const char *name
178POSTCALL:
179 die_if_error;
180
181int
182seccomp_syscall_resolve_name_rewrite(arch_token, name)
183 U32 arch_token
184 const char *name
185POSTCALL:
186 die_if_error;
187
188char *
189seccomp_syscall_resolve_num_arch(arch_token, num)
190 U32 arch_token
191 int num
192
193AV*
194seccomp_version()
195 PREINIT:
196 const struct scmp_version* ver;
197 CODE:
198 ver = seccomp_version();
199 if(ver == NULL)
200 croak("seccomp_version() returned NULL");
201 RETVAL = newAV();
202 av_push(RETVAL, newSViv(ver->major));
203 av_push(RETVAL, newSViv(ver->minor));
204 av_push(RETVAL, newSViv(ver->micro));
205 OUTPUT:
206 RETVAL
This page took 0.036935 seconds and 4 git commands to generate.