]>
Commit | Line | Data |
---|---|---|
1 | /** | |
2 | * Seccomp Library test program | |
3 | * | |
4 | * Copyright (c) 2012 Red Hat <pmoore@redhat.com> | |
5 | * Author: Paul Moore <paul@paul-moore.com> | |
6 | */ | |
7 | ||
8 | /* | |
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. | |
12 | * | |
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 | |
16 | * for more details. | |
17 | * | |
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>. | |
20 | */ | |
21 | ||
22 | #include <errno.h> | |
23 | #include <string.h> | |
24 | #include <stdlib.h> | |
25 | ||
26 | #include <seccomp.h> | |
27 | ||
28 | int main(int argc, char *argv[]) | |
29 | { | |
30 | char *name = NULL; | |
31 | ||
32 | if (seccomp_syscall_resolve_name("open") != __NR_open) | |
33 | goto fail; | |
34 | if (seccomp_syscall_resolve_name("read") != __NR_read) | |
35 | goto fail; | |
36 | if (seccomp_syscall_resolve_name("INVALID") != __NR_SCMP_ERROR) | |
37 | goto fail; | |
38 | ||
39 | if (seccomp_syscall_resolve_name_arch(SCMP_ARCH_NATIVE, | |
40 | "open") != __NR_open) | |
41 | goto fail; | |
42 | if (seccomp_syscall_resolve_name_arch(SCMP_ARCH_NATIVE, | |
43 | "read") != __NR_read) | |
44 | goto fail; | |
45 | if (seccomp_syscall_resolve_name_arch(SCMP_ARCH_NATIVE, | |
46 | "INVALID") != __NR_SCMP_ERROR) | |
47 | goto fail; | |
48 | ||
49 | name = seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE, __NR_open); | |
50 | if (name == NULL || strcmp(name, "open") != 0) | |
51 | goto fail; | |
52 | free(name); | |
53 | ||
54 | name = seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE, __NR_read); | |
55 | if (name == NULL || strcmp(name, "read") != 0) | |
56 | goto fail; | |
57 | free(name); | |
58 | ||
59 | name = seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE, | |
60 | __NR_SCMP_ERROR); | |
61 | if (name != NULL) | |
62 | goto fail; | |
63 | free(name); | |
64 | ||
65 | return 0; | |
66 | ||
67 | fail: | |
68 | if (name != NULL) | |
69 | free(name); | |
70 | return 1; | |
71 | } |