summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar startx2017 <vradu.startx@yandex.com>2018-04-23 15:59:52 -0400
committerLibravatar startx2017 <vradu.startx@yandex.com>2018-04-23 15:59:52 -0400
commit648a6d9edfa8d3647e95d0cf6e78fbcaf72f311e (patch)
tree86b23aa8cf139dd0ce6859dedae4a3dc2d099fcf /src
parentadd baloo_filemetadata_temp_extractor profile (diff)
downloadfirejail-648a6d9edfa8d3647e95d0cf6e78fbcaf72f311e.tar.gz
firejail-648a6d9edfa8d3647e95d0cf6e78fbcaf72f311e.tar.zst
firejail-648a6d9edfa8d3647e95d0cf6e78fbcaf72f311e.zip
conditional compile for debug code in fs.c
Diffstat (limited to 'src')
-rw-r--r--src/firejail/fs.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/firejail/fs.c b/src/firejail/fs.c
index 29cca0761..c9158ebd5 100644
--- a/src/firejail/fs.c
+++ b/src/firejail/fs.c
@@ -29,6 +29,11 @@
29#include <fcntl.h> 29#include <fcntl.h>
30#include <errno.h> 30#include <errno.h>
31 31
32// check noblacklist statements not matched by a proper blacklist in disable-*.inc files
33//#define TEST_NO_BLACKLIST_MATCHING
34
35
36
32static void fs_rdwr(const char *dir); 37static void fs_rdwr(const char *dir);
33 38
34 39
@@ -183,15 +188,17 @@ static void disable_file(OPERATION op, const char *filename) {
183 free(fname); 188 free(fname);
184} 189}
185 190
186// check noblacklist statements not matched by a proper blacklist in disable-*.inc files 191#ifdef TEST_NO_BLACKLIST_MATCHING
187static int nbcheck_start = 0; 192static int nbcheck_start = 0;
188static size_t nbcheck_size = 0; 193static size_t nbcheck_size = 0;
189static int *nbcheck = NULL; 194static int *nbcheck = NULL;
195#endif
190 196
191// Treat pattern as a shell glob pattern and blacklist matching files 197// Treat pattern as a shell glob pattern and blacklist matching files
192static void globbing(OPERATION op, const char *pattern, const char *noblacklist[], size_t noblacklist_len) { 198static void globbing(OPERATION op, const char *pattern, const char *noblacklist[], size_t noblacklist_len) {
193 assert(pattern); 199 assert(pattern);
194 200
201#ifdef TEST_NO_BLACKLIST_MATCHING
195 if (nbcheck_start == 0) { 202 if (nbcheck_start == 0) {
196 nbcheck_start = 1; 203 nbcheck_start = 1;
197 nbcheck_size = noblacklist_len; 204 nbcheck_size = noblacklist_len;
@@ -200,6 +207,7 @@ static void globbing(OPERATION op, const char *pattern, const char *noblacklist[
200 errExit("malloc"); 207 errExit("malloc");
201 memset(nbcheck, 0, sizeof(int) * noblacklist_len); 208 memset(nbcheck, 0, sizeof(int) * noblacklist_len);
202 } 209 }
210#endif
203 211
204 glob_t globbuf; 212 glob_t globbuf;
205 // Profiles contain blacklists for files that might not exist on a user's machine. 213 // Profiles contain blacklists for files that might not exist on a user's machine.
@@ -226,8 +234,10 @@ static void globbing(OPERATION op, const char *pattern, const char *noblacklist[
226 continue; 234 continue;
227 else if (result == 0) { 235 else if (result == 0) {
228 okay_to_blacklist = false; 236 okay_to_blacklist = false;
237#ifdef TEST_NO_BLACKLIST_MATCHING
229 if (j < nbcheck_size) // noblacklist checking 238 if (j < nbcheck_size) // noblacklist checking
230 nbcheck[j] = 1; 239 nbcheck[j] = 1;
240#endif
231 break; 241 break;
232 } 242 }
233 else { 243 else {
@@ -419,6 +429,7 @@ void fs_blacklist(void) {
419 } 429 }
420 430
421 size_t i; 431 size_t i;
432#ifdef TEST_NO_BLACKLIST_MATCHING
422 // noblacklist checking 433 // noblacklist checking
423 for (i = 0; i < nbcheck_size; i++) 434 for (i = 0; i < nbcheck_size; i++)
424 if (!arg_quiet && !nbcheck[i]) 435 if (!arg_quiet && !nbcheck[i])
@@ -431,6 +442,7 @@ void fs_blacklist(void) {
431 nbcheck = NULL; 442 nbcheck = NULL;
432 nbcheck_size = 0; 443 nbcheck_size = 0;
433 } 444 }
445#endif
434 for (i = 0; i < noblacklist_c; i++) 446 for (i = 0; i < noblacklist_c; i++)
435 free(noblacklist[i]); 447 free(noblacklist[i]);
436 free(noblacklist); 448 free(noblacklist);