]>
iEval git - linux-seccomp.git/blob - libseccomp/tests/17-sim-arch_merge.c
2 * Seccomp Library test program
4 * Copyright (c) 2012 Red Hat <pmoore@redhat.com>
5 * Author: Paul Moore <paul@paul-moore.com>
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
11 * published by the Free Software Foundation.
13 * This library is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
29 int main(int argc
, char *argv
[])
32 struct util_options opts
;
33 scmp_filter_ctx ctx_64
= NULL
, ctx_32
= NULL
;
35 rc
= util_getopt(argc
, argv
, &opts
);
39 ctx_32
= seccomp_init(SCMP_ACT_KILL
);
44 ctx_64
= seccomp_init(SCMP_ACT_KILL
);
50 rc
= seccomp_arch_remove(ctx_32
, SCMP_ARCH_NATIVE
);
53 rc
= seccomp_arch_remove(ctx_64
, SCMP_ARCH_NATIVE
);
57 rc
= seccomp_arch_add(ctx_32
, SCMP_ARCH_X86
);
60 rc
= seccomp_arch_add(ctx_64
, SCMP_ARCH_X86_64
);
64 rc
= seccomp_rule_add(ctx_32
, SCMP_ACT_ALLOW
, SCMP_SYS(read
), 1,
65 SCMP_A0(SCMP_CMP_EQ
, STDIN_FILENO
));
69 rc
= seccomp_rule_add(ctx_32
, SCMP_ACT_ALLOW
, SCMP_SYS(write
), 1,
70 SCMP_A0(SCMP_CMP_EQ
, STDOUT_FILENO
));
74 rc
= seccomp_rule_add(ctx_32
, SCMP_ACT_ALLOW
, SCMP_SYS(write
), 1,
75 SCMP_A0(SCMP_CMP_EQ
, STDERR_FILENO
));
79 rc
= seccomp_rule_add(ctx_32
, SCMP_ACT_ALLOW
, SCMP_SYS(close
), 0);
83 rc
= seccomp_rule_add(ctx_64
, SCMP_ACT_ALLOW
, SCMP_SYS(socket
), 0);
87 rc
= seccomp_rule_add(ctx_64
, SCMP_ACT_ALLOW
, SCMP_SYS(connect
), 0);
91 rc
= seccomp_rule_add(ctx_64
, SCMP_ACT_ALLOW
, SCMP_SYS(shutdown
), 0);
95 rc
= seccomp_merge(ctx_64
, ctx_32
);
99 /* NOTE: ctx_32 is no longer valid at this point */
101 rc
= util_filter_output(&opts
, ctx_64
);
106 seccomp_release(ctx_64
);
107 return (rc
< 0 ? -rc
: rc
);
109 seccomp_release(ctx_32
);
This page took 0.055103 seconds and 4 git commands to generate.