aboutsummaryrefslogtreecommitdiffstats
path: root/src/firecfg/firejail-welcome.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/firecfg/firejail-welcome.sh')
-rwxr-xr-xsrc/firecfg/firejail-welcome.sh204
1 files changed, 204 insertions, 0 deletions
diff --git a/src/firecfg/firejail-welcome.sh b/src/firecfg/firejail-welcome.sh
new file mode 100755
index 000000000..a7e74ebc3
--- /dev/null
+++ b/src/firecfg/firejail-welcome.sh
@@ -0,0 +1,204 @@
1#!/bin/bash
2
3# This file is part of Firejail project
4# Copyright (C) 2020-2022 Firejail Authors
5# License GPL v2
6#
7# Usage: firejail-welcome PROGRAM SYSCONFDIR USER_NAME
8# where PROGRAM is detected and driven by firecfg.
9# SYSCONFDIR is most of the time /etc/firejail.
10#
11# The plan is to go with zenity by default. If zenity is not installed
12# we will provide a console-only replacement in /usr/lib/firejail/fzenity
13#
14
15if ! command -v "$1" >/dev/null; then
16 echo "Please install $1."
17 exit 1
18fi
19
20PROGRAM="sudo -u $3 $1"
21SYSCONFDIR=$2
22export LANG=en_US.UTF8
23
24TITLE="Firejail Configuration Guide"
25sed_scripts=()
26run_firecfg=false
27enable_u2f=false
28enable_drm=false
29enable_seccomp_kill=false
30enable_restricted_net=false
31enable_nonewprivs=false
32
33#******************************************************
34# Intro
35#******************************************************
36read -r -d $'\0' MSG_INTRO <<EOM
37<big><b>Welcome to Firejail!</b></big>
38
39This guide will walk you through some of the most common sandbox customizations.
40At the end of the guide you'll have the option to save your changes in Firejail's
41global config file at <b>/etc/firejail/firejail.config</b>. A copy of the original file is saved
42as <b>/etc/firejal/firejail.config-</b>.
43
44Please note that running this script a second time can set new options, but does
45not clear options set in a previous run.
46
47Press OK to continue, or close this window to stop the program.
48
49EOM
50$PROGRAM --title="$TITLE" --info --width=600 --height=40 --text="$MSG_INTRO"
51[[ $? -eq 1 ]] && exit 0
52
53#******************************************************
54# symlinks
55#******************************************************
56read -r -d $'\0' MSG_Q_RUN_FIRECFG <<EOM
57<big><b>Should most programs be sandboxed by default?</b></big>
58
59Currently, Firejail recognizes more than 1000 regular desktop programs. These programs
60can be sandboxed automatically when you start them.
61
62EOM
63
64if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_RUN_FIRECFG"; then
65 run_firecfg=true
66fi
67
68#******************************************************
69# U2F
70#******************************************************
71read -r -d $'\0' MSG_Q_BROWSER_DISABLE_U2F <<EOM
72<big><b>Should browsers be allowed to access u2f hardware?</b></big>
73
74Universal Two-Factor (U2F) devices are used as a password store for online
75accounts. These devices usually come in a form of a USB key.
76
77EOM
78
79if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_BROWSER_DISABLE_U2F"; then
80 enable_u2f=true
81 sed_scripts+=("-e s/# browser-disable-u2f yes/browser-disable-u2f no/")
82fi
83
84#******************************************************
85# DRM
86#******************************************************
87read -r -d $'\0' MSG_Q_BROWSER_ALLOW_DRM <<EOM
88<big><b>Should browsers be able to play DRM content?</b></big>
89
90The home directory is <tt>noexec,nodev,nosuid</tt> by default for most applications.
91This means that executing programs located in your home directory is forbidden.
92
93Browsers install proprietary DRM plug-ins such as Widevine in your home directory.
94In order to use them, your home must be mounted <tt>exec</tt> inside the sandbox. This
95may give the people developing and distributing the plug-in access to your private
96data.
97
98NOTE: Software written in an interpreted language such as bash, python or java can
99always be started from home directory.
100
101HINT: If <tt>/home</tt> has its own partition, you can mount it <tt>nodev,nosuid</tt> for all programs.
102
103EOM
104
105if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_BROWSER_ALLOW_DRM"; then
106 enable_drm=true
107 sed_scripts+=("-e s/# browser-allow-drm no/browser-allow-drm yes/")
108fi
109
110#******************************************************
111# nonewprivs
112#******************************************************
113read -r -d $'\0' MSG_Q_NONEWPRIVS <<EOM
114<big><b>Should we force nonweprivs by default?</b></big>
115
116nonewprivs is a Linux kernel feature that prevents programs from rising privileges.
117It is also a strong mitigation against exploits in Firejail. However, some programs
118like chromium, wireshark, or even ping might not work.
119
120NOTE: seccomp enables nonewprivs automatically. Most applications supported by
121default by Firejail are using seccomp.
122
123EOM
124
125if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_NONEWPRIVS"; then
126 enable_nonewprivs=true
127 sed_scripts+=("-e s/# force-nonewprivs no/force-nonewprivs yes/")
128fi
129
130#******************************************************
131# restricted network
132#******************************************************
133read -r -d $'\0' MSG_Q_NETWORK <<EOM
134<big><b>Should we restrict network functionality?</b></big>
135
136Restrict all network related commands except '<tt>net none</tt>' to root only.
137
138EOM
139
140if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_NETWORK"; then
141 enable_restricted_net=true
142 sed_scripts+=("-e s/# restricted-network no/restricted-network yes/")
143fi
144
145#******************************************************
146# seccomp kill
147#******************************************************
148read -r -d $'\0' MSG_Q_SECCOMP <<EOM
149<big><b>Should we kill programs that violate seccomp rules?</b></big>
150
151By default seccomp prevents the program from running the syscall and returns an error.
152
153EOM
154
155if $PROGRAM --title="$TITLE" --question --ellipsize --text="$MSG_Q_SECCOMP"; then
156 enable_seccomp_kill=true
157 sed_scripts+=("-e s/# seccomp-error-action EPERM/seccomp-error-action kill/")
158fi
159
160#******************************************************
161# root
162#******************************************************
163read -r -d $'\0' MSG_RUN <<EOM
164Now, I will apply the changes. This is what I will do:
165
166
167EOM
168MSG_RUN+="\n\n"
169if [[ "$run_firecfg" == "true" ]]; then
170 MSG_RUN+=" * enable Firejail for all recognized programs\n"
171fi
172if [[ "$enable_u2f" == "true" ]]; then
173 MSG_RUN+=" * allow browsers to access U2F devices\n"
174fi
175if [[ "$enable_drm" == "true" ]]; then
176 MSG_RUN+=" * allow browsers to play DRM content\n"
177fi
178if [[ "$enable_nonewprivs" == "true" ]]; then
179 MSG_RUN+=" * enable nonewprivs globally\n"
180fi
181if [[ "$enable_restricted_net" == "true" ]]; then
182 MSG_RUN+=" * restrict networking features\n"
183fi
184if [[ "$enable_seccomp_kill" == "true" ]]; then
185 MSG_RUN+=" * enable seccomp kill\n"
186fi
187MSG_RUN+="\n\nPress OK to continue, or close this window to stop the program."
188
189$PROGRAM --title="$TITLE" --info --width=600 --height=40 --text="$MSG_RUN"
190[[ $? -eq 1 ]] && exit 0
191
192if [[ -n "${sed_scripts[*]}" ]]; then
193 cp "$SYSCONFDIR"/firejail.config "$SYSCONFDIR"/firejail.config-
194 sed -i "${sed_scripts[@]}" "$SYSCONFDIR"/firejail.config
195fi
196if [[ "$run_firecfg" == "true" ]]; then
197 # return 55 to inform firecfg symlinks are desired
198 exit 55
199fi
200
201#******************************************************
202# all done
203#******************************************************
204exit 0