aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-07-05 07:23:31 -0400
committerLibravatar netblue30 <netblue30@protonmail.com>2021-07-05 07:23:31 -0400
commitfe0f975f447d59977d90c3226cc8c623b31b20b3 (patch)
tree70897a33cde6c716e273d927d18a6be4b54c18a9 /src
parentdeprecated whitelist=yes/no in /etc/firejail/firejail.config (diff)
downloadfirejail-fe0f975f447d59977d90c3226cc8c623b31b20b3.tar.gz
firejail-fe0f975f447d59977d90c3226cc8c623b31b20b3.tar.zst
firejail-fe0f975f447d59977d90c3226cc8c623b31b20b3.zip
move whitelist/blacklist to allow/deny
Diffstat (limited to 'src')
-rw-r--r--src/firejail/profile.c7
-rw-r--r--src/tools/profcleaner.c75
2 files changed, 82 insertions, 0 deletions
diff --git a/src/firejail/profile.c b/src/firejail/profile.c
index 29bb5fbac..b7c7185a6 100644
--- a/src/firejail/profile.c
+++ b/src/firejail/profile.c
@@ -1751,6 +1751,13 @@ void profile_read(const char *fname) {
1751 free(ptr); 1751 free(ptr);
1752 ptr = tmp; 1752 ptr = tmp;
1753 } 1753 }
1754 else if (strncmp(ptr, "deny-nolog ", 11) == 0) {
1755 char *tmp;
1756 if (asprintf(&tmp, "blacklist-nolog %s", ptr + 11) == -1)
1757 errExit("asprintf");
1758 free(ptr);
1759 ptr = tmp;
1760 }
1754 // translate noallow/nodeny to nowhitelist/noblacklist 1761 // translate noallow/nodeny to nowhitelist/noblacklist
1755 else if (strncmp(ptr, "noallow ", 8) == 0) { 1762 else if (strncmp(ptr, "noallow ", 8) == 0) {
1756 char *tmp; 1763 char *tmp;
diff --git a/src/tools/profcleaner.c b/src/tools/profcleaner.c
new file mode 100644
index 000000000..93bb3f73d
--- /dev/null
+++ b/src/tools/profcleaner.c
@@ -0,0 +1,75 @@
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
21//*************************************************************
22// Small utility program to convert profiles from blacklist/whitelist to deny/allow
23// Compile:
24// gcc -o profcleaner profcleaner.c
25// Usage:
26// profcleaner *.profile
27//*************************************************************
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <unistd.h>
33#define MAXBUF 4096
34
35int main(int argc, char **argv) {
36 printf("Usage: profcleaner files\n");
37 int i;
38
39 for (i = 1; i < argc; i++) {
40 FILE *fp = fopen(argv[i], "r");
41 if (!fp) {
42 fprintf(stderr, "Error: cannot open %s\n", argv[i]);
43 return 1;
44 }
45
46 FILE *fpout = fopen("profcleaner-tmp", "w");
47 if (!fpout) {
48 fprintf(stderr, "Error: cannot open output file\n");
49 return 1;
50 }
51
52 char buf[MAXBUF];
53 while (fgets(buf, MAXBUF, fp)) {
54 if (strncmp(buf, "blacklist-nolog", 15) == 0)
55 fprintf(fpout, "deny-nolog %s", buf + 15);
56 else if (strncmp(buf, "blacklist", 9) == 0)
57 fprintf(fpout, "deny %s", buf + 9);
58 else if (strncmp(buf, "noblacklist", 11) == 0)
59 fprintf(fpout, "nodeny %s", buf + 11);
60 else if (strncmp(buf, "whitelist", 9) == 0)
61 fprintf(fpout, "allow %s", buf + 9);
62 else if (strncmp(buf, "nowhitelist", 11) == 0)
63 fprintf(fpout, "noallow %s", buf + 11);
64 else
65 fprintf(fpout, "%s", buf);
66 }
67
68 fclose(fp);
69 fclose(fpout);
70 unlink(argv[i]);
71 rename("profcleaner-tmp", argv[i]);
72 }
73
74 return 0;
75} \ No newline at end of file