aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-11-30 09:33:50 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2021-11-30 09:33:50 -0500
commit957f55b78c9a8efd67f7823916b259e3c7ea9f06 (patch)
tree1e93b997bd1dfc7a899d9acf4976c9420b12da2b
parentreadme updates (diff)
parentMerge pull request #4725 from kmk3/fix-groups-misc2 (diff)
downloadfirejail-957f55b78c9a8efd67f7823916b259e3c7ea9f06.tar.gz
firejail-957f55b78c9a8efd67f7823916b259e3c7ea9f06.tar.zst
firejail-957f55b78c9a8efd67f7823916b259e3c7ea9f06.zip
Merge branch 'master' of ssh://github.com/netblue30/firejail
-rw-r--r--etc/inc/disable-programs.inc1
-rw-r--r--etc/profile-a-l/kodi.profile1
-rw-r--r--etc/profile-m-z/mpsyt.profile1
-rw-r--r--etc/profile-m-z/mpv.profile1
-rw-r--r--etc/profile-m-z/steam.profile1
-rw-r--r--src/firejail/firejail.h1
-rw-r--r--src/firejail/main.c82
-rw-r--r--src/firejail/profile.c9
-rw-r--r--src/firejail/util.c22
9 files changed, 89 insertions, 30 deletions
diff --git a/etc/inc/disable-programs.inc b/etc/inc/disable-programs.inc
index 254d05e8e..1a3c27e5e 100644
--- a/etc/inc/disable-programs.inc
+++ b/etc/inc/disable-programs.inc
@@ -505,6 +505,7 @@ blacklist ${HOME}/.config/microsoft-edge-beta
505blacklist ${HOME}/.config/microsoft-edge-dev 505blacklist ${HOME}/.config/microsoft-edge-dev
506blacklist ${HOME}/.config/midori 506blacklist ${HOME}/.config/midori
507blacklist ${HOME}/.config/mirage 507blacklist ${HOME}/.config/mirage
508blacklist ${HOME}/.config/monero-project
508blacklist ${HOME}/.config/mono 509blacklist ${HOME}/.config/mono
509blacklist ${HOME}/.config/mpDris2 510blacklist ${HOME}/.config/mpDris2
510blacklist ${HOME}/.config/mpd 511blacklist ${HOME}/.config/mpd
diff --git a/etc/profile-a-l/kodi.profile b/etc/profile-a-l/kodi.profile
index f901637f3..2277a74fe 100644
--- a/etc/profile-a-l/kodi.profile
+++ b/etc/profile-a-l/kodi.profile
@@ -43,7 +43,6 @@ netfilter
43nogroups 43nogroups
44noinput 44noinput
45nonewprivs 45nonewprivs
46# Seems to cause issues with Nvidia drivers sometimes (#3501)
47noroot 46noroot
48nou2f 47nou2f
49protocol unix,inet,inet6,netlink 48protocol unix,inet,inet6,netlink
diff --git a/etc/profile-m-z/mpsyt.profile b/etc/profile-m-z/mpsyt.profile
index cadfd9b7f..ffc7698c7 100644
--- a/etc/profile-m-z/mpsyt.profile
+++ b/etc/profile-m-z/mpsyt.profile
@@ -50,7 +50,6 @@ apparmor
50caps.drop all 50caps.drop all
51netfilter 51netfilter
52nodvd 52nodvd
53# Seems to cause issues with Nvidia drivers sometimes
54nogroups 53nogroups
55noinput 54noinput
56nonewprivs 55nonewprivs
diff --git a/etc/profile-m-z/mpv.profile b/etc/profile-m-z/mpv.profile
index efb11465b..e6faba78a 100644
--- a/etc/profile-m-z/mpv.profile
+++ b/etc/profile-m-z/mpv.profile
@@ -62,7 +62,6 @@ include whitelist-var-common.inc
62apparmor 62apparmor
63caps.drop all 63caps.drop all
64netfilter 64netfilter
65# nogroups seems to cause issues with Nvidia drivers sometimes
66nogroups 65nogroups
67noinput 66noinput
68nonewprivs 67nonewprivs
diff --git a/etc/profile-m-z/steam.profile b/etc/profile-m-z/steam.profile
index dfefd7c2c..bcf94de51 100644
--- a/etc/profile-m-z/steam.profile
+++ b/etc/profile-m-z/steam.profile
@@ -132,7 +132,6 @@ netfilter
132nodvd 132nodvd
133nogroups 133nogroups
134nonewprivs 134nonewprivs
135# If you use nVidia you might need to add 'ignore noroot' to your steam.local.
136noroot 135noroot
137notv 136notv
138nou2f 137nou2f
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index 251350acc..a7673ae20 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -324,6 +324,7 @@ extern int arg_whitelist; // whitelist command
324extern int arg_nosound; // disable sound 324extern int arg_nosound; // disable sound
325extern int arg_novideo; //disable video devices in /dev 325extern int arg_novideo; //disable video devices in /dev
326extern int arg_no3d; // disable 3d hardware acceleration 326extern int arg_no3d; // disable 3d hardware acceleration
327extern int arg_noprinters; // disable printers
327extern int arg_quiet; // no output for scripting 328extern int arg_quiet; // no output for scripting
328extern int arg_join_network; // join only the network namespace 329extern int arg_join_network; // join only the network namespace
329extern int arg_join_filesystem; // join only the mount namespace 330extern int arg_join_filesystem; // join only the mount namespace
diff --git a/src/firejail/main.c b/src/firejail/main.c
index af2c603df..59e88bdc6 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -120,6 +120,7 @@ int arg_whitelist = 0; // whitelist command
120int arg_nosound = 0; // disable sound 120int arg_nosound = 0; // disable sound
121int arg_novideo = 0; //disable video devices in /dev 121int arg_novideo = 0; //disable video devices in /dev
122int arg_no3d; // disable 3d hardware acceleration 122int arg_no3d; // disable 3d hardware acceleration
123int arg_noprinters = 0; // disable printers
123int arg_quiet = 0; // no output for scripting 124int arg_quiet = 0; // no output for scripting
124int arg_join_network = 0; // join only the network namespace 125int arg_join_network = 0; // join only the network namespace
125int arg_join_filesystem = 0; // join only the mount namespace 126int arg_join_filesystem = 0; // join only the mount namespace
@@ -2160,6 +2161,7 @@ int main(int argc, char **argv, char **envp) {
2160 else if (strcmp(argv[i], "--no3d") == 0) 2161 else if (strcmp(argv[i], "--no3d") == 0)
2161 arg_no3d = 1; 2162 arg_no3d = 1;
2162 else if (strcmp(argv[i], "--noprinters") == 0) { 2163 else if (strcmp(argv[i], "--noprinters") == 0) {
2164 arg_noprinters = 1;
2163 profile_add("blacklist /dev/lp*"); 2165 profile_add("blacklist /dev/lp*");
2164 profile_add("blacklist /run/cups/cups.sock"); 2166 profile_add("blacklist /run/cups/cups.sock");
2165 } 2167 }
@@ -3152,37 +3154,79 @@ int main(int argc, char **argv, char **envp) {
3152 sprintf(ptr, "%d %d 1\n", gid, gid); 3154 sprintf(ptr, "%d %d 1\n", gid, gid);
3153 ptr += strlen(ptr); 3155 ptr += strlen(ptr);
3154 3156
3155 if (!arg_nogroups) { 3157 gid_t g;
3156 // add firejail group 3158 // add audio group
3157 gid_t g = get_group_id("firejail"); 3159 if (!arg_nosound) {
3160 g = get_group_id("audio");
3158 if (g) { 3161 if (g) {
3159 sprintf(ptr, "%d %d 1\n", g, g); 3162 sprintf(ptr, "%d %d 1\n", g, g);
3160 ptr += strlen(ptr); 3163 ptr += strlen(ptr);
3161 } 3164 }
3165 }
3162 3166
3163 // add tty group 3167 // add video group
3164 g = get_group_id("tty"); 3168 if (!arg_novideo) {
3169 g = get_group_id("video");
3165 if (g) { 3170 if (g) {
3166 sprintf(ptr, "%d %d 1\n", g, g); 3171 sprintf(ptr, "%d %d 1\n", g, g);
3167 ptr += strlen(ptr); 3172 ptr += strlen(ptr);
3168 } 3173 }
3174 }
3169 3175
3170 // add audio group 3176 // add render group
3171 if (!arg_nosound) { 3177 if (!arg_no3d) {
3172 g = get_group_id("audio"); 3178 g = get_group_id("render");
3173 if (g) { 3179 if (g) {
3174 sprintf(ptr, "%d %d 1\n", g, g); 3180 sprintf(ptr, "%d %d 1\n", g, g);
3175 ptr += strlen(ptr); 3181 ptr += strlen(ptr);
3176 }
3177 } 3182 }
3183 }
3178 3184
3179 // add video group 3185 // add lp group
3180 if (!arg_novideo) { 3186 if (!arg_noprinters) {
3181 g = get_group_id("video"); 3187 g = get_group_id("lp");
3182 if (g) { 3188 if (g) {
3183 sprintf(ptr, "%d %d 1\n", g, g); 3189 sprintf(ptr, "%d %d 1\n", g, g);
3184 ptr += strlen(ptr); 3190 ptr += strlen(ptr);
3185 } 3191 }
3192 }
3193
3194 // add cdrom/optical groups
3195 if (!arg_nodvd) {
3196 g = get_group_id("cdrom");
3197 if (g) {
3198 sprintf(ptr, "%d %d 1\n", g, g);
3199 ptr += strlen(ptr);
3200 }
3201 g = get_group_id("optical");
3202 if (g) {
3203 sprintf(ptr, "%d %d 1\n", g, g);
3204 ptr += strlen(ptr);
3205 }
3206 }
3207
3208 // add input group
3209 if (!arg_noinput) {
3210 g = get_group_id("input");
3211 if (g) {
3212 sprintf(ptr, "%d %d 1\n", g, g);
3213 ptr += strlen(ptr);
3214 }
3215 }
3216
3217 if (!arg_nogroups) {
3218 // add firejail group
3219 g = get_group_id("firejail");
3220 if (g) {
3221 sprintf(ptr, "%d %d 1\n", g, g);
3222 ptr += strlen(ptr);
3223 }
3224
3225 // add tty group
3226 g = get_group_id("tty");
3227 if (g) {
3228 sprintf(ptr, "%d %d 1\n", g, g);
3229 ptr += strlen(ptr);
3186 } 3230 }
3187 3231
3188 // add games group 3232 // add games group
diff --git a/src/firejail/profile.c b/src/firejail/profile.c
index d44b97ff6..756b370aa 100644
--- a/src/firejail/profile.c
+++ b/src/firejail/profile.c
@@ -416,13 +416,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
416 return 0; 416 return 0;
417 } 417 }
418 else if (strcmp(ptr, "nogroups") == 0) { 418 else if (strcmp(ptr, "nogroups") == 0) {
419 // nvidia cards require video group; disable nogroups 419 arg_nogroups = 1;
420 if (access("/dev/nvidiactl", R_OK) == 0 && arg_no3d == 0) {
421 fwarning("Warning: NVIDIA card detected, nogroups command disabled\n");
422 arg_nogroups = 0;
423 }
424 else
425 arg_nogroups = 1;
426 return 0; 420 return 0;
427 } 421 }
428 else if (strcmp(ptr, "nosound") == 0) { 422 else if (strcmp(ptr, "nosound") == 0) {
@@ -450,6 +444,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
450 return 0; 444 return 0;
451 } 445 }
452 else if (strcmp(ptr, "noprinters") == 0) { 446 else if (strcmp(ptr, "noprinters") == 0) {
447 arg_noprinters = 1;
453 profile_add("blacklist /dev/lp*"); 448 profile_add("blacklist /dev/lp*");
454 profile_add("blacklist /run/cups/cups.sock"); 449 profile_add("blacklist /run/cups/cups.sock");
455 return 0; 450 return 0;
diff --git a/src/firejail/util.c b/src/firejail/util.c
index 3bfb4435e..97afe9649 100644
--- a/src/firejail/util.c
+++ b/src/firejail/util.c
@@ -168,6 +168,28 @@ static void clean_supplementary_groups(gid_t gid) {
168 new_groups, &new_ngroups, MAX_GROUPS); 168 new_groups, &new_ngroups, MAX_GROUPS);
169 } 169 }
170 170
171 if (!arg_no3d) {
172 copy_group_ifcont("render", groups, ngroups,
173 new_groups, &new_ngroups, MAX_GROUPS);
174 }
175
176 if (!arg_noprinters) {
177 copy_group_ifcont("lp", groups, ngroups,
178 new_groups, &new_ngroups, MAX_GROUPS);
179 }
180
181 if (!arg_nodvd) {
182 copy_group_ifcont("cdrom", groups, ngroups,
183 new_groups, &new_ngroups, MAX_GROUPS);
184 copy_group_ifcont("optical", groups, ngroups,
185 new_groups, &new_ngroups, MAX_GROUPS);
186 }
187
188 if (!arg_noinput) {
189 copy_group_ifcont("input", groups, ngroups,
190 new_groups, &new_ngroups, MAX_GROUPS);
191 }
192
171 if (new_ngroups) { 193 if (new_ngroups) {
172 rv = setgroups(new_ngroups, new_groups); 194 rv = setgroups(new_ngroups, new_groups);
173 if (rv) 195 if (rv)