aboutsummaryrefslogtreecommitdiffstats
path: root/src/jailtest/seccomp.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-02-23 08:40:02 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2021-02-23 08:40:02 -0500
commit80868ffa70784fae2642c3d9219e08a17822bc86 (patch)
tree430b0a9c90e9adad7b18f601e3fc5ba1d92bebe2 /src/jailtest/seccomp.c
parenthardening ssh, tor (diff)
downloadfirejail-80868ffa70784fae2642c3d9219e08a17822bc86.tar.gz
firejail-80868ffa70784fae2642c3d9219e08a17822bc86.tar.zst
firejail-80868ffa70784fae2642c3d9219e08a17822bc86.zip
jailtest
Diffstat (limited to 'src/jailtest/seccomp.c')
-rw-r--r--src/jailtest/seccomp.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/jailtest/seccomp.c b/src/jailtest/seccomp.c
new file mode 100644
index 000000000..2cecb4b4d
--- /dev/null
+++ b/src/jailtest/seccomp.c
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2014-2021 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#include "jailtest.h"
21#define MAXBUF 4096
22
23void seccomp_test(pid_t pid) {
24 char *file;
25 if (asprintf(&file, "/proc/%d/status", pid) == -1)
26 errExit("asprintf");
27
28 FILE *fp = fopen(file, "r");
29 if (!fp) {
30 printf(" Error: cannot open %s\n", file);
31 free(file);
32 return;
33 }
34
35 char buf[MAXBUF];
36 while (fgets(buf, MAXBUF, fp)) {
37 if (strncmp(buf, "Seccomp:", 8) == 0) {
38 int val = -1;
39 int rv = sscanf(buf + 8, "\t%d", &val);
40 if (rv != 1 || val == 0)
41 printf(" Warning: seccomp not enabled\n");
42 break;
43 }
44 }
45 fclose(fp);
46 free(file);
47}