diff options
author | netblue30 <netblue30@protonmail.com> | 2021-05-18 13:49:02 -0400 |
---|---|---|
committer | netblue30 <netblue30@protonmail.com> | 2021-05-18 13:49:02 -0400 |
commit | b79e4416fe642976111a2d610a19c3e4696bb2e2 (patch) | |
tree | c038806bb80d57314a248dbc6df92b91d32a3a59 /src/jailcheck/seccomp.c | |
parent | readme, etc (diff) | |
download | firejail-b79e4416fe642976111a2d610a19c3e4696bb2e2.tar.gz firejail-b79e4416fe642976111a2d610a19c3e4696bb2e2.tar.zst firejail-b79e4416fe642976111a2d610a19c3e4696bb2e2.zip |
jailtest -> jailcheck (#4268)
Diffstat (limited to 'src/jailcheck/seccomp.c')
-rw-r--r-- | src/jailcheck/seccomp.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/jailcheck/seccomp.c b/src/jailcheck/seccomp.c new file mode 100644 index 000000000..9345eb970 --- /dev/null +++ b/src/jailcheck/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 "jailcheck.h" | ||
21 | #define MAXBUF 4096 | ||
22 | |||
23 | void 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 | } | ||