aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/util.c
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2021-10-16 02:26:17 -0300
committerLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2021-10-22 15:53:34 -0300
commitea564eb74abaefd791a8c95d51e36c21e5fffcf9 (patch)
tree2e5e9161002b5f343b1610e09fc4da4d9dda9f54 /src/firejail/util.c
parentutil.c: check array size on copy_group_ifcont (diff)
downloadfirejail-ea564eb74abaefd791a8c95d51e36c21e5fffcf9.tar.gz
firejail-ea564eb74abaefd791a8c95d51e36c21e5fffcf9.tar.zst
firejail-ea564eb74abaefd791a8c95d51e36c21e5fffcf9.zip
Consider nosound and novideo when keeping groups
Even when `nogroups` is not used, avoid keeping the audio and video groups when `nosound` and `novideo` are used, respectively. Based on @rusty-snake's suggestion: https://github.com/netblue30/firejail/issues/4603#issuecomment-944046299 Relates to #4603.
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r--src/firejail/util.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c
index 5bb5c257b..969578aeb 100644
--- a/src/firejail/util.c
+++ b/src/firejail/util.c
@@ -142,14 +142,11 @@ static void clean_supplementary_groups(gid_t gid) {
142 goto clean_all; 142 goto clean_all;
143 143
144 // clean supplementary group list 144 // clean supplementary group list
145 // allow only firejail, tty, audio, video, games
146 gid_t new_groups[MAX_GROUPS]; 145 gid_t new_groups[MAX_GROUPS];
147 int new_ngroups = 0; 146 int new_ngroups = 0;
148 char *allowed[] = { 147 char *allowed[] = {
149 "firejail", 148 "firejail",
150 "tty", 149 "tty",
151 "audio",
152 "video",
153 "games", 150 "games",
154 NULL 151 NULL
155 }; 152 };
@@ -161,6 +158,16 @@ static void clean_supplementary_groups(gid_t gid) {
161 i++; 158 i++;
162 } 159 }
163 160
161 if (!arg_nosound) {
162 copy_group_ifcont("audio", groups, ngroups,
163 new_groups, &new_ngroups, MAX_GROUPS);
164 }
165
166 if (!arg_novideo) {
167 copy_group_ifcont("video", groups, ngroups,
168 new_groups, &new_ngroups, MAX_GROUPS);
169 }
170
164 if (new_ngroups) { 171 if (new_ngroups) {
165 rv = setgroups(new_ngroups, new_groups); 172 rv = setgroups(new_ngroups, new_groups);
166 if (rv) 173 if (rv)