aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/codeql-analysis.yml6
-rw-r--r--etc/inc/allow-common-devel.inc5
-rw-r--r--etc/inc/disable-common.inc2
-rw-r--r--etc/inc/disable-programs.inc1
-rw-r--r--etc/profile-a-l/cmake.profile9
-rw-r--r--etc/profile-m-z/mupdf-gl.profile3
-rw-r--r--etc/profile-m-z/mupdf-x11.profile3
-rw-r--r--etc/profile-m-z/mupdf.profile4
-rw-r--r--etc/profile-m-z/ocenaudio.profile33
-rw-r--r--etc/profile-m-z/opera.profile11
-rw-r--r--etc/profile-m-z/pip.profile5
-rw-r--r--src/fbuilder/build_fs.c117
-rw-r--r--src/fbuilder/build_profile.c6
-rw-r--r--src/fbuilder/fbuilder.h6
-rw-r--r--src/fbuilder/filedb.c10
-rw-r--r--src/man/firejail.txt12
16 files changed, 193 insertions, 40 deletions
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 1352ce3e6..e1d972d04 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -47,7 +47,7 @@ jobs:
47 47
48 # Initializes the CodeQL tools for scanning. 48 # Initializes the CodeQL tools for scanning.
49 - name: Initialize CodeQL 49 - name: Initialize CodeQL
50 uses: github/codeql-action/init@75f07e7ab2ee63cba88752d8c696324e4df67466 50 uses: github/codeql-action/init@883476649888a9e8e219d5b2e6b789dc024f690c
51 with: 51 with:
52 languages: ${{ matrix.language }} 52 languages: ${{ matrix.language }}
53 # If you wish to specify custom queries, you can do so here or in a config file. 53 # If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
58 # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 58 # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
59 # If this step fails, then you should remove it and run the build manually (see below) 59 # If this step fails, then you should remove it and run the build manually (see below)
60 - name: Autobuild 60 - name: Autobuild
61 uses: github/codeql-action/autobuild@75f07e7ab2ee63cba88752d8c696324e4df67466 61 uses: github/codeql-action/autobuild@883476649888a9e8e219d5b2e6b789dc024f690c
62 62
63 # ℹī¸ Command-line programs to run using the OS shell. 63 # ℹī¸ Command-line programs to run using the OS shell.
64 # 📚 https://git.io/JvXDl 64 # 📚 https://git.io/JvXDl
@@ -72,4 +72,4 @@ jobs:
72 # make release 72 # make release
73 73
74 - name: Perform CodeQL Analysis 74 - name: Perform CodeQL Analysis
75 uses: github/codeql-action/analyze@75f07e7ab2ee63cba88752d8c696324e4df67466 75 uses: github/codeql-action/analyze@883476649888a9e8e219d5b2e6b789dc024f690c
diff --git a/etc/inc/allow-common-devel.inc b/etc/inc/allow-common-devel.inc
index 4e460fc10..9576239f3 100644
--- a/etc/inc/allow-common-devel.inc
+++ b/etc/inc/allow-common-devel.inc
@@ -8,8 +8,13 @@ noblacklist ${HOME}/.gitconfig
8noblacklist ${HOME}/.git-credentials 8noblacklist ${HOME}/.git-credentials
9 9
10# Java 10# Java
11noblacklist ${HOME}/.ammonite
12noblacklist ${HOME}/.config/jgit
13noblacklist ${HOME}/.g8
11noblacklist ${HOME}/.gradle 14noblacklist ${HOME}/.gradle
15noblacklist ${HOME}/.ivy2
12noblacklist ${HOME}/.java 16noblacklist ${HOME}/.java
17noblacklist ${HOME}/.sbt
13 18
14# Node.js 19# Node.js
15noblacklist ${HOME}/.node-gyp 20noblacklist ${HOME}/.node-gyp
diff --git a/etc/inc/disable-common.inc b/etc/inc/disable-common.inc
index 2e2f6c429..080a7f3a1 100644
--- a/etc/inc/disable-common.inc
+++ b/etc/inc/disable-common.inc
@@ -13,6 +13,7 @@ blacklist-nolog ${HOME}/.*_history_*
13blacklist-nolog ${HOME}/.adobe 13blacklist-nolog ${HOME}/.adobe
14blacklist-nolog ${HOME}/.ammonite/history 14blacklist-nolog ${HOME}/.ammonite/history
15blacklist-nolog ${HOME}/.cache/greenclip* 15blacklist-nolog ${HOME}/.cache/greenclip*
16blacklist-nolog ${HOME}/.cache/mupdf.history
16blacklist-nolog ${HOME}/.histfile 17blacklist-nolog ${HOME}/.histfile
17blacklist-nolog ${HOME}/.history 18blacklist-nolog ${HOME}/.history
18blacklist-nolog ${HOME}/.kde/share/apps/klipper 19blacklist-nolog ${HOME}/.kde/share/apps/klipper
@@ -511,6 +512,7 @@ blacklist /usr/lib/policykit-1/polkit-agent-helper-1
511blacklist /usr/lib/dbus-1.0/dbus-daemon-launch-helper 512blacklist /usr/lib/dbus-1.0/dbus-daemon-launch-helper
512blacklist /usr/lib/eject/dmcrypt-get-device 513blacklist /usr/lib/eject/dmcrypt-get-device
513blacklist /usr/lib/chromium/chrome-sandbox 514blacklist /usr/lib/chromium/chrome-sandbox
515blacklist /usr/lib/opera/opera_sandbox
514blacklist /usr/lib/vmware 516blacklist /usr/lib/vmware
515blacklist ${PATH}/suexec 517blacklist ${PATH}/suexec
516blacklist /usr/lib/squid/basic_pam_auth 518blacklist /usr/lib/squid/basic_pam_auth
diff --git a/etc/inc/disable-programs.inc b/etc/inc/disable-programs.inc
index fcd385cae..efe1b2572 100644
--- a/etc/inc/disable-programs.inc
+++ b/etc/inc/disable-programs.inc
@@ -175,6 +175,7 @@ blacklist ${HOME}/.cache/mypaint
175blacklist ${HOME}/.cache/netsurf 175blacklist ${HOME}/.cache/netsurf
176blacklist ${HOME}/.cache/nheko 176blacklist ${HOME}/.cache/nheko
177blacklist ${HOME}/.cache/nvim 177blacklist ${HOME}/.cache/nvim
178blacklist ${HOME}/.cache/ocenaudio
178blacklist ${HOME}/.cache/okular 179blacklist ${HOME}/.cache/okular
179blacklist ${HOME}/.cache/opera 180blacklist ${HOME}/.cache/opera
180blacklist ${HOME}/.cache/opera-beta 181blacklist ${HOME}/.cache/opera-beta
diff --git a/etc/profile-a-l/cmake.profile b/etc/profile-a-l/cmake.profile
index 26cc2a00a..acc03e93f 100644
--- a/etc/profile-a-l/cmake.profile
+++ b/etc/profile-a-l/cmake.profile
@@ -1,12 +1,15 @@
1# Firejail profile for cargo 1# Firejail profile for cmake
2# Description: The Rust package manager 2# Description: A cross-platform open-source make system
3# This file is overwritten after every install/update 3# This file is overwritten after every install/update
4quiet 4quiet
5# Persistent local customizations 5# Persistent local customizations
6include cargo.local 6include cmake.local
7# Persistent global definitions 7# Persistent global definitions
8include globals.local 8include globals.local
9 9
10whitelist /usr/share/cmake
11whitelist /usr/share/cmake-*
12
10memory-deny-write-execute 13memory-deny-write-execute
11 14
12# Redirect 15# Redirect
diff --git a/etc/profile-m-z/mupdf-gl.profile b/etc/profile-m-z/mupdf-gl.profile
index be94a9083..c5d94c371 100644
--- a/etc/profile-m-z/mupdf-gl.profile
+++ b/etc/profile-m-z/mupdf-gl.profile
@@ -7,7 +7,10 @@ include mupdf-gl.local
7# added by included profile 7# added by included profile
8#include globals.local 8#include globals.local
9 9
10noblacklist ${HOME}/.cache/mupdf.history
10noblacklist ${HOME}/.mupdf.history 11noblacklist ${HOME}/.mupdf.history
11 12
13ignore no3d
14
12# Redirect 15# Redirect
13include mupdf.profile 16include mupdf.profile
diff --git a/etc/profile-m-z/mupdf-x11.profile b/etc/profile-m-z/mupdf-x11.profile
index 256201d0c..547aa4f2f 100644
--- a/etc/profile-m-z/mupdf-x11.profile
+++ b/etc/profile-m-z/mupdf-x11.profile
@@ -7,8 +7,5 @@ include mupdf-x11.local
7# added by included profile 7# added by included profile
8#include globals.local 8#include globals.local
9 9
10memory-deny-write-execute
11read-only ${HOME}
12
13# Redirect 10# Redirect
14include mupdf.profile 11include mupdf.profile
diff --git a/etc/profile-m-z/mupdf.profile b/etc/profile-m-z/mupdf.profile
index 22cb83cc4..7a1f62858 100644
--- a/etc/profile-m-z/mupdf.profile
+++ b/etc/profile-m-z/mupdf.profile
@@ -21,6 +21,7 @@ apparmor
21caps.drop all 21caps.drop all
22machine-id 22machine-id
23net none 23net none
24no3d
24nodvd 25nodvd
25nogroups 26nogroups
26noinput 27noinput
@@ -41,3 +42,6 @@ private-tmp
41 42
42dbus-user none 43dbus-user none
43dbus-system none 44dbus-system none
45
46memory-deny-write-execute
47read-only ${HOME}
diff --git a/etc/profile-m-z/ocenaudio.profile b/etc/profile-m-z/ocenaudio.profile
index 0bfb35333..080b4c92b 100644
--- a/etc/profile-m-z/ocenaudio.profile
+++ b/etc/profile-m-z/ocenaudio.profile
@@ -6,8 +6,9 @@ include ocenaudio.local
6# Persistent global definitions 6# Persistent global definitions
7include globals.local 7include globals.local
8 8
9noblacklist ${HOME}/.cache/ocenaudio
9noblacklist ${HOME}/.local/share/ocenaudio 10noblacklist ${HOME}/.local/share/ocenaudio
10noblacklist ${DOCUMENTS} 11
11noblacklist ${MUSIC} 12noblacklist ${MUSIC}
12 13
13include disable-common.inc 14include disable-common.inc
@@ -18,38 +19,44 @@ include disable-programs.inc
18include disable-shell.inc 19include disable-shell.inc
19include disable-xdg.inc 20include disable-xdg.inc
20 21
22mkdir ${HOME}/.cache/ocenaudio
23mkdir ${HOME}/.local/share/ocenaudio
24whitelist ${HOME}/.cache/ocenaudio
25whitelist ${HOME}/.local/share/ocenaudio
26whitelist ${DOWNLOADS}
27whitelist ${MUSIC}
28include whitelist-common.inc
29include whitelist-run-common.inc
30include whitelist-runuser-common.inc
21include whitelist-usr-share-common.inc 31include whitelist-usr-share-common.inc
22include whitelist-var-common.inc 32include whitelist-var-common.inc
23 33
24apparmor 34apparmor
25caps.drop all 35caps.drop all
26ipc-namespace 36#ipc-namespace
27# net none - breaks update functionality and AppArmor on Ubuntu systems
28# Add 'net none' to your ocenaudio.local when you want that functionality.
29#net none
30netfilter 37netfilter
31no3d 38no3d
32nodvd 39nodvd
33nogroups 40nogroups
34noinput 41noinput
35nonewprivs 42nonewprivs
43noprinters
36noroot 44noroot
37notv 45notv
38nou2f 46nou2f
39novideo 47novideo
40protocol unix 48# Add `protocol unix\nignore protocol` to your ocenaudio.local to disable networking.
49protocol unix,inet,inet6
41seccomp 50seccomp
42shell none 51shell none
43tracelog 52tracelog
44 53
45private-bin ocenaudio 54private-bin ocenaudio,ocenvst
46private-cache 55private-cache
47private-dev 56private-dev
48private-etc alternatives,asound.conf,fonts,ld.so.cache,ld.so.preload,pulse 57private-etc alternatives,asound.conf,ca-certificates,crypto-policies,dconf,fonts,group,gtk-2.0,gtk-3.0,hostname,hosts,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,mime.types,nsswitch.conf,pki,pulse,resolv.conf,ssl,X11,xdg
58private-opt ocenaudio
49private-tmp 59private-tmp
50 60
51# breaks preferences 61dbus-user none
52# dbus-user none 62dbus-system none
53# dbus-system none
54
55#memory-deny-write-execute - breaks on Arch (see issue #1803)
diff --git a/etc/profile-m-z/opera.profile b/etc/profile-m-z/opera.profile
index b342b3961..e52e9294d 100644
--- a/etc/profile-m-z/opera.profile
+++ b/etc/profile-m-z/opera.profile
@@ -17,5 +17,16 @@ whitelist ${HOME}/.cache/opera
17whitelist ${HOME}/.config/opera 17whitelist ${HOME}/.config/opera
18whitelist ${HOME}/.opera 18whitelist ${HOME}/.opera
19 19
20# https://github.com/netblue30/firejail/issues/4965
21ignore whitelist /usr/share/mozilla/extensions
22ignore whitelist /usr/share/webext
23
24# opera uses opera_sandbox instead of chrome-sandbox
25noblacklist /usr/lib/opera/opera_sandbox
26ignore noblacklist /usr/lib/chromium/chrome-sandbox
27
28# Add the below to your opera.local if you want to disable auto update
29#env OPERA_AUTOUPDATE_DISABLED=1
30
20# Redirect 31# Redirect
21include chromium-common.profile 32include chromium-common.profile
diff --git a/etc/profile-m-z/pip.profile b/etc/profile-m-z/pip.profile
index a0926371f..560957d47 100644
--- a/etc/profile-m-z/pip.profile
+++ b/etc/profile-m-z/pip.profile
@@ -3,7 +3,7 @@
3# This file is overwritten after every install/update 3# This file is overwritten after every install/update
4quiet 4quiet
5# Persistent local customizations 5# Persistent local customizations
6include meson.local 6include pip.local
7# Persistent global definitions 7# Persistent global definitions
8include globals.local 8include globals.local
9 9
@@ -12,6 +12,9 @@ ignore read-only ${HOME}/.local/lib
12# Allow python3 (blacklisted by disable-interpreters.inc) 12# Allow python3 (blacklisted by disable-interpreters.inc)
13include allow-python3.inc 13include allow-python3.inc
14 14
15noblacklist ${HOME}/.cache/pip
16
17#whitelist ${HOME}/.cache/pip
15#whitelist ${HOME}/.local/lib/python* 18#whitelist ${HOME}/.local/lib/python*
16 19
17# Redirect 20# Redirect
diff --git a/src/fbuilder/build_fs.c b/src/fbuilder/build_fs.c
index ede96c9b4..88b5eaad3 100644
--- a/src/fbuilder/build_fs.c
+++ b/src/fbuilder/build_fs.c
@@ -68,8 +68,23 @@ static void process_file(const char *fname, const char *dir, void (*callback)(ch
68 ptr += 7; 68 ptr += 7;
69 else if (strncmp(ptr, "open ", 5) == 0) 69 else if (strncmp(ptr, "open ", 5) == 0)
70 ptr += 5; 70 ptr += 5;
71 else if (strncmp(ptr, "opendir ", 8) == 0)
72 ptr += 8;
73 else if (strncmp(ptr, "connect ", 8) == 0) {
74 ptr += 8;
75 // file descriptor argument
76 if (!isdigit(*ptr))
77 continue;
78 while (isdigit(*ptr))
79 ptr++;
80 if (*ptr++ != ' ')
81 continue;
82 if (*ptr != '/')
83 continue;
84 }
71 else 85 else
72 continue; 86 continue;
87
73 if (strncmp(ptr, dir, dir_len) != 0) 88 if (strncmp(ptr, dir, dir_len) != 0)
74 continue; 89 continue;
75 90
@@ -117,8 +132,19 @@ static void etc_callback(char *ptr) {
117 if (strncmp(ptr, "/etc/firejail", 13) == 0) 132 if (strncmp(ptr, "/etc/firejail", 13) == 0)
118 return; 133 return;
119 134
135 // extract the directory:
136 assert(strncmp(ptr, "/etc", 4) == 0);
137 ptr += 4;
138 if (*ptr != '/')
139 return;
140 ptr++;
141
142 if (*ptr == '/') // double '/'
143 ptr++;
144 if (*ptr == '\0')
145 return;
146
120 // add only top files and directories 147 // add only top files and directories
121 ptr += 5; // skip "/etc/"
122 char *end = strchr(ptr, '/'); 148 char *end = strchr(ptr, '/');
123 if (end) 149 if (end)
124 *end = '\0'; 150 *end = '\0';
@@ -163,6 +189,11 @@ static char *var_skip[] = {
163static FileDB *var_out = NULL; 189static FileDB *var_out = NULL;
164static FileDB *var_skip = NULL; 190static FileDB *var_skip = NULL;
165static void var_callback(char *ptr) { 191static void var_callback(char *ptr) {
192 // skip /var/lib/flatpak, /var/lib/snapd directory
193 if (strncmp(ptr, "/var/lib/flatpak", 16) == 0 ||
194 strncmp(ptr, "/var/lib/snapd", 14) == 0)
195 return;
196
166 // extract the directory: 197 // extract the directory:
167 assert(strncmp(ptr, "/var", 4) == 0); 198 assert(strncmp(ptr, "/var", 4) == 0);
168 char *p1 = ptr + 4; 199 char *p1 = ptr + 4;
@@ -183,8 +214,6 @@ void build_var(const char *fname, FILE *fp) {
183 assert(fname); 214 assert(fname);
184 215
185 var_skip = filedb_load_whitelist(var_skip, "whitelist-var-common.inc", "whitelist /var/"); 216 var_skip = filedb_load_whitelist(var_skip, "whitelist-var-common.inc", "whitelist /var/");
186 var_skip = filedb_add(var_skip, "lib/flatpak");
187 var_skip = filedb_add(var_skip, "lib/snapd");
188 process_files(fname, "/var", var_callback); 217 process_files(fname, "/var", var_callback);
189 218
190 // always whitelist /var 219 // always whitelist /var
@@ -193,6 +222,88 @@ void build_var(const char *fname, FILE *fp) {
193 fprintf(fp, "include whitelist-var-common.inc\n"); 222 fprintf(fp, "include whitelist-var-common.inc\n");
194} 223}
195 224
225//*******************************************
226// run directory
227//*******************************************
228static FileDB *run_out = NULL;
229static FileDB *run_skip = NULL;
230static void run_callback(char *ptr) {
231 // skip /run/firejail
232 if (strncmp(ptr, "/run/firejail", 13) == 0)
233 return;
234 // skip files in /run/user
235 if (strncmp(ptr, "/run/user", 9) == 0)
236 return;
237
238 // extract the directory:
239 assert(strncmp(ptr, "/run", 4) == 0);
240 char *p1 = ptr + 4;
241 if (*p1 != '/')
242 return;
243 p1++;
244
245 if (*p1 == '/') // double '/'
246 p1++;
247 if (*p1 == '\0')
248 return;
249
250 if (!filedb_find(run_skip, p1))
251 run_out = filedb_add(run_out, p1);
252}
253
254void build_run(const char *fname, FILE *fp) {
255 assert(fname);
256
257 run_skip = filedb_load_whitelist(run_skip, "whitelist-run-common.inc", "whitelist /run/");
258 process_files(fname, "/run", run_callback);
259
260 // always whitelist /run
261 if (run_out)
262 filedb_print(run_out, "whitelist /run/", fp);
263 fprintf(fp, "include whitelist-run-common.inc\n");
264}
265
266//*******************************************
267// ${RUNUSER} directory
268//*******************************************
269static char *runuser_fname = NULL;
270static FileDB *runuser_out = NULL;
271static FileDB *runuser_skip = NULL;
272static void runuser_callback(char *ptr) {
273 // extract the directory:
274 assert(runuser_fname);
275 assert(strncmp(ptr, runuser_fname, strlen(runuser_fname)) == 0);
276 char *p1 = ptr + strlen(runuser_fname);
277 if (*p1 != '/')
278 return;
279 p1++;
280
281 if (*p1 == '/') // double '/'
282 p1++;
283 if (*p1 == '\0')
284 return;
285
286 if (!filedb_find(runuser_skip, p1))
287 runuser_out = filedb_add(runuser_out, p1);
288}
289
290void build_runuser(const char *fname, FILE *fp) {
291 assert(fname);
292
293 if (asprintf(&runuser_fname, "/run/user/%d", getuid()) < 0)
294 errExit("asprintf");
295
296 if (!is_dir(runuser_fname))
297 return;
298
299 runuser_skip = filedb_load_whitelist(runuser_skip, "whitelist-runuser-common.inc", "whitelist ${RUNUSER}/");
300 process_files(fname, runuser_fname, runuser_callback);
301
302 // always whitelist /run/user/$UID
303 if (runuser_out)
304 filedb_print(runuser_out, "whitelist ${RUNUSER}/", fp);
305 fprintf(fp, "include whitelist-runuser-common.inc\n");
306}
196 307
197//******************************************* 308//*******************************************
198// usr/share directory 309// usr/share directory
diff --git a/src/fbuilder/build_profile.c b/src/fbuilder/build_profile.c
index 4fcd950c6..24cb4472c 100644
--- a/src/fbuilder/build_profile.c
+++ b/src/fbuilder/build_profile.c
@@ -122,8 +122,10 @@ void build_profile(int argc, char **argv, int index, FILE *fp) {
122 fprintf(fp, "\n"); 122 fprintf(fp, "\n");
123 123
124 fprintf(fp, "### Filesystem Whitelisting ###\n"); 124 fprintf(fp, "### Filesystem Whitelisting ###\n");
125 build_share(trace_output, fp); 125 build_run(trace_output, fp);
126 //todo: include whitelist-runuser-common.inc 126 build_runuser(trace_output, fp);
127 if (!arg_appimage)
128 build_share(trace_output, fp);
127 build_var(trace_output, fp); 129 build_var(trace_output, fp);
128 fprintf(fp, "\n"); 130 fprintf(fp, "\n");
129 131
diff --git a/src/fbuilder/fbuilder.h b/src/fbuilder/fbuilder.h
index 3e23d7854..b07209e51 100644
--- a/src/fbuilder/fbuilder.h
+++ b/src/fbuilder/fbuilder.h
@@ -26,7 +26,7 @@
26#include <sys/types.h> 26#include <sys/types.h>
27#include <sys/stat.h> 27#include <sys/stat.h>
28#include <fcntl.h> 28#include <fcntl.h>
29 29#include <fnmatch.h>
30 30
31#define MAX_BUF 4096 31#define MAX_BUF 4096
32// main.c 32// main.c
@@ -46,6 +46,8 @@ void build_var(const char *fname, FILE *fp);
46void build_tmp(const char *fname, FILE *fp); 46void build_tmp(const char *fname, FILE *fp);
47void build_dev(const char *fname, FILE *fp); 47void build_dev(const char *fname, FILE *fp);
48void build_share(const char *fname, FILE *fp); 48void build_share(const char *fname, FILE *fp);
49void build_run(const char *fname, FILE *fp);
50void build_runuser(const char *fname, FILE *fp);
49 51
50// build_bin.c 52// build_bin.c
51void build_bin(const char *fname, FILE *fp); 53void build_bin(const char *fname, FILE *fp);
@@ -61,7 +63,7 @@ char *extract_dir(char *fname);
61typedef struct filedb_t { 63typedef struct filedb_t {
62 struct filedb_t *next; 64 struct filedb_t *next;
63 char *fname; // file name 65 char *fname; // file name
64 int len; // length of file name 66 unsigned len; // length of file name
65} FileDB; 67} FileDB;
66 68
67FileDB *filedb_add(FileDB *head, const char *fname); 69FileDB *filedb_add(FileDB *head, const char *fname);
diff --git a/src/fbuilder/filedb.c b/src/fbuilder/filedb.c
index 569095785..89b6980d2 100644
--- a/src/fbuilder/filedb.c
+++ b/src/fbuilder/filedb.c
@@ -25,17 +25,17 @@ FileDB *filedb_find(FileDB *head, const char *fname) {
25 assert(fname); 25 assert(fname);
26 FileDB *ptr = head; 26 FileDB *ptr = head;
27 int found = 0; 27 int found = 0;
28 int len = strlen(fname);
29 28
30 while (ptr) { 29 while (ptr) {
31 // exact name 30 // ptr->fname can be a pattern, like .mutter-Xwaylandauth.*
32 if (strcmp(fname, ptr->fname) == 0) { 31 // check if fname is a match
32 if (fnmatch(ptr->fname, fname, FNM_PATHNAME) == 0) {
33 found = 1; 33 found = 1;
34 break; 34 break;
35 } 35 }
36 36
37 // parent directory in the list 37 // parent directory in the list
38 if (len > ptr->len && 38 if (strlen(fname) > ptr->len &&
39 fname[ptr->len] == '/' && 39 fname[ptr->len] == '/' &&
40 strncmp(ptr->fname, fname, ptr->len) == 0) { 40 strncmp(ptr->fname, fname, ptr->len) == 0) {
41 found = 1; 41 found = 1;
@@ -54,8 +54,6 @@ FileDB *filedb_find(FileDB *head, const char *fname) {
54FileDB *filedb_add(FileDB *head, const char *fname) { 54FileDB *filedb_add(FileDB *head, const char *fname) {
55 assert(fname); 55 assert(fname);
56 56
57 // todo: support fnames such as ${RUNUSER}/.mutter-Xwaylandauth.*
58
59 // don't add it if it is already there or if the parent directory is already in the list 57 // don't add it if it is already there or if the parent directory is already in the list
60 if (filedb_find(head, fname)) 58 if (filedb_find(head, fname))
61 return head; 59 return head;
diff --git a/src/man/firejail.txt b/src/man/firejail.txt
index 228d0c91c..1d028b8ac 100644
--- a/src/man/firejail.txt
+++ b/src/man/firejail.txt
@@ -185,23 +185,27 @@ $ firejail "\-\-blacklist=/home/username/My Virtual Machines"
185$ firejail \-\-blacklist=/home/username/My\\ Virtual\\ Machines 185$ firejail \-\-blacklist=/home/username/My\\ Virtual\\ Machines
186.TP 186.TP
187\fB\-\-build 187\fB\-\-build
188The command builds a whitelisted profile. The profile is printed on the screen. The program is run in a very relaxed sandbox, with only --caps.drop=all and --nonewprivs. Programs that raise user privileges are not supported. 188The command builds a whitelisted profile. The profile is printed on the screen. The program is run in a very relaxed sandbox, with only \-\-caps.drop=all and \-\-seccomp=!chroot. Programs that raise user privileges are not supported.
189.br 189.br
190 190
191.br 191.br
192Example: 192Example:
193.br 193.br
194$ firejail --build vlc ~/Videos/test.mp4 194$ firejail \-\-build vlc ~/Videos/test.mp4
195.br
196$ firejail \-\-build \-\-appimage ~/Downloads/Subsurface.AppImage
195.TP 197.TP
196\fB\-\-build=profile-file 198\fB\-\-build=profile-file
197The command builds a whitelisted profile, and saves it in profile-file. The program is run in a very relaxed sandbox, 199The command builds a whitelisted profile, and saves it in profile-file. The program is run in a very relaxed sandbox,
198with only --caps.drop=all and --nonewprivs. Programs that raise user privileges are not supported. 200with only \-\-caps.drop=all and \-\-seccomp=!chroot. Programs that raise user privileges are not supported.
199.br 201.br
200 202
201.br 203.br
202Example: 204Example:
203.br 205.br
204$ firejail --build=vlc.profile vlc ~/Videos/test.mp4 206$ firejail \-\-build=vlc.profile vlc ~/Videos/test.mp4
207.br
208$ firejail \-\-build=Subsurface.profile \-\-appimage ~/Downloads/Subsurface.AppImage
205.TP 209.TP
206\fB\-c 210\fB\-c
207Login shell compatibility option. This option is use by some login programs when executing 211Login shell compatibility option. This option is use by some login programs when executing