-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadbox.c
More file actions
40 lines (33 loc) · 975 Bytes
/
threadbox.c
File metadata and controls
40 lines (33 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <string.h>
void sandbox_ps() {
FILE *fp = fopen("/sys/kernel/security/funcsandbox/sandbox_ps", "w");
if (fp == NULL) {
perror("Failed to open sandbox_ps");
return;
}
fprintf(fp, " ");
fclose(fp);
}
void permissions(const char *promises, const char *debug, int complain) {
FILE *p = fopen("/sys/kernel/security/funcsandbox/promises", "w");
FILE *d = fopen("/sys/kernel/security/funcsandbox/debug", "w");
FILE *c = fopen("/sys/kernel/security/funcsandbox/learning_mode", "w");
if (p == NULL || d == NULL || c == NULL) {
perror("Failed to open one or more permission files");
if (p) fclose(p);
if (d) fclose(d);
if (c) fclose(c);
return;
}
fprintf(p, "%s", promises);
if (strlen(debug) != 0) {
fprintf(d, "%s", debug);
}
if (complain) {
fprintf(c, " ");
}
fclose(p);
fclose(d);
fclose(c);
}