Skip to content

Commit 2714c6b

Browse files
committed
AppRun: watch adding /tmp
Beware not to add --whitelist=/tmp[something] because that would hide the actual mounted image (/tmp/.mount_ultragridsomething). As /tmp is remounted RO, just make the "whitelisted" dirs RW. + add to whitelist $DIR (path to executable) if it is not /tmp (eg. extracted AppImage somewhere)
1 parent cee4f37 commit 2714c6b

File tree

1 file changed

+16
-3
lines changed
  • data/scripts/Linux-AppImage

1 file changed

+16
-3
lines changed

data/scripts/Linux-AppImage/AppRun

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,30 @@ setup_vaapi() {
161161
fi
162162
}
163163

164+
add_whitelist() {
165+
if expr "$1" : /tmp >/dev/null; then
166+
printf -- "--read-write=%s --mkdir=%s" "$1" "$1"
167+
return
168+
fi
169+
printf -- "--whitelist=%s" "$1"
170+
}
171+
164172
## Parse params to get whitelists that may be needed to add
165173
## @todo spaces inside paths doesn't work
166174
get_firejail_whitelist() {
167175
separator=''
168176
playback_path=$(echo "$@" | sed -n 's/.*--playback \([^ :]*\).*/\1/p')
169177
if [ -n "$playback_path" ]; then
170178
abs_path=$(realpath "$playback_path")
171-
printf -- "$separator--whitelist=%s" "$abs_path"
179+
printf -- "$separator%s" "$(add_whitelist "$abs_path")"
172180
separator=' '
173181
fi
174182
# print every argument of "filename=", "file=", "dump:" or "--record=" pattern
175183
for n in "$@"; do
176184
file_path=$(echo "$n" | sed -n -e 's/.*filename=\([^:]*\).*/\1/p' -e 's/.*file=\([^:]*\).*/\1/p' -e 's/dump:\([^:]*\).*/\1/p' -e 's/^--record=\([^:]*\).*/\1/p')
177185
if [ -n "$file_path" ]; then
178186
abs_path=$(realpath "$file_path")
179-
printf -- "$separator--whitelist=%s" "$abs_path"
187+
printf -- "$separator%s" "$(add_whitelist "$abs_path")"
180188
separator=' '
181189
if expr "$n" : 'dump:' >/dev/null || expr "$n" : '--record' >/dev/null; then
182190
printf -- "$separator--mkdir=%s" "$abs_path" # dir may not exist
@@ -185,7 +193,12 @@ get_firejail_whitelist() {
185193
done
186194
# -d dump or -d dummy:dump_to_file
187195
if expr "$*" : '.*dump' >/dev/null || expr "$*" : '.*record' >/dev/null; then
188-
printf -- "$separator--whitelist=%s" "$(pwd)"
196+
printf -- "$separator%s" "$(add_whitelist "$(pwd)")"
197+
separator=' '
198+
fi
199+
if ! expr "$DIR" : /tmp >/dev/null && command -v realpath >/dev/null; then
200+
exe_path=$(realpath "$DIR")
201+
printf -- "$separator%s" "$(add_whitelist "$exe_path")"
189202
separator=' '
190203
fi
191204
if [ -z "$separator" ]; then

0 commit comments

Comments
 (0)