aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-07-25 12:31:32 +0000
committerLibravatar GitHub <noreply@github.com>2021-07-25 12:31:32 +0000
commit209cdb529b8fcaebd1775e553d63367bb7a86ecd (patch)
treec17c687e310c9d3ad7874dd40636c104d308e9a6
parentRevert "move whitelist/blacklist to allow/deny" (diff)
parentMerge branch 'master' of https://github.com/netblue30/firejail (diff)
downloadfirejail-209cdb529b8fcaebd1775e553d63367bb7a86ecd.tar.gz
firejail-209cdb529b8fcaebd1775e553d63367bb7a86ecd.tar.zst
firejail-209cdb529b8fcaebd1775e553d63367bb7a86ecd.zip
Merge branch 'master' into revert-allow-deny-etc
-rw-r--r--CONTRIBUTING.md7
-rw-r--r--README.md2
-rw-r--r--RELNOTES1
-rw-r--r--etc/inc/disable-programs.inc8
-rw-r--r--etc/profile-a-l/avidemux.profile1
-rw-r--r--etc/profile-a-l/lifeograph.profile58
-rw-r--r--etc/profile-m-z/io.github.lainsce.Notejot.profile61
-rw-r--r--etc/profile-m-z/rednotebook.profile67
-rw-r--r--etc/profile-m-z/zim.profile72
-rw-r--r--src/firecfg/firecfg.config23
-rw-r--r--src/firejail/main.c189
-rw-r--r--src/firejail/no_sandbox.c3
-rw-r--r--src/firejail/output.c12
-rw-r--r--src/firejail/util.c5
-rwxr-xr-xtest/profiles/profile_syntax.exp2
-rw-r--r--test/profiles/test.profile2
16 files changed, 399 insertions, 114 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 688101d13..0f868d6c4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -34,6 +34,13 @@ If you want to write a new profile, the easiest way to do this is to use the
34[profile template](https://github.com/netblue30/firejail/blob/master/etc/templates/profile.template). 34[profile template](https://github.com/netblue30/firejail/blob/master/etc/templates/profile.template).
35If you have already written a profile, please make sure it follows the rules described in the template. 35If you have already written a profile, please make sure it follows the rules described in the template.
36 36
37If you add a new command, here's the checklist:
38
39 - [ ] Update manpages: firejail(1) and firejail-profile(5)
40 - [ ] Update shell completions
41 - [ ] Update vim syntax files
42 - [ ] Update --help
43
37# Editing the wiki 44# Editing the wiki
38 45
39You are highly encouraged to add your own tips and tricks to the [wiki](https://github.com/netblue30/firejail/wiki). 46You are highly encouraged to add your own tips and tricks to the [wiki](https://github.com/netblue30/firejail/wiki).
diff --git a/README.md b/README.md
index c635bf811..2fd8e3009 100644
--- a/README.md
+++ b/README.md
@@ -236,3 +236,5 @@ $ ./profstats *.profile
236``` 236```
237 237
238### New profiles: 238### New profiles:
239
240clion-eap, lifeograph, io.github.lainsce.Notejot, rednotebook, zim, microsoft-edge-beta
diff --git a/RELNOTES b/RELNOTES
index 905c25096..49b88ac08 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -2,6 +2,7 @@ firejail (0.9.67) baseline; urgency=low
2 * work in progress 2 * work in progress
3 * deprecated --disable-whitelist at compile time 3 * deprecated --disable-whitelist at compile time
4 * deprecated whitelist=yes/no in /etc/firejail/firejail.config 4 * deprecated whitelist=yes/no in /etc/firejail/firejail.config
5 * new profiles: microsoft-edge-beta
5 -- netblue30 <netblue30@yahoo.com> Mon, 28 Jun 2021 09:00:00 -0500 6 -- netblue30 <netblue30@yahoo.com> Mon, 28 Jun 2021 09:00:00 -0500
6 7
7firejail (0.9.66) baseline; urgency=low 8firejail (0.9.66) baseline; urgency=low
diff --git a/etc/inc/disable-programs.inc b/etc/inc/disable-programs.inc
index fd907034f..44983dd14 100644
--- a/etc/inc/disable-programs.inc
+++ b/etc/inc/disable-programs.inc
@@ -320,6 +320,7 @@ blacklist ${HOME}/.config/meld
320blacklist ${HOME}/.config/menulibre.cfg 320blacklist ${HOME}/.config/menulibre.cfg
321blacklist ${HOME}/.config/meteo-qt 321blacklist ${HOME}/.config/meteo-qt
322blacklist ${HOME}/.config/mfusion 322blacklist ${HOME}/.config/mfusion
323blacklist ${HOME}/.config/microsoft-edge-beta
323blacklist ${HOME}/.config/microsoft-edge-dev 324blacklist ${HOME}/.config/microsoft-edge-dev
324blacklist ${HOME}/.config/midori 325blacklist ${HOME}/.config/midori
325blacklist ${HOME}/.config/mirage 326blacklist ${HOME}/.config/mirage
@@ -449,6 +450,7 @@ blacklist ${HOME}/.config/youtube-music-desktop-app
449blacklist ${HOME}/.config/youtube-viewer 450blacklist ${HOME}/.config/youtube-viewer
450blacklist ${HOME}/.config/youtubemusic-nativefier-040164 451blacklist ${HOME}/.config/youtubemusic-nativefier-040164
451blacklist ${HOME}/.config/zathura 452blacklist ${HOME}/.config/zathura
453blacklist ${HOME}/.config/zim
452blacklist ${HOME}/.config/zoomus.conf 454blacklist ${HOME}/.config/zoomus.conf
453blacklist ${HOME}/.conkeror.mozdev.org 455blacklist ${HOME}/.conkeror.mozdev.org
454blacklist ${HOME}/.crawl 456blacklist ${HOME}/.crawl
@@ -684,6 +686,7 @@ blacklist ${HOME}/.local/share/godot
684blacklist ${HOME}/.local/share/gradio 686blacklist ${HOME}/.local/share/gradio
685blacklist ${HOME}/.local/share/gwenview 687blacklist ${HOME}/.local/share/gwenview
686blacklist ${HOME}/.local/share/i2p 688blacklist ${HOME}/.local/share/i2p
689blacklist ${HOME}/.local/share/io.github.lainsce.Notejot
687blacklist ${HOME}/.local/share/jami 690blacklist ${HOME}/.local/share/jami
688blacklist ${HOME}/.local/share/kaffeine 691blacklist ${HOME}/.local/share/kaffeine
689blacklist ${HOME}/.local/share/kalgebra 692blacklist ${HOME}/.local/share/kalgebra
@@ -840,6 +843,7 @@ blacklist ${HOME}/.qgis2
840blacklist ${HOME}/.qmmp 843blacklist ${HOME}/.qmmp
841blacklist ${HOME}/.quodlibet 844blacklist ${HOME}/.quodlibet
842blacklist ${HOME}/.redeclipse 845blacklist ${HOME}/.redeclipse
846blacklist ${HOME}/.rednotebook
843blacklist ${HOME}/.remmina 847blacklist ${HOME}/.remmina
844blacklist ${HOME}/.repo_.gitconfig.json 848blacklist ${HOME}/.repo_.gitconfig.json
845blacklist ${HOME}/.repoconfig 849blacklist ${HOME}/.repoconfig
@@ -1010,6 +1014,7 @@ blacklist ${HOME}/.cache/gummi
1010blacklist ${HOME}/.cache/icedove 1014blacklist ${HOME}/.cache/icedove
1011blacklist ${HOME}/.cache/inkscape 1015blacklist ${HOME}/.cache/inkscape
1012blacklist ${HOME}/.cache/inox 1016blacklist ${HOME}/.cache/inox
1017blacklist ${HOME}/.cache/io.github.lainsce.Notejot
1013blacklist ${HOME}/.cache/iridium 1018blacklist ${HOME}/.cache/iridium
1014blacklist ${HOME}/.cache/JetBrains/CLion* 1019blacklist ${HOME}/.cache/JetBrains/CLion*
1015blacklist ${HOME}/.cache/kcmshell5 1020blacklist ${HOME}/.cache/kcmshell5
@@ -1031,6 +1036,7 @@ blacklist ${HOME}/.cache/liferea
1031blacklist ${HOME}/.cache/lutris 1036blacklist ${HOME}/.cache/lutris
1032blacklist ${HOME}/.cache/marker 1037blacklist ${HOME}/.cache/marker
1033blacklist ${HOME}/.cache/matrix-mirage 1038blacklist ${HOME}/.cache/matrix-mirage
1039blacklist ${HOME}/.cache/microsoft-edge-beta
1034blacklist ${HOME}/.cache/microsoft-edge-dev 1040blacklist ${HOME}/.cache/microsoft-edge-dev
1035blacklist ${HOME}/.cache/midori 1041blacklist ${HOME}/.cache/midori
1036blacklist ${HOME}/.cache/minetest 1042blacklist ${HOME}/.cache/minetest
@@ -1066,6 +1072,7 @@ blacklist ${HOME}/.cache/qBittorrent
1066blacklist ${HOME}/.cache/quodlibet 1072blacklist ${HOME}/.cache/quodlibet
1067blacklist ${HOME}/.cache/qupzilla 1073blacklist ${HOME}/.cache/qupzilla
1068blacklist ${HOME}/.cache/qutebrowser 1074blacklist ${HOME}/.cache/qutebrowser
1075blacklist ${HOME}/.cache/rednotebook
1069blacklist ${HOME}/.cache/rhythmbox 1076blacklist ${HOME}/.cache/rhythmbox
1070blacklist ${HOME}/.cache/shotwell 1077blacklist ${HOME}/.cache/shotwell
1071blacklist ${HOME}/.cache/simple-scan 1078blacklist ${HOME}/.cache/simple-scan
@@ -1096,3 +1103,4 @@ blacklist ${HOME}/.cache/yandex-browser
1096blacklist ${HOME}/.cache/yandex-browser-beta 1103blacklist ${HOME}/.cache/yandex-browser-beta
1097blacklist ${HOME}/.cache/youtube-dl 1104blacklist ${HOME}/.cache/youtube-dl
1098blacklist ${HOME}/.cache/youtube-viewer 1105blacklist ${HOME}/.cache/youtube-viewer
1106blacklist ${HOME}/.cache/zim
diff --git a/etc/profile-a-l/avidemux.profile b/etc/profile-a-l/avidemux.profile
index 1ecc03da1..7f9d0f6e7 100644
--- a/etc/profile-a-l/avidemux.profile
+++ b/etc/profile-a-l/avidemux.profile
@@ -23,6 +23,7 @@ mkdir ${HOME}/.config/avidemux3_qt5rc
23whitelist ${HOME}/.avidemux6 23whitelist ${HOME}/.avidemux6
24whitelist ${HOME}/.config/avidemux3_qt5rc 24whitelist ${HOME}/.config/avidemux3_qt5rc
25whitelist ${VIDEOS} 25whitelist ${VIDEOS}
26
26include whitelist-common.inc 27include whitelist-common.inc
27include whitelist-runuser-common.inc 28include whitelist-runuser-common.inc
28include whitelist-usr-share-common.inc 29include whitelist-usr-share-common.inc
diff --git a/etc/profile-a-l/lifeograph.profile b/etc/profile-a-l/lifeograph.profile
new file mode 100644
index 000000000..b9ed0de8e
--- /dev/null
+++ b/etc/profile-a-l/lifeograph.profile
@@ -0,0 +1,58 @@
1# Firejail profile for lifeograph
2# Description: Lifeograph is a diary program to take personal notes
3# This file is overwritten after every install/update
4# Persistent local customizations
5include lifeograph.local
6# Persistent global definitions
7include globals.local
8
9nodeny ${DOCUMENTS}
10
11deny /usr/libexec
12
13include disable-common.inc
14include disable-devel.inc
15include disable-exec.inc
16include disable-interpreters.inc
17include disable-passwdmgr.inc
18include disable-programs.inc
19include disable-shell.inc
20include disable-xdg.inc
21
22allow ${DOCUMENTS}
23allow /usr/share/lifeograph
24include whitelist-common.inc
25include whitelist-runuser-common.inc
26include whitelist-usr-share-common.inc
27include whitelist-var-common.inc
28
29apparmor
30caps.drop all
31machine-id
32net none
33no3d
34nodvd
35nogroups
36noinput
37nonewprivs
38noroot
39nosound
40notv
41nou2f
42novideo
43protocol unix
44seccomp
45seccomp.block-secondary
46shell none
47tracelog
48
49disable-mnt
50private-bin lifeograph
51private-cache
52private-dev
53private-etc alternatives,dconf,fonts,gtk-3.0,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,pango,X11
54private-tmp
55
56dbus-user filter
57dbus-user.talk ca.desrt.dconf
58dbus-system none
diff --git a/etc/profile-m-z/io.github.lainsce.Notejot.profile b/etc/profile-m-z/io.github.lainsce.Notejot.profile
new file mode 100644
index 000000000..a8029db72
--- /dev/null
+++ b/etc/profile-m-z/io.github.lainsce.Notejot.profile
@@ -0,0 +1,61 @@
1# Firejail profile for notejot
2# Description: Jot your ideas
3# This file is overwritten after every install/update
4# Persistent local customizations
5include io.github.lainsce.Notejot.local
6# Persistent global definitions
7include globals.local
8
9nodeny ${HOME}/.cache/io.github.lainsce.Notejot
10nodeny ${HOME}/.local/share/io.github.lainsce.Notejot
11
12include disable-common.inc
13include disable-devel.inc
14include disable-exec.inc
15include disable-interpreters.inc
16include disable-passwdmgr.inc
17include disable-programs.inc
18include disable-shell.inc
19include disable-xdg.inc
20
21mkdir ${HOME}/.cache/io.github.lainsce.Notejot
22mkdir ${HOME}/.local/share/io.github.lainsce.Notejot
23allow ${HOME}/.cache/io.github.lainsce.Notejot
24allow ${HOME}/.local/share/io.github.lainsce.Notejot
25allow /usr/libexec/webkit2gtk-4.0
26include whitelist-common.inc
27include whitelist-runuser-common.inc
28include whitelist-usr-share-common.inc
29include whitelist-var-common.inc
30
31apparmor
32caps.drop all
33machine-id
34net none
35no3d
36nodvd
37nogroups
38noinput
39nonewprivs
40noroot
41nosound
42notv
43nou2f
44novideo
45protocol unix
46seccomp
47seccomp.block-secondary
48shell none
49tracelog
50
51disable-mnt
52private-bin io.github.lainsce.Notejot
53private-cache
54private-dev
55private-etc alternatives,dconf,fonts,gtk-3.0,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,pango,X11
56private-tmp
57
58dbus-user filter
59dbus-user.own io.github.lainsce.Notejot
60dbus-user.talk ca.desrt.dconf
61dbus-system none
diff --git a/etc/profile-m-z/rednotebook.profile b/etc/profile-m-z/rednotebook.profile
new file mode 100644
index 000000000..67281c518
--- /dev/null
+++ b/etc/profile-m-z/rednotebook.profile
@@ -0,0 +1,67 @@
1# Firejail profile for rednotebook
2# Description: Daily journal with calendar, templates and keyword searching
3# This file is overwritten after every install/update
4# Persistent local customizations
5include rednotebook.local
6# Persistent global definitions
7include globals.local
8
9nodeny ${HOME}/.cache/rednotebook
10nodeny ${HOME}/.rednotebook
11
12# Allow python (blacklisted by disable-interpreters.inc)
13include allow-python3.inc
14
15include disable-common.inc
16include disable-devel.inc
17include disable-exec.inc
18include disable-interpreters.inc
19include disable-passwdmgr.inc
20include disable-programs.inc
21include disable-shell.inc
22
23mkdir ${HOME}/.cache/rednotebook
24mkdir ${HOME}/.rednotebook
25allow ${HOME}/.cache/rednotebook
26allow ${HOME}/.rednotebook
27allow ${DESKTOP}
28allow ${DOCUMENTS}
29allow ${DOWNLOADS}
30allow ${MUSIC}
31allow ${PICTURES}
32allow ${VIDEOS}
33allow /usr/libexec/webkit2gtk-4.0
34include whitelist-common.inc
35include whitelist-runuser-common.inc
36include whitelist-usr-share-common.inc
37include whitelist-var-common.inc
38
39apparmor
40caps.drop all
41machine-id
42net none
43no3d
44nodvd
45nogroups
46noinput
47nonewprivs
48noroot
49nosound
50notv
51nou2f
52novideo
53protocol unix
54seccomp
55seccomp.block-secondary
56shell none
57tracelog
58
59disable-mnt
60private-bin python3*,rednotebook
61private-cache
62private-dev
63private-etc alternatives,fonts,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,pango,X11
64private-tmp
65
66dbus-user none
67dbus-system none
diff --git a/etc/profile-m-z/zim.profile b/etc/profile-m-z/zim.profile
new file mode 100644
index 000000000..5ae9cddb3
--- /dev/null
+++ b/etc/profile-m-z/zim.profile
@@ -0,0 +1,72 @@
1# Firejail profile for Zim
2# Description: Desktop wiki & notekeeper
3# This file is overwritten after every install/update
4# Persistent local customizations
5include zim.local
6# Persistent global definitions
7include globals.local
8
9nodeny ${HOME}/.cache/zim
10nodeny ${HOME}/.config/zim
11
12# Allow python (blacklisted by disable-interpreters.inc)
13include allow-python2.inc
14include allow-python3.inc
15
16deny /usr/libexec
17
18include disable-common.inc
19include disable-devel.inc
20include disable-exec.inc
21include disable-interpreters.inc
22include disable-passwdmgr.inc
23include disable-programs.inc
24include disable-shell.inc
25
26mkdir ${HOME}/.cache/zim
27mkdir ${HOME}/.config/zim
28mkdir ${HOME}/Notebooks
29allow ${HOME}/.cache/zim
30allow ${HOME}/.config/zim
31allow ${HOME}/Notebooks
32allow ${DESKTOP}
33allow ${DOCUMENTS}
34allow ${DOWNLOADS}
35allow ${MUSIC}
36allow ${PICTURES}
37allow ${VIDEOS}
38allow /usr/share/zim
39include whitelist-common.inc
40include whitelist-runuser-common.inc
41include whitelist-usr-share-common.inc
42include whitelist-var-common.inc
43
44apparmor
45caps.drop all
46machine-id
47net none
48no3d
49nodvd
50nogroups
51noinput
52nonewprivs
53noroot
54nosound
55notv
56nou2f
57novideo
58protocol unix
59seccomp
60seccomp.block-secondary
61shell none
62tracelog
63
64disable-mnt
65private-bin python*,zim
66private-cache
67private-dev
68private-etc alternatives,dconf,fonts,gconf,gtk-2.0,gtk-3.0,ld.so.cache,ld.so.conf,ld.so.conf.d,ld.so.preload,pango,X11
69private-tmp
70
71dbus-user none
72dbus-system none
diff --git a/src/firecfg/firecfg.config b/src/firecfg/firecfg.config
index 7052f7509..3b0ad0aed 100644
--- a/src/firecfg/firecfg.config
+++ b/src/firecfg/firecfg.config
@@ -45,8 +45,8 @@ amule
45amuled 45amuled
46android-studio 46android-studio
47anydesk 47anydesk
48apostrophe
49apktool 48apktool
49apostrophe
50# ar - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095) 50# ar - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095)
51arch-audit 51arch-audit
52archaudit-report 52archaudit-report
@@ -143,8 +143,8 @@ clawsker
143clementine 143clementine
144clion 144clion
145clion-eap 145clion-eap
146clipit
147clipgrab 146clipgrab
147clipit
148cliqz 148cliqz
149clocks 149clocks
150cmus 150cmus
@@ -168,6 +168,7 @@ crow
168cryptocat 168cryptocat
169cvlc 169cvlc
170cyberfox 170cyberfox
171d-feet
171darktable 172darktable
172dconf-editor 173dconf-editor
173ddgr 174ddgr
@@ -198,13 +199,12 @@ dragon
198drawio 199drawio
199drill 200drill
200dropbox 201dropbox
201d-feet
202easystroke 202easystroke
203ebook-viewer
204ebook-convert 203ebook-convert
205ebook-edit 204ebook-edit
206ebook-meta 205ebook-meta
207ebook-polish 206ebook-polish
207ebook-viewer
208electron-mail 208electron-mail
209electrum 209electrum
210element-desktop 210element-desktop
@@ -295,8 +295,8 @@ gimp-2.10
295gimp-2.8 295gimp-2.8
296gist 296gist
297gist-paste 297gist-paste
298gitg
299git-cola 298git-cola
299gitg
300github-desktop 300github-desktop
301gitter 301gitter
302# gjs -- https://github.com/netblue30/firejail/issues/3333#issuecomment-612601102 302# gjs -- https://github.com/netblue30/firejail/issues/3333#issuecomment-612601102
@@ -387,14 +387,15 @@ icecat
387icedove 387icedove
388iceweasel 388iceweasel
389idea 389idea
390ideaIC
391idea.sh 390idea.sh
391ideaIC
392imagej 392imagej
393img2txt 393img2txt
394impressive 394impressive
395inkscape 395inkscape
396inkview 396inkview
397inox 397inox
398io.github.lainsce.Notejot
398ipcalc 399ipcalc
399ipcalc-ng 400ipcalc-ng
400iridium 401iridium
@@ -453,6 +454,7 @@ librecad
453libreoffice 454libreoffice
454librewolf 455librewolf
455librewolf-nightly 456librewolf-nightly
457lifeograph
456liferea 458liferea
457lightsoff 459lightsoff
458lincity-ng 460lincity-ng
@@ -508,6 +510,7 @@ mendeleydesktop
508menulibre 510menulibre
509meteo-qt 511meteo-qt
510microsoft-edge 512microsoft-edge
513microsoft-edge-beta
511microsoft-edge-dev 514microsoft-edge-dev
512midori 515midori
513min 516min
@@ -524,7 +527,6 @@ mp3splt-gtk
524mp3wrap 527mp3wrap
525mpDris2 528mpDris2
526mpg123 529mpg123
527mpg123.bin
528mpg123-alsa 530mpg123-alsa
529mpg123-id3dump 531mpg123-id3dump
530mpg123-jack 532mpg123-jack
@@ -534,6 +536,7 @@ mpg123-oss
534mpg123-portaudio 536mpg123-portaudio
535mpg123-pulse 537mpg123-pulse
536mpg123-strip 538mpg123-strip
539mpg123.bin
537mplayer 540mplayer
538mpsyt 541mpsyt
539mpv 542mpv
@@ -675,6 +678,7 @@ qupzilla
675qutebrowser 678qutebrowser
676rambox 679rambox
677redeclipse 680redeclipse
681rednotebook
678redshift 682redshift
679regextester 683regextester
680remmina 684remmina
@@ -735,8 +739,8 @@ steam
735steam-native 739steam-native
736steam-runtime 740steam-runtime
737stellarium 741stellarium
738strawberry
739straw-viewer 742straw-viewer
743strawberry
740strings 744strings
741studio.sh 745studio.sh
742subdownloader 746subdownloader
@@ -863,10 +867,10 @@ wire-desktop
863wireshark 867wireshark
864wireshark-gtk 868wireshark-gtk
865wireshark-qt 869wireshark-qt
870wordwarvi
866wpp 871wpp
867wps 872wps
868wpspdf 873wpspdf
869wordwarvi
870x2goclient 874x2goclient
871xbill 875xbill
872xcalc 876xcalc
@@ -908,6 +912,7 @@ zaproxy
908zart 912zart
909zathura 913zathura
910zeal 914zeal
915zim
911zoom 916zoom
912# zpaq - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095) 917# zpaq - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095)
913# zstd - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095) 918# zstd - disable until we fix CLI archivers for makepkg on Arch (see discussion in #3095)
diff --git a/src/firejail/main.c b/src/firejail/main.c
index f64994e02..655e6e9d0 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -985,24 +985,16 @@ int main(int argc, char **argv, char **envp) {
985 int arg_caps_cmdline = 0; // caps requested on command line (used to break out of --chroot) 985 int arg_caps_cmdline = 0; // caps requested on command line (used to break out of --chroot)
986 char **ptr; 986 char **ptr;
987 987
988#ifndef HAVE_SUID
989 if (geteuid() != 0) {
990 fprintf(stderr, "Error: Firejail needs to be SUID.\n");
991 fprintf(stderr, "Assuming firejail is installed in /usr/bin, execute the following command as root:\n");
992 fprintf(stderr, " chmod u+s /usr/bin/firejail\n");
993 }
994#endif
995
996 // sanitize the umask 988 // sanitize the umask
997 orig_umask = umask(022); 989 orig_umask = umask(022);
998 990
999 // check standard streams before printing anything
1000 fix_std_streams();
1001
1002 // drop permissions by default and rise them when required 991 // drop permissions by default and rise them when required
1003 EUID_INIT(); 992 EUID_INIT();
1004 EUID_USER(); 993 EUID_USER();
1005 994
995 // check standard streams before opening any file
996 fix_std_streams();
997
1006 // argument count should be larger than 0 998 // argument count should be larger than 0
1007 if (argc == 0 || !argv || strlen(argv[0]) == 0) { 999 if (argc == 0 || !argv || strlen(argv[0]) == 0) {
1008 fprintf(stderr, "Error: argv is invalid\n"); 1000 fprintf(stderr, "Error: argv is invalid\n");
@@ -1012,16 +1004,6 @@ int main(int argc, char **argv, char **envp) {
1012 exit(1); 1004 exit(1);
1013 } 1005 }
1014 1006
1015 // Stash environment variables
1016 for (i = 0, ptr = envp; ptr && *ptr && i < MAX_ENVS; i++, ptr++)
1017 env_store(*ptr, SETENV);
1018
1019 // sanity check for environment variables
1020 if (i >= MAX_ENVS) {
1021 fprintf(stderr, "Error: too many environment variables\n");
1022 exit(1);
1023 }
1024
1025 // sanity check for arguments 1007 // sanity check for arguments
1026 for (i = 0; i < argc; i++) { 1008 for (i = 0; i < argc; i++) {
1027 if (*argv[i] == 0) { 1009 if (*argv[i] == 0) {
@@ -1034,82 +1016,29 @@ int main(int argc, char **argv, char **envp) {
1034 } 1016 }
1035 } 1017 }
1036 1018
1019 // Stash environment variables
1020 for (i = 0, ptr = envp; ptr && *ptr && i < MAX_ENVS; i++, ptr++)
1021 env_store(*ptr, SETENV);
1022
1023 // sanity check for environment variables
1024 if (i >= MAX_ENVS) {
1025 fprintf(stderr, "Error: too many environment variables\n");
1026 exit(1);
1027 }
1028
1037 // Reapply a minimal set of environment variables 1029 // Reapply a minimal set of environment variables
1038 env_apply_whitelist(); 1030 env_apply_whitelist();
1039 1031
1040 // check if the user is allowed to use firejail 1032 // process --quiet
1041 init_cfg(argc, argv);
1042
1043 // get starting timestamp, process --quiet
1044 timetrace_start();
1045 const char *env_quiet = env_get("FIREJAIL_QUIET"); 1033 const char *env_quiet = env_get("FIREJAIL_QUIET");
1046 if (check_arg(argc, argv, "--quiet", 1) || (env_quiet && strcmp(env_quiet, "yes") == 0)) 1034 if (check_arg(argc, argv, "--quiet", 1) || (env_quiet && strcmp(env_quiet, "yes") == 0))
1047 arg_quiet = 1; 1035 arg_quiet = 1;
1048 1036
1049 // cleanup at exit 1037 // check if the user is allowed to use firejail
1050 EUID_ROOT(); 1038 init_cfg(argc, argv);
1051 atexit(clear_atexit);
1052
1053 // build /run/firejail directory structure
1054 preproc_build_firejail_dir();
1055 const char *container_name = env_get("container");
1056 if (!container_name || strcmp(container_name, "firejail")) {
1057 lockfd_directory = open(RUN_DIRECTORY_LOCK_FILE, O_WRONLY | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR);
1058 if (lockfd_directory != -1) {
1059 int rv = fchown(lockfd_directory, 0, 0);
1060 (void) rv;
1061 flock(lockfd_directory, LOCK_EX);
1062 }
1063 preproc_clean_run();
1064 flock(lockfd_directory, LOCK_UN);
1065 close(lockfd_directory);
1066 }
1067 EUID_USER();
1068
1069 // --ip=dhcp - we need access to /sbin and /usr/sbin directories in order to run ISC DHCP client (dhclient)
1070 // these paths are disabled in disable-common.inc
1071 if ((i = check_arg(argc, argv, "--ip", 0)) != 0) {
1072 if (strncmp(argv[i] + 4, "=dhcp", 5) == 0) {
1073 profile_add("noblacklist /sbin");
1074 profile_add("noblacklist /usr/sbin");
1075 }
1076 }
1077
1078 // for appimages we need to remove "include disable-shell.inc from the profile
1079 // a --profile command can show up before --appimage
1080 if (check_arg(argc, argv, "--appimage", 1))
1081 arg_appimage = 1;
1082
1083 // process allow-debuggers
1084 if (check_arg(argc, argv, "--allow-debuggers", 1)) {
1085 // check kernel version
1086 struct utsname u;
1087 int rv = uname(&u);
1088 if (rv != 0)
1089 errExit("uname");
1090 int major;
1091 int minor;
1092 if (2 != sscanf(u.release, "%d.%d", &major, &minor)) {
1093 fprintf(stderr, "Error: cannot extract Linux kernel version: %s\n", u.version);
1094 exit(1);
1095 }
1096 if (major < 4 || (major == 4 && minor < 8)) {
1097 fprintf(stderr, "Error: --allow-debuggers is disabled on Linux kernels prior to 4.8. "
1098 "A bug in ptrace call allows a full bypass of the seccomp filter. "
1099 "Your current kernel version is %d.%d.\n", major, minor);
1100 exit(1);
1101 }
1102
1103 arg_allow_debuggers = 1;
1104 char *cmd = strdup("noblacklist ${PATH}/strace");
1105 if (!cmd)
1106 errExit("strdup");
1107 profile_add(cmd);
1108 }
1109 1039
1110 // profile builder 1040 // get starting timestamp
1111 if (check_arg(argc, argv, "--build", 0)) // supports both --build and --build=filename 1041 timetrace_start();
1112 run_builder(argc, argv); // this function will not return
1113 1042
1114 // check argv[0] symlink wrapper if this is not a login shell 1043 // check argv[0] symlink wrapper if this is not a login shell
1115 if (*argv[0] != '-') 1044 if (*argv[0] != '-')
@@ -1134,15 +1063,40 @@ int main(int argc, char **argv, char **envp) {
1134 __builtin_unreachable(); 1063 __builtin_unreachable();
1135 } 1064 }
1136 } 1065 }
1137 EUID_ASSERT();
1138 1066
1067 // profile builder
1068 if (check_arg(argc, argv, "--build", 0)) // supports both --build and --build=filename
1069 run_builder(argc, argv); // this function will not return
1139 1070
1140 // check firejail directories
1141 EUID_ROOT(); 1071 EUID_ROOT();
1142 delete_run_files(sandbox_pid); 1072#ifndef HAVE_SUID
1073 if (geteuid() != 0) {
1074 fprintf(stderr, "Error: Firejail needs to be SUID.\n");
1075 fprintf(stderr, "Assuming firejail is installed in /usr/bin, execute the following command as root:\n");
1076 fprintf(stderr, " chmod u+s /usr/bin/firejail\n");
1077 }
1078#endif
1079
1080 // build /run/firejail directory structure
1081 preproc_build_firejail_dir();
1082 const char *container_name = env_get("container");
1083 if (!container_name || strcmp(container_name, "firejail")) {
1084 lockfd_directory = open(RUN_DIRECTORY_LOCK_FILE, O_WRONLY | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR);
1085 if (lockfd_directory != -1) {
1086 int rv = fchown(lockfd_directory, 0, 0);
1087 (void) rv;
1088 flock(lockfd_directory, LOCK_EX);
1089 }
1090 preproc_clean_run();
1091 flock(lockfd_directory, LOCK_UN);
1092 close(lockfd_directory);
1093 }
1094
1095 delete_run_files(getpid());
1096 atexit(clear_atexit);
1143 EUID_USER(); 1097 EUID_USER();
1144 1098
1145 //check if the parent is sshd daemon 1099 // check if the parent is sshd daemon
1146 int parent_sshd = 0; 1100 int parent_sshd = 0;
1147 { 1101 {
1148 pid_t ppid = getppid(); 1102 pid_t ppid = getppid();
@@ -1199,7 +1153,8 @@ int main(int argc, char **argv, char **envp) {
1199 } 1153 }
1200 EUID_ASSERT(); 1154 EUID_ASSERT();
1201 1155
1202 // is this a login shell, or a command passed by sshd, insert command line options from /etc/firejail/login.users 1156 // is this a login shell, or a command passed by sshd,
1157 // insert command line options from /etc/firejail/login.users
1203 if (*argv[0] == '-' || parent_sshd) { 1158 if (*argv[0] == '-' || parent_sshd) {
1204 if (argc == 1) 1159 if (argc == 1)
1205 login_shell = 1; 1160 login_shell = 1;
@@ -1251,6 +1206,47 @@ int main(int argc, char **argv, char **envp) {
1251#endif 1206#endif
1252 EUID_ASSERT(); 1207 EUID_ASSERT();
1253 1208
1209 // --ip=dhcp - we need access to /sbin and /usr/sbin directories in order to run ISC DHCP client (dhclient)
1210 // these paths are disabled in disable-common.inc
1211 if ((i = check_arg(argc, argv, "--ip", 0)) != 0) {
1212 if (strncmp(argv[i] + 4, "=dhcp", 5) == 0) {
1213 profile_add("noblacklist /sbin");
1214 profile_add("noblacklist /usr/sbin");
1215 }
1216 }
1217
1218 // process allow-debuggers
1219 if (check_arg(argc, argv, "--allow-debuggers", 1)) {
1220 // check kernel version
1221 struct utsname u;
1222 int rv = uname(&u);
1223 if (rv != 0)
1224 errExit("uname");
1225 int major;
1226 int minor;
1227 if (2 != sscanf(u.release, "%d.%d", &major, &minor)) {
1228 fprintf(stderr, "Error: cannot extract Linux kernel version: %s\n", u.version);
1229 exit(1);
1230 }
1231 if (major < 4 || (major == 4 && minor < 8)) {
1232 fprintf(stderr, "Error: --allow-debuggers is disabled on Linux kernels prior to 4.8. "
1233 "A bug in ptrace call allows a full bypass of the seccomp filter. "
1234 "Your current kernel version is %d.%d.\n", major, minor);
1235 exit(1);
1236 }
1237
1238 arg_allow_debuggers = 1;
1239 char *cmd = strdup("noblacklist ${PATH}/strace");
1240 if (!cmd)
1241 errExit("strdup");
1242 profile_add(cmd);
1243 }
1244
1245 // for appimages we need to remove "include disable-shell.inc from the profile
1246 // a --profile command can show up before --appimage
1247 if (check_arg(argc, argv, "--appimage", 1))
1248 arg_appimage = 1;
1249
1254 // check for force-nonewprivs in /etc/firejail/firejail.config file 1250 // check for force-nonewprivs in /etc/firejail/firejail.config file
1255 if (checkcfg(CFG_FORCE_NONEWPRIVS)) 1251 if (checkcfg(CFG_FORCE_NONEWPRIVS))
1256 arg_nonewprivs = 1; 1252 arg_nonewprivs = 1;
@@ -2680,8 +2676,9 @@ int main(int argc, char **argv, char **envp) {
2680 //************************************* 2676 //*************************************
2681 else if (strncmp(argv[i], "--timeout=", 10) == 0) 2677 else if (strncmp(argv[i], "--timeout=", 10) == 0)
2682 cfg.timeout = extract_timeout(argv[i] + 10); 2678 cfg.timeout = extract_timeout(argv[i] + 10);
2683 else if (strcmp(argv[i], "--appimage") == 0) 2679 else if (strcmp(argv[i], "--appimage") == 0) {
2684 arg_appimage = 1; 2680 // already handled
2681 }
2685 else if (strcmp(argv[i], "--shell=none") == 0) { 2682 else if (strcmp(argv[i], "--shell=none") == 0) {
2686 arg_shell_none = 1; 2683 arg_shell_none = 1;
2687 if (cfg.shell) { 2684 if (cfg.shell) {
diff --git a/src/firejail/no_sandbox.c b/src/firejail/no_sandbox.c
index 665bef73d..0e5562d90 100644
--- a/src/firejail/no_sandbox.c
+++ b/src/firejail/no_sandbox.c
@@ -49,6 +49,7 @@ int check_namespace_virt(void) {
49 // check PID 1 container environment variable 49 // check PID 1 container environment variable
50 EUID_ROOT(); 50 EUID_ROOT();
51 FILE *fp = fopen("/proc/1/environ", "re"); 51 FILE *fp = fopen("/proc/1/environ", "re");
52 EUID_USER();
52 if (fp) { 53 if (fp) {
53 int c = 0; 54 int c = 0;
54 while (c != EOF) { 55 while (c != EOF) {
@@ -69,7 +70,6 @@ int check_namespace_virt(void) {
69 // found it 70 // found it
70 if (is_container(buf + 10)) { 71 if (is_container(buf + 10)) {
71 fclose(fp); 72 fclose(fp);
72 EUID_USER();
73 return 1; 73 return 1;
74 } 74 }
75 } 75 }
@@ -79,7 +79,6 @@ int check_namespace_virt(void) {
79 fclose(fp); 79 fclose(fp);
80 } 80 }
81 81
82 EUID_USER();
83 return 0; 82 return 0;
84} 83}
85 84
diff --git a/src/firejail/output.c b/src/firejail/output.c
index 835dff2db..ce10ab157 100644
--- a/src/firejail/output.c
+++ b/src/firejail/output.c
@@ -50,13 +50,21 @@ void check_output(int argc, char **argv) {
50 if (!outindex) 50 if (!outindex)
51 return; 51 return;
52 52
53
54 // check filename
55 drop_privs(0); 53 drop_privs(0);
56 char *outfile = argv[outindex]; 54 char *outfile = argv[outindex];
57 outfile += (enable_stderr)? 16:9; 55 outfile += (enable_stderr)? 16:9;
56
57 // check filename
58 invalid_filename(outfile, 0); // no globbing 58 invalid_filename(outfile, 0); // no globbing
59 59
60 // expand user home directory
61 if (outfile[0] == '~') {
62 char *full;
63 if (asprintf(&full, "%s%s", cfg.homedir, outfile + 1) == -1)
64 errExit("asprintf");
65 outfile = full;
66 }
67
60 // do not accept directories, links, and files with ".." 68 // do not accept directories, links, and files with ".."
61 if (strstr(outfile, "..") || is_link(outfile) || is_dir(outfile)) { 69 if (strstr(outfile, "..") || is_link(outfile) || is_dir(outfile)) {
62 fprintf(stderr, "Error: invalid output file. Links, directories and files with \"..\" are not allowed.\n"); 70 fprintf(stderr, "Error: invalid output file. Links, directories and files with \"..\" are not allowed.\n");
diff --git a/src/firejail/util.c b/src/firejail/util.c
index de31ebdd6..094a68c60 100644
--- a/src/firejail/util.c
+++ b/src/firejail/util.c
@@ -1513,8 +1513,7 @@ void check_homedir(const char *dir) {
1513 exit(1); 1513 exit(1);
1514 } 1514 }
1515 // symlinks are rejected in many places 1515 // symlinks are rejected in many places
1516 if (has_link(dir)) { 1516 if (has_link(dir))
1517 fprintf(stderr, "No full support for symbolic links in path of user directory.\n" 1517 fmessage("No full support for symbolic links in path of user directory.\n"
1518 "Please provide resolved path in password database (/etc/passwd).\n\n"); 1518 "Please provide resolved path in password database (/etc/passwd).\n\n");
1519 }
1520} 1519}
diff --git a/test/profiles/profile_syntax.exp b/test/profiles/profile_syntax.exp
index 258089a39..a2cccb0d4 100755
--- a/test/profiles/profile_syntax.exp
+++ b/test/profiles/profile_syntax.exp
@@ -22,7 +22,7 @@ expect {
22} 22}
23 23
24sleep 1 24sleep 1
25send -- "ls -l /etc/shadow\r" 25send -- "ls -l /dev/console\r"
26expect { 26expect {
27 timeout {puts "TESTING ERROR 3\n";exit} 27 timeout {puts "TESTING ERROR 3\n";exit}
28 "root root" 28 "root root"
diff --git a/test/profiles/test.profile b/test/profiles/test.profile
index 26d6de849..27cb99606 100644
--- a/test/profiles/test.profile
+++ b/test/profiles/test.profile
@@ -1,5 +1,5 @@
1blacklist /sbin/iptables 1blacklist /sbin/iptables
2blacklist /etc/shadow 2blacklist /dev/console
3blacklist /bin/rmdir 3blacklist /bin/rmdir
4blacklist ${PATH}/umount 4blacklist ${PATH}/umount
5blacklist ${PATH}/mount 5blacklist ${PATH}/mount