diff options
author | 2021-11-30 09:33:50 -0500 | |
---|---|---|
committer | 2021-11-30 09:33:50 -0500 | |
commit | 957f55b78c9a8efd67f7823916b259e3c7ea9f06 (patch) | |
tree | 1e93b997bd1dfc7a899d9acf4976c9420b12da2b | |
parent | readme updates (diff) | |
parent | Merge pull request #4725 from kmk3/fix-groups-misc2 (diff) | |
download | firejail-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.inc | 1 | ||||
-rw-r--r-- | etc/profile-a-l/kodi.profile | 1 | ||||
-rw-r--r-- | etc/profile-m-z/mpsyt.profile | 1 | ||||
-rw-r--r-- | etc/profile-m-z/mpv.profile | 1 | ||||
-rw-r--r-- | etc/profile-m-z/steam.profile | 1 | ||||
-rw-r--r-- | src/firejail/firejail.h | 1 | ||||
-rw-r--r-- | src/firejail/main.c | 82 | ||||
-rw-r--r-- | src/firejail/profile.c | 9 | ||||
-rw-r--r-- | src/firejail/util.c | 22 |
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 | |||
505 | blacklist ${HOME}/.config/microsoft-edge-dev | 505 | blacklist ${HOME}/.config/microsoft-edge-dev |
506 | blacklist ${HOME}/.config/midori | 506 | blacklist ${HOME}/.config/midori |
507 | blacklist ${HOME}/.config/mirage | 507 | blacklist ${HOME}/.config/mirage |
508 | blacklist ${HOME}/.config/monero-project | ||
508 | blacklist ${HOME}/.config/mono | 509 | blacklist ${HOME}/.config/mono |
509 | blacklist ${HOME}/.config/mpDris2 | 510 | blacklist ${HOME}/.config/mpDris2 |
510 | blacklist ${HOME}/.config/mpd | 511 | blacklist ${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 | |||
43 | nogroups | 43 | nogroups |
44 | noinput | 44 | noinput |
45 | nonewprivs | 45 | nonewprivs |
46 | # Seems to cause issues with Nvidia drivers sometimes (#3501) | ||
47 | noroot | 46 | noroot |
48 | nou2f | 47 | nou2f |
49 | protocol unix,inet,inet6,netlink | 48 | protocol 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 | |||
50 | caps.drop all | 50 | caps.drop all |
51 | netfilter | 51 | netfilter |
52 | nodvd | 52 | nodvd |
53 | # Seems to cause issues with Nvidia drivers sometimes | ||
54 | nogroups | 53 | nogroups |
55 | noinput | 54 | noinput |
56 | nonewprivs | 55 | nonewprivs |
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 | |||
62 | apparmor | 62 | apparmor |
63 | caps.drop all | 63 | caps.drop all |
64 | netfilter | 64 | netfilter |
65 | # nogroups seems to cause issues with Nvidia drivers sometimes | ||
66 | nogroups | 65 | nogroups |
67 | noinput | 66 | noinput |
68 | nonewprivs | 67 | nonewprivs |
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 | |||
132 | nodvd | 132 | nodvd |
133 | nogroups | 133 | nogroups |
134 | nonewprivs | 134 | nonewprivs |
135 | # If you use nVidia you might need to add 'ignore noroot' to your steam.local. | ||
136 | noroot | 135 | noroot |
137 | notv | 136 | notv |
138 | nou2f | 137 | nou2f |
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 | |||
324 | extern int arg_nosound; // disable sound | 324 | extern int arg_nosound; // disable sound |
325 | extern int arg_novideo; //disable video devices in /dev | 325 | extern int arg_novideo; //disable video devices in /dev |
326 | extern int arg_no3d; // disable 3d hardware acceleration | 326 | extern int arg_no3d; // disable 3d hardware acceleration |
327 | extern int arg_noprinters; // disable printers | ||
327 | extern int arg_quiet; // no output for scripting | 328 | extern int arg_quiet; // no output for scripting |
328 | extern int arg_join_network; // join only the network namespace | 329 | extern int arg_join_network; // join only the network namespace |
329 | extern int arg_join_filesystem; // join only the mount namespace | 330 | extern 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 | |||
120 | int arg_nosound = 0; // disable sound | 120 | int arg_nosound = 0; // disable sound |
121 | int arg_novideo = 0; //disable video devices in /dev | 121 | int arg_novideo = 0; //disable video devices in /dev |
122 | int arg_no3d; // disable 3d hardware acceleration | 122 | int arg_no3d; // disable 3d hardware acceleration |
123 | int arg_noprinters = 0; // disable printers | ||
123 | int arg_quiet = 0; // no output for scripting | 124 | int arg_quiet = 0; // no output for scripting |
124 | int arg_join_network = 0; // join only the network namespace | 125 | int arg_join_network = 0; // join only the network namespace |
125 | int arg_join_filesystem = 0; // join only the mount namespace | 126 | int 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) |