aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Reiner Herrmann <reiner@reiner-h.de>2016-07-30 17:58:25 +0200
committerLibravatar Reiner Herrmann <reiner@reiner-h.de>2016-07-30 17:58:45 +0200
commit0657c20377d6f8d80f143e9c6a336601c8bbd2e2 (patch)
tree9a64c53de121fb14f64cc0db850fd8397883776b
parentfixes (diff)
downloadfirejail-0657c20377d6f8d80f143e9c6a336601c8bbd2e2.tar.gz
firejail-0657c20377d6f8d80f143e9c6a336601c8bbd2e2.tar.zst
firejail-0657c20377d6f8d80f143e9c6a336601c8bbd2e2.zip
Allow recursive mkdir (Closes #305)
-rw-r--r--etc/0ad.profile4
-rw-r--r--etc/abrowser.profile2
-rw-r--r--etc/aweather.profile1
-rw-r--r--etc/brave.profile1
-rw-r--r--etc/cherrytree.profile2
-rw-r--r--etc/chromium.profile2
-rw-r--r--etc/cyberfox.profile1
-rw-r--r--etc/dropbox.profile1
-rw-r--r--etc/epiphany.profile4
-rw-r--r--etc/firefox.profile2
-rw-r--r--etc/flashpeak-slimjet.profile2
-rw-r--r--etc/franz.profile2
-rw-r--r--etc/google-chrome-beta.profile2
-rw-r--r--etc/google-chrome-unstable.profile2
-rw-r--r--etc/google-chrome.profile2
-rw-r--r--etc/gpredict.profile1
-rw-r--r--etc/hexchat.profile1
-rw-r--r--etc/icedove.profile1
-rw-r--r--etc/mupen64plus.profile3
-rw-r--r--etc/netsurf.profile2
-rw-r--r--etc/opera-beta.profile2
-rw-r--r--etc/opera.profile2
-rw-r--r--etc/palemoon.profile2
-rw-r--r--etc/polari.profile4
-rw-r--r--etc/psi-plus.profile4
-rw-r--r--etc/quiterss.profile3
-rw-r--r--etc/qutebrowser.profile1
-rw-r--r--etc/seamonkey.profile3
-rw-r--r--etc/spotify.profile4
-rw-r--r--etc/stellarium.profile1
-rw-r--r--etc/thunderbird.profile1
-rw-r--r--etc/uget-gtk.profile1
-rw-r--r--etc/vivaldi.profile2
-rw-r--r--etc/wesnoth.profile4
-rw-r--r--etc/whitelist-common.inc1
-rw-r--r--src/firejail/fs_mkdir.c39
-rw-r--r--src/man/firejail-profile.txt8
-rwxr-xr-xtest/fs/fs.sh3
-rwxr-xr-xtest/fs/mkdir.exp20
-rw-r--r--test/fs/mkdir.profile2
40 files changed, 60 insertions, 85 deletions
diff --git a/etc/0ad.profile b/etc/0ad.profile
index 11fb45463..217cdeee0 100644
--- a/etc/0ad.profile
+++ b/etc/0ad.profile
@@ -8,16 +8,12 @@ include /etc/firejail/disable-passwdmgr.inc
8include /etc/firejail/disable-programs.inc 8include /etc/firejail/disable-programs.inc
9 9
10# Whitelists 10# Whitelists
11mkdir ~/.cache
12mkdir ~/.cache/0ad 11mkdir ~/.cache/0ad
13whitelist ~/.cache/0ad 12whitelist ~/.cache/0ad
14 13
15mkdir ~/.config
16mkdir ~/.config/0ad 14mkdir ~/.config/0ad
17whitelist ~/.config/0ad 15whitelist ~/.config/0ad
18 16
19mkdir ~/.local
20mkdir ~/.local/share
21mkdir ~/.local/share/0ad 17mkdir ~/.local/share/0ad
22whitelist ~/.local/share/0ad 18whitelist ~/.local/share/0ad
23 19
diff --git a/etc/abrowser.profile b/etc/abrowser.profile
index 65247e7d3..4aa18aa90 100644
--- a/etc/abrowser.profile
+++ b/etc/abrowser.profile
@@ -17,8 +17,6 @@ tracelog
17whitelist ${DOWNLOADS} 17whitelist ${DOWNLOADS}
18mkdir ~/.mozilla 18mkdir ~/.mozilla
19whitelist ~/.mozilla 19whitelist ~/.mozilla
20mkdir ~/.cache
21mkdir ~/.cache/mozilla
22mkdir ~/.cache/mozilla/abrowser 20mkdir ~/.cache/mozilla/abrowser
23whitelist ~/.cache/mozilla/abrowser 21whitelist ~/.cache/mozilla/abrowser
24whitelist ~/dwhelper 22whitelist ~/dwhelper
diff --git a/etc/aweather.profile b/etc/aweather.profile
index d617fb701..da93e8ba3 100644
--- a/etc/aweather.profile
+++ b/etc/aweather.profile
@@ -6,7 +6,6 @@ include /etc/firejail/disable-passwdmgr.inc
6include /etc/firejail/disable-programs.inc 6include /etc/firejail/disable-programs.inc
7 7
8# Whitelist 8# Whitelist
9mkdir ~/.config
10mkdir ~/.config/aweather 9mkdir ~/.config/aweather
11whitelist ~/.config/aweather 10whitelist ~/.config/aweather
12 11
diff --git a/etc/brave.profile b/etc/brave.profile
index 4c42e9faa..4fc3a5bb0 100644
--- a/etc/brave.profile
+++ b/etc/brave.profile
@@ -14,6 +14,5 @@ seccomp
14 14
15whitelist ${DOWNLOADS} 15whitelist ${DOWNLOADS}
16 16
17mkdir ~/.config
18mkdir ~/.config/brave 17mkdir ~/.config/brave
19whitelist ~/.config/brave 18whitelist ~/.config/brave
diff --git a/etc/cherrytree.profile b/etc/cherrytree.profile
index 7b6238d98..76ee70679 100644
--- a/etc/cherrytree.profile
+++ b/etc/cherrytree.profile
@@ -7,10 +7,8 @@ include /etc/firejail/disable-devel.inc
7include /etc/firejail/disable-passwdmgr.inc 7include /etc/firejail/disable-passwdmgr.inc
8 8
9whitelist ${HOME}/cherrytree 9whitelist ${HOME}/cherrytree
10mkdir ~/.config
11mkdir ~/.config/cherrytree 10mkdir ~/.config/cherrytree
12whitelist ${HOME}/.config/cherrytree/ 11whitelist ${HOME}/.config/cherrytree/
13mkdir ~/.local
14mkdir ~/.local/share 12mkdir ~/.local/share
15whitelist ${HOME}/.local/share/ 13whitelist ${HOME}/.local/share/
16 14
diff --git a/etc/chromium.profile b/etc/chromium.profile
index 7cf2853ca..0d383aebf 100644
--- a/etc/chromium.profile
+++ b/etc/chromium.profile
@@ -11,10 +11,8 @@ include /etc/firejail/disable-programs.inc
11netfilter 11netfilter
12 12
13whitelist ${DOWNLOADS} 13whitelist ${DOWNLOADS}
14mkdir ~/.config
15mkdir ~/.config/chromium 14mkdir ~/.config/chromium
16whitelist ~/.config/chromium 15whitelist ~/.config/chromium
17mkdir ~/.cache
18mkdir ~/.cache/chromium 16mkdir ~/.cache/chromium
19whitelist ~/.cache/chromium 17whitelist ~/.cache/chromium
20mkdir ~/.pki 18mkdir ~/.pki
diff --git a/etc/cyberfox.profile b/etc/cyberfox.profile
index afa77d1d4..ae487fa3c 100644
--- a/etc/cyberfox.profile
+++ b/etc/cyberfox.profile
@@ -17,7 +17,6 @@ tracelog
17whitelist ${DOWNLOADS} 17whitelist ${DOWNLOADS}
18mkdir ~/.8pecxstudios 18mkdir ~/.8pecxstudios
19whitelist ~/.8pecxstudios 19whitelist ~/.8pecxstudios
20mkdir ~/.cache
21mkdir ~/.cache/8pecxstudios 20mkdir ~/.cache/8pecxstudios
22whitelist ~/.cache/8pecxstudios 21whitelist ~/.cache/8pecxstudios
23whitelist ~/dwhelper 22whitelist ~/dwhelper
diff --git a/etc/dropbox.profile b/etc/dropbox.profile
index 71e019f8c..40efd62b2 100644
--- a/etc/dropbox.profile
+++ b/etc/dropbox.profile
@@ -17,6 +17,5 @@ whitelist ~/.dropbox
17mkdir ~/.dropbox-dist 17mkdir ~/.dropbox-dist
18whitelist ~/.dropbox-dist 18whitelist ~/.dropbox-dist
19 19
20mkdir ~/.config/autostart
21mkfile ~/.config/autostart/dropbox.desktop 20mkfile ~/.config/autostart/dropbox.desktop
22whitelist ~/.config/autostart/dropbox.desktop 21whitelist ~/.config/autostart/dropbox.desktop
diff --git a/etc/epiphany.profile b/etc/epiphany.profile
index 57191429a..0e898f02b 100644
--- a/etc/epiphany.profile
+++ b/etc/epiphany.profile
@@ -8,14 +8,10 @@ include /etc/firejail/disable-programs.inc
8include /etc/firejail/disable-devel.inc 8include /etc/firejail/disable-devel.inc
9 9
10whitelist ${DOWNLOADS} 10whitelist ${DOWNLOADS}
11mkdir ${HOME}/.local
12mkdir ${HOME}/.local/share
13mkdir ${HOME}/.local/share/epiphany 11mkdir ${HOME}/.local/share/epiphany
14whitelist ${HOME}/.local/share/epiphany 12whitelist ${HOME}/.local/share/epiphany
15mkdir ${HOME}/.config
16mkdir ${HOME}/.config/epiphany 13mkdir ${HOME}/.config/epiphany
17whitelist ${HOME}/.config/epiphany 14whitelist ${HOME}/.config/epiphany
18mkdir ${HOME}/.cache
19mkdir ${HOME}/.cache/epiphany 15mkdir ${HOME}/.cache/epiphany
20whitelist ${HOME}/.cache/epiphany 16whitelist ${HOME}/.cache/epiphany
21include /etc/firejail/whitelist-common.inc 17include /etc/firejail/whitelist-common.inc
diff --git a/etc/firefox.profile b/etc/firefox.profile
index 2cc4d3cd8..170d0fe10 100644
--- a/etc/firefox.profile
+++ b/etc/firefox.profile
@@ -17,8 +17,6 @@ tracelog
17whitelist ${DOWNLOADS} 17whitelist ${DOWNLOADS}
18mkdir ~/.mozilla 18mkdir ~/.mozilla
19whitelist ~/.mozilla 19whitelist ~/.mozilla
20mkdir ~/.cache
21mkdir ~/.cache/mozilla
22mkdir ~/.cache/mozilla/firefox 20mkdir ~/.cache/mozilla/firefox
23whitelist ~/.cache/mozilla/firefox 21whitelist ~/.cache/mozilla/firefox
24whitelist ~/dwhelper 22whitelist ~/dwhelper
diff --git a/etc/flashpeak-slimjet.profile b/etc/flashpeak-slimjet.profile
index f248c385a..7e0eb486b 100644
--- a/etc/flashpeak-slimjet.profile
+++ b/etc/flashpeak-slimjet.profile
@@ -22,10 +22,8 @@ protocol unix,inet,inet6,netlink
22seccomp 22seccomp
23 23
24whitelist ${DOWNLOADS} 24whitelist ${DOWNLOADS}
25mkdir ~/.config
26mkdir ~/.config/slimjet 25mkdir ~/.config/slimjet
27whitelist ~/.config/slimjet 26whitelist ~/.config/slimjet
28mkdir ~/.cache
29mkdir ~/.cache/slimjet 27mkdir ~/.cache/slimjet
30whitelist ~/.cache/slimjet 28whitelist ~/.cache/slimjet
31mkdir ~/.pki 29mkdir ~/.pki
diff --git a/etc/franz.profile b/etc/franz.profile
index fc4a665de..3cb7942ab 100644
--- a/etc/franz.profile
+++ b/etc/franz.profile
@@ -14,10 +14,8 @@ nonewprivs
14noroot 14noroot
15 15
16whitelist ${DOWNLOADS} 16whitelist ${DOWNLOADS}
17mkdir ~/.config
18mkdir ~/.config/Franz 17mkdir ~/.config/Franz
19whitelist ~/.config/Franz 18whitelist ~/.config/Franz
20mkdir ~/.cache
21mkdir ~/.cache/Franz 19mkdir ~/.cache/Franz
22whitelist ~/.cache/Franz 20whitelist ~/.cache/Franz
23mkdir ~/.pki 21mkdir ~/.pki
diff --git a/etc/google-chrome-beta.profile b/etc/google-chrome-beta.profile
index 11f9f9e33..fe870274f 100644
--- a/etc/google-chrome-beta.profile
+++ b/etc/google-chrome-beta.profile
@@ -11,10 +11,8 @@ include /etc/firejail/disable-programs.inc
11netfilter 11netfilter
12 12
13whitelist ${DOWNLOADS} 13whitelist ${DOWNLOADS}
14mkdir ~/.config
15mkdir ~/.config/google-chrome-beta 14mkdir ~/.config/google-chrome-beta
16whitelist ~/.config/google-chrome-beta 15whitelist ~/.config/google-chrome-beta
17mkdir ~/.cache
18mkdir ~/.cache/google-chrome-beta 16mkdir ~/.cache/google-chrome-beta
19whitelist ~/.cache/google-chrome-beta 17whitelist ~/.cache/google-chrome-beta
20mkdir ~/.pki 18mkdir ~/.pki
diff --git a/etc/google-chrome-unstable.profile b/etc/google-chrome-unstable.profile
index f253e5a90..f6680ac2d 100644
--- a/etc/google-chrome-unstable.profile
+++ b/etc/google-chrome-unstable.profile
@@ -11,10 +11,8 @@ include /etc/firejail/disable-programs.inc
11netfilter 11netfilter
12 12
13whitelist ${DOWNLOADS} 13whitelist ${DOWNLOADS}
14mkdir ~/.config
15mkdir ~/.config/google-chrome-unstable 14mkdir ~/.config/google-chrome-unstable
16whitelist ~/.config/google-chrome-unstable 15whitelist ~/.config/google-chrome-unstable
17mkdir ~/.cache
18mkdir ~/.cache/google-chrome-unstable 16mkdir ~/.cache/google-chrome-unstable
19whitelist ~/.cache/google-chrome-unstable 17whitelist ~/.cache/google-chrome-unstable
20mkdir ~/.pki 18mkdir ~/.pki
diff --git a/etc/google-chrome.profile b/etc/google-chrome.profile
index 5e168aae5..a9fcebe73 100644
--- a/etc/google-chrome.profile
+++ b/etc/google-chrome.profile
@@ -11,10 +11,8 @@ include /etc/firejail/disable-programs.inc
11netfilter 11netfilter
12 12
13whitelist ${DOWNLOADS} 13whitelist ${DOWNLOADS}
14mkdir ~/.config
15mkdir ~/.config/google-chrome 14mkdir ~/.config/google-chrome
16whitelist ~/.config/google-chrome 15whitelist ~/.config/google-chrome
17mkdir ~/.cache
18mkdir ~/.cache/google-chrome 16mkdir ~/.cache/google-chrome
19whitelist ~/.cache/google-chrome 17whitelist ~/.cache/google-chrome
20mkdir ~/.pki 18mkdir ~/.pki
diff --git a/etc/gpredict.profile b/etc/gpredict.profile
index 02bb4d24d..a8378a66e 100644
--- a/etc/gpredict.profile
+++ b/etc/gpredict.profile
@@ -6,7 +6,6 @@ include /etc/firejail/disable-passwdmgr.inc
6include /etc/firejail/disable-programs.inc 6include /etc/firejail/disable-programs.inc
7 7
8# Whitelist 8# Whitelist
9mkdir ~/.config
10mkdir ~/.config/Gpredict 9mkdir ~/.config/Gpredict
11whitelist ~/.config/Gpredict 10whitelist ~/.config/Gpredict
12 11
diff --git a/etc/hexchat.profile b/etc/hexchat.profile
index 4e829c379..0d7ee6594 100644
--- a/etc/hexchat.profile
+++ b/etc/hexchat.profile
@@ -13,7 +13,6 @@ netfilter
13protocol unix,inet,inet6 13protocol unix,inet,inet6
14seccomp 14seccomp
15 15
16mkdir ~/.config
17mkdir ~/.config/hexchat 16mkdir ~/.config/hexchat
18whitelist ~/.config/hexchat 17whitelist ~/.config/hexchat
19include /etc/firejail/whitelist-common.inc 18include /etc/firejail/whitelist-common.inc
diff --git a/etc/icedove.profile b/etc/icedove.profile
index e9a63c8dd..23254751b 100644
--- a/etc/icedove.profile
+++ b/etc/icedove.profile
@@ -11,7 +11,6 @@ mkdir ~/.icedove
11whitelist ~/.icedove 11whitelist ~/.icedove
12 12
13noblacklist ~/.cache/icedove 13noblacklist ~/.cache/icedove
14mkdir ~/.cache
15mkdir ~/.cache/icedove 14mkdir ~/.cache/icedove
16whitelist ~/.cache/icedove 15whitelist ~/.cache/icedove
17 16
diff --git a/etc/mupen64plus.profile b/etc/mupen64plus.profile
index d4b442df8..acb13e6b9 100644
--- a/etc/mupen64plus.profile
+++ b/etc/mupen64plus.profile
@@ -8,11 +8,8 @@ include /etc/firejail/disable-programs.inc
8include /etc/firejail/disable-devel.inc 8include /etc/firejail/disable-devel.inc
9include /etc/firejail/disable-passwdmgr.inc 9include /etc/firejail/disable-passwdmgr.inc
10 10
11mkdir ${HOME}/.local
12mkdir ${HOME}/.local/share
13mkdir ${HOME}/.local/share/mupen64plus 11mkdir ${HOME}/.local/share/mupen64plus
14whitelist ${HOME}/.local/share/mupen64plus/ 12whitelist ${HOME}/.local/share/mupen64plus/
15mkdir ${HOME}/.config
16mkdir ${HOME}/.config/mupen64plus 13mkdir ${HOME}/.config/mupen64plus
17whitelist ${HOME}/.config/mupen64plus/ 14whitelist ${HOME}/.config/mupen64plus/
18 15
diff --git a/etc/netsurf.profile b/etc/netsurf.profile
index 3de6be238..1ed2163c2 100644
--- a/etc/netsurf.profile
+++ b/etc/netsurf.profile
@@ -15,10 +15,8 @@ seccomp
15tracelog 15tracelog
16 16
17whitelist ${DOWNLOADS} 17whitelist ${DOWNLOADS}
18mkdir ~/.config
19mkdir ~/.config/netsurf 18mkdir ~/.config/netsurf
20whitelist ~/.config/netsurf 19whitelist ~/.config/netsurf
21mkdir ~/.cache
22mkdir ~/.cache/netsurf 20mkdir ~/.cache/netsurf
23whitelist ~/.cache/netsurf 21whitelist ~/.cache/netsurf
24 22
diff --git a/etc/opera-beta.profile b/etc/opera-beta.profile
index 3d6edb286..12c91c744 100644
--- a/etc/opera-beta.profile
+++ b/etc/opera-beta.profile
@@ -8,10 +8,8 @@ include /etc/firejail/disable-devel.inc
8netfilter 8netfilter
9 9
10whitelist ${DOWNLOADS} 10whitelist ${DOWNLOADS}
11mkdir ~/.config
12mkdir ~/.config/opera-beta 11mkdir ~/.config/opera-beta
13whitelist ~/.config/opera-beta 12whitelist ~/.config/opera-beta
14mkdir ~/.cache
15mkdir ~/.cache/opera-beta 13mkdir ~/.cache/opera-beta
16whitelist ~/.cache/opera-beta 14whitelist ~/.cache/opera-beta
17mkdir ~/.pki 15mkdir ~/.pki
diff --git a/etc/opera.profile b/etc/opera.profile
index ff00eb349..e0c89a195 100644
--- a/etc/opera.profile
+++ b/etc/opera.profile
@@ -9,10 +9,8 @@ include /etc/firejail/disable-devel.inc
9netfilter 9netfilter
10 10
11whitelist ${DOWNLOADS} 11whitelist ${DOWNLOADS}
12mkdir ~/.config
13mkdir ~/.config/opera 12mkdir ~/.config/opera
14whitelist ~/.config/opera 13whitelist ~/.config/opera
15mkdir ~/.cache
16mkdir ~/.cache/opera 14mkdir ~/.cache/opera
17whitelist ~/.cache/opera 15whitelist ~/.cache/opera
18mkdir ~/.opera 16mkdir ~/.opera
diff --git a/etc/palemoon.profile b/etc/palemoon.profile
index 302c20d7d..acedaebb7 100644
--- a/etc/palemoon.profile
+++ b/etc/palemoon.profile
@@ -9,8 +9,6 @@ include /etc/firejail/whitelist-common.inc
9whitelist ${DOWNLOADS} 9whitelist ${DOWNLOADS}
10mkdir ~/.moonchild productions 10mkdir ~/.moonchild productions
11whitelist ~/.moonchild productions 11whitelist ~/.moonchild productions
12mkdir ~/.cache
13mkdir ~/.cache/moonchild productions
14mkdir ~/.cache/moonchild productions/pale moon 12mkdir ~/.cache/moonchild productions/pale moon
15whitelist ~/.cache/moonchild productions/pale moon 13whitelist ~/.cache/moonchild productions/pale moon
16 14
diff --git a/etc/polari.profile b/etc/polari.profile
index 366883c83..ac9530c40 100644
--- a/etc/polari.profile
+++ b/etc/polari.profile
@@ -3,18 +3,14 @@ include /etc/firejail/disable-common.inc
3include /etc/firejail/disable-programs.inc 3include /etc/firejail/disable-programs.inc
4include /etc/firejail/disable-devel.inc 4include /etc/firejail/disable-devel.inc
5 5
6mkdir ${HOME}/.local
7mkdir ${HOME}/.local/share/
8mkdir ${HOME}/.local/share/Empathy 6mkdir ${HOME}/.local/share/Empathy
9whitelist ${HOME}/.local/share/Empathy 7whitelist ${HOME}/.local/share/Empathy
10mkdir ${HOME}/.local/share/telepathy 8mkdir ${HOME}/.local/share/telepathy
11whitelist ${HOME}/.local/share/telepathy 9whitelist ${HOME}/.local/share/telepathy
12mkdir ${HOME}/.local/share/TpLogger 10mkdir ${HOME}/.local/share/TpLogger
13whitelist ${HOME}/.local/share/TpLogger 11whitelist ${HOME}/.local/share/TpLogger
14mkdir ${HOME}/.config
15mkdir ${HOME}/.config/telepathy-account-widgets 12mkdir ${HOME}/.config/telepathy-account-widgets
16whitelist ${HOME}/.config/telepathy-account-widgets 13whitelist ${HOME}/.config/telepathy-account-widgets
17mkdir ${HOME}/.cache
18mkdir ${HOME}/.cache/telepathy 14mkdir ${HOME}/.cache/telepathy
19whitelist ${HOME}/.cache/telepathy 15whitelist ${HOME}/.cache/telepathy
20mkdir ${HOME}/.purple 16mkdir ${HOME}/.purple
diff --git a/etc/psi-plus.profile b/etc/psi-plus.profile
index 9380237be..22c5bafc5 100644
--- a/etc/psi-plus.profile
+++ b/etc/psi-plus.profile
@@ -7,14 +7,10 @@ include /etc/firejail/disable-programs.inc
7include /etc/firejail/disable-passwdmgr.inc 7include /etc/firejail/disable-passwdmgr.inc
8 8
9whitelist ${DOWNLOADS} 9whitelist ${DOWNLOADS}
10mkdir ~/.config
11mkdir ~/.config/psi+ 10mkdir ~/.config/psi+
12whitelist ~/.config/psi+ 11whitelist ~/.config/psi+
13mkdir ~/.local
14mkdir ~/.local/share
15mkdir ~/.local/share/psi+ 12mkdir ~/.local/share/psi+
16whitelist ~/.local/share/psi+ 13whitelist ~/.local/share/psi+
17mkdir ~/.cache
18mkdir ~/.cache/psi+ 14mkdir ~/.cache/psi+
19whitelist ~/.cache/psi+ 15whitelist ~/.cache/psi+
20 16
diff --git a/etc/quiterss.profile b/etc/quiterss.profile
index f2b9959f6..2ab5d8a8e 100644
--- a/etc/quiterss.profile
+++ b/etc/quiterss.profile
@@ -4,14 +4,11 @@ include /etc/firejail/disable-passwdmgr.inc
4include /etc/firejail/disable-devel.inc 4include /etc/firejail/disable-devel.inc
5 5
6whitelist ${HOME}/quiterssfeeds.opml 6whitelist ${HOME}/quiterssfeeds.opml
7mkdir ~/.config
8mkdir ~/.config/QuiteRss 7mkdir ~/.config/QuiteRss
9whitelist ${HOME}/.config/QuiteRss/ 8whitelist ${HOME}/.config/QuiteRss/
10whitelist ${HOME}/.config/QuiteRssrc 9whitelist ${HOME}/.config/QuiteRssrc
11mkdir ~/.local
12mkdir ~/.local/share 10mkdir ~/.local/share
13whitelist ${HOME}/.local/share/ 11whitelist ${HOME}/.local/share/
14mkdir ~/.cache
15mkdir ~/.cache/QuiteRss 12mkdir ~/.cache/QuiteRss
16whitelist ${HOME}/.cache/QuiteRss 13whitelist ${HOME}/.cache/QuiteRss
17 14
diff --git a/etc/qutebrowser.profile b/etc/qutebrowser.profile
index b590f0ef1..0efb7b629 100644
--- a/etc/qutebrowser.profile
+++ b/etc/qutebrowser.profile
@@ -17,7 +17,6 @@ tracelog
17whitelist ${DOWNLOADS} 17whitelist ${DOWNLOADS}
18mkdir ~/.config/qutebrowser 18mkdir ~/.config/qutebrowser
19whitelist ~/.config/qutebrowser 19whitelist ~/.config/qutebrowser
20mkdir ~/.cache
21mkdir ~/.cache/qutebrowser 20mkdir ~/.cache/qutebrowser
22whitelist ~/.cache/qutebrowser 21whitelist ~/.cache/qutebrowser
23include /etc/firejail/whitelist-common.inc 22include /etc/firejail/whitelist-common.inc
diff --git a/etc/seamonkey.profile b/etc/seamonkey.profile
index 9ce4164c1..b981d9516 100644
--- a/etc/seamonkey.profile
+++ b/etc/seamonkey.profile
@@ -14,11 +14,8 @@ seccomp
14tracelog 14tracelog
15 15
16whitelist ${DOWNLOADS} 16whitelist ${DOWNLOADS}
17mkdir ~/.mozilla
18mkdir ~/.mozilla/seamonkey 17mkdir ~/.mozilla/seamonkey
19whitelist ~/.mozilla/seamonkey 18whitelist ~/.mozilla/seamonkey
20mkdir ~/.cache
21mkdir ~/.cache/mozilla
22mkdir ~/.cache/mozilla/seamonkey 19mkdir ~/.cache/mozilla/seamonkey
23whitelist ~/.cache/mozilla/seamonkey 20whitelist ~/.cache/mozilla/seamonkey
24whitelist ~/dwhelper 21whitelist ~/dwhelper
diff --git a/etc/spotify.profile b/etc/spotify.profile
index ca575970b..6bcb99e0f 100644
--- a/etc/spotify.profile
+++ b/etc/spotify.profile
@@ -10,14 +10,10 @@ include /etc/firejail/disable-passwdmgr.inc
10# Whitelist the folders needed by Spotify - This is more restrictive 10# Whitelist the folders needed by Spotify - This is more restrictive
11# than a blacklist though, but this is all spotify requires for 11# than a blacklist though, but this is all spotify requires for
12# streaming audio 12# streaming audio
13mkdir ${HOME}/.config
14mkdir ${HOME}/.config/spotify 13mkdir ${HOME}/.config/spotify
15whitelist ${HOME}/.config/spotify 14whitelist ${HOME}/.config/spotify
16mkdir ${HOME}/.local
17mkdir ${HOME}/.local/share
18mkdir ${HOME}/.local/share/spotify 15mkdir ${HOME}/.local/share/spotify
19whitelist ${HOME}/.local/share/spotify 16whitelist ${HOME}/.local/share/spotify
20mkdir ${HOME}/.cache
21mkdir ${HOME}/.cache/spotify 17mkdir ${HOME}/.cache/spotify
22whitelist ${HOME}/.cache/spotify 18whitelist ${HOME}/.cache/spotify
23include /etc/firejail/whitelist-common.inc 19include /etc/firejail/whitelist-common.inc
diff --git a/etc/stellarium.profile b/etc/stellarium.profile
index d0c1326b3..adefa75ff 100644
--- a/etc/stellarium.profile
+++ b/etc/stellarium.profile
@@ -9,7 +9,6 @@ include /etc/firejail/disable-programs.inc
9# Whitelist 9# Whitelist
10mkdir ~/.stellarium 10mkdir ~/.stellarium
11whitelist ~/.stellarium 11whitelist ~/.stellarium
12mkdir ~/.config
13mkdir ~/.config/stellarium 12mkdir ~/.config/stellarium
14whitelist ~/.config/stellarium 13whitelist ~/.config/stellarium
15 14
diff --git a/etc/thunderbird.profile b/etc/thunderbird.profile
index 7882367b9..5db50da4d 100644
--- a/etc/thunderbird.profile
+++ b/etc/thunderbird.profile
@@ -11,7 +11,6 @@ mkdir ~/.thunderbird
11whitelist ~/.thunderbird 11whitelist ~/.thunderbird
12 12
13noblacklist ~/.cache/thunderbird 13noblacklist ~/.cache/thunderbird
14mkdir ~/.cache
15mkdir ~/.cache/thunderbird 14mkdir ~/.cache/thunderbird
16whitelist ~/.cache/thunderbird 15whitelist ~/.cache/thunderbird
17 16
diff --git a/etc/uget-gtk.profile b/etc/uget-gtk.profile
index 269f8f0fd..522b4bd1e 100644
--- a/etc/uget-gtk.profile
+++ b/etc/uget-gtk.profile
@@ -13,7 +13,6 @@ protocol unix,inet,inet6
13seccomp 13seccomp
14 14
15whitelist ${DOWNLOADS} 15whitelist ${DOWNLOADS}
16mkdir ~/.config
17mkdir ~/.config/uGet 16mkdir ~/.config/uGet
18whitelist ~/.config/uGet 17whitelist ~/.config/uGet
19include /etc/firejail/whitelist-common.inc 18include /etc/firejail/whitelist-common.inc
diff --git a/etc/vivaldi.profile b/etc/vivaldi.profile
index 2049d2bd9..3c608dccb 100644
--- a/etc/vivaldi.profile
+++ b/etc/vivaldi.profile
@@ -9,10 +9,8 @@ netfilter
9nonewprivs 9nonewprivs
10 10
11whitelist ${DOWNLOADS} 11whitelist ${DOWNLOADS}
12mkdir ~/.config
13mkdir ~/.config/vivaldi 12mkdir ~/.config/vivaldi
14whitelist ~/.config/vivaldi 13whitelist ~/.config/vivaldi
15mkdir ~/.cache
16mkdir ~/.cache/vivaldi 14mkdir ~/.cache/vivaldi
17whitelist ~/.cache/vivaldi 15whitelist ~/.cache/vivaldi
18include /etc/firejail/whitelist-common.inc 16include /etc/firejail/whitelist-common.inc
diff --git a/etc/wesnoth.profile b/etc/wesnoth.profile
index cd0c6406f..2ddb59d11 100644
--- a/etc/wesnoth.profile
+++ b/etc/wesnoth.profile
@@ -18,12 +18,8 @@ private-dev
18 18
19whitelist /tmp/.X11-unix 19whitelist /tmp/.X11-unix
20 20
21mkdir ${HOME}/.local
22mkdir ${HOME}/.local/share
23mkdir ${HOME}/.local/share/wesnoth 21mkdir ${HOME}/.local/share/wesnoth
24mkdir ${HOME}/.config
25mkdir ${HOME}/.config/wesnoth 22mkdir ${HOME}/.config/wesnoth
26mkdir ${HOME}/.cache
27mkdir ${HOME}/.cache/wesnoth 23mkdir ${HOME}/.cache/wesnoth
28whitelist ${HOME}/.local/share/wesnoth 24whitelist ${HOME}/.local/share/wesnoth
29whitelist ${HOME}/.config/wesnoth 25whitelist ${HOME}/.config/wesnoth
diff --git a/etc/whitelist-common.inc b/etc/whitelist-common.inc
index b3a1a1d30..2317133c5 100644
--- a/etc/whitelist-common.inc
+++ b/etc/whitelist-common.inc
@@ -24,6 +24,5 @@ whitelist ~/.config/gtk-3.0
24whitelist ~/.themes 24whitelist ~/.themes
25 25
26# dconf 26# dconf
27mkdir ~/.config
28mkdir ~/.config/dconf 27mkdir ~/.config/dconf
29whitelist ~/.config/dconf 28whitelist ~/.config/dconf
diff --git a/src/firejail/fs_mkdir.c b/src/firejail/fs_mkdir.c
index 50bcc613b..5bc2df2cc 100644
--- a/src/firejail/fs_mkdir.c
+++ b/src/firejail/fs_mkdir.c
@@ -22,8 +22,38 @@
22#include <sys/stat.h> 22#include <sys/stat.h>
23#include <unistd.h> 23#include <unistd.h>
24#include <grp.h> 24#include <grp.h>
25 #include <sys/wait.h> 25#include <sys/wait.h>
26 26#include <string.h>
27
28static void mkdir_recursive(char *path) {
29 char *subdir = NULL;
30 struct stat s;
31
32 if (chdir("/")) {
33 fprintf(stderr, "Error: can't chdir to /");
34 return;
35 }
36
37 subdir = strtok(path, "/");
38 while(subdir) {
39 if (stat(subdir, &s) == -1) {
40 if (mkdir(subdir, 0700) == -1) {
41 fprintf(stderr, "Warning: cannot create %s directory\n", subdir);
42 return;
43 }
44 } else if (!S_ISDIR(s.st_mode)) {
45 fprintf(stderr, "Warning: '%s' exists, but is no directory\n", subdir);
46 return;
47 }
48 if (chdir(subdir)) {
49 fprintf(stderr, "Error: can't chdir to %s", subdir);
50 return;
51 }
52
53 subdir = strtok(NULL, "/");
54 }
55}
56
27void fs_mkdir(const char *name) { 57void fs_mkdir(const char *name) {
28 EUID_ASSERT(); 58 EUID_ASSERT();
29 59
@@ -50,8 +80,7 @@ void fs_mkdir(const char *name) {
50 drop_privs(0); 80 drop_privs(0);
51 81
52 // create directory 82 // create directory
53 if (mkdir(expanded, 0700) == -1) 83 mkdir_recursive(expanded);
54 fprintf(stderr, "Warning: cannot create %s directory\n", expanded);
55 exit(0); 84 exit(0);
56 } 85 }
57 // wait for the child to finish 86 // wait for the child to finish
@@ -101,4 +130,4 @@ void fs_mkfile(const char *name) {
101 130
102doexit: 131doexit:
103 free(expanded); 132 free(expanded);
104} \ No newline at end of file 133}
diff --git a/src/man/firejail-profile.txt b/src/man/firejail-profile.txt
index 504842a9e..7e33a6b45 100644
--- a/src/man/firejail-profile.txt
+++ b/src/man/firejail-profile.txt
@@ -136,7 +136,7 @@ The directory is created if it doesn't already exist.
136.br 136.br
137Use this command for whitelisted directories you need to preserve 137Use this command for whitelisted directories you need to preserve
138when the sandbox is closed. Without it, the application will create the directory, and the directory 138when the sandbox is closed. Without it, the application will create the directory, and the directory
139will be deleted when the sandbox is closed. Subdirectories also need to be created using mkdir. Example from 139will be deleted when the sandbox is closed. Subdirectories are recursively created. Example from
140firefox profile: 140firefox profile:
141.br 141.br
142 142
@@ -145,17 +145,13 @@ mkdir ~/.mozilla
145.br 145.br
146whitelist ~/.mozilla 146whitelist ~/.mozilla
147.br 147.br
148mkdir ~/.cache
149.br
150mkdir ~/.cache/mozilla
151.br
152mkdir ~/.cache/mozilla/firefox 148mkdir ~/.cache/mozilla/firefox
153.br 149.br
154whitelist ~/.cache/mozilla/firefox 150whitelist ~/.cache/mozilla/firefox
155.TP 151.TP
156\fBmkfile file 152\fBmkfile file
157Similar to mkdir, this command creates a file in user home before the sandbox is started. 153Similar to mkdir, this command creates a file in user home before the sandbox is started.
158The file is created if it doesn't already exist. 154The file is created if it doesn't already exist, but it's target directory has to exist.
159.TP 155.TP
160\fBnoexec file_or_directory 156\fBnoexec file_or_directory
161Remount the file or the directory noexec, nodev and nosuid. 157Remount the file or the directory noexec, nodev and nosuid.
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index 08888020c..00e6e29c2 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -51,5 +51,6 @@ echo "TESTING: blacklist glob (test/fs/option_blacklist_glob.exp)"
51echo "TESTING: bind as user (test/fs/option_bind_user.exp)" 51echo "TESTING: bind as user (test/fs/option_bind_user.exp)"
52./option_bind_user.exp 52./option_bind_user.exp
53 53
54 54echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
55./mkdir.exp
55 56
diff --git a/test/fs/mkdir.exp b/test/fs/mkdir.exp
new file mode 100755
index 000000000..111db06db
--- /dev/null
+++ b/test/fs/mkdir.exp
@@ -0,0 +1,20 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2016 Firejail Authors
4# License GPL v2
5
6set timeout 3
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --profile=mkdir.profile find ~/.firejail_test\r"
11expect {
12 timeout {puts "TESTING ERROR 1.1\n";exit}
13 "Warning: cannot create" { puts "TESTING ERROR 1.2\n";exit}
14 "No such file or directory" { puts "TESTING ERROR 1.3\n";exit}
15 ".firejail_test/a/b/c/d.txt"
16}
17send -- "rm -rf ~/.firejail_test\r"
18after 100
19
20puts "\nall done\n"
diff --git a/test/fs/mkdir.profile b/test/fs/mkdir.profile
new file mode 100644
index 000000000..61b44c9ac
--- /dev/null
+++ b/test/fs/mkdir.profile
@@ -0,0 +1,2 @@
1mkdir ~/.firejail_test/a/b/c
2mkfile ~/.firejail_test/a/b/c/d.txt