aboutsummaryrefslogtreecommitdiffstats
path: root/src/faudit/dev.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-07-15 12:10:58 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-07-15 12:10:58 -0400
commit80ccd124b6e510f820f5ccca7dd6b8acc3671e6a (patch)
tree94a4d9fc68154410bc947fe8dac923979d4eec06 /src/faudit/dev.c
parenttodo (diff)
downloadfirejail-80ccd124b6e510f820f5ccca7dd6b8acc3671e6a.tar.gz
firejail-80ccd124b6e510f820f5ccca7dd6b8acc3671e6a.tar.zst
firejail-80ccd124b6e510f820f5ccca7dd6b8acc3671e6a.zip
faudit work
Diffstat (limited to 'src/faudit/dev.c')
-rw-r--r--src/faudit/dev.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/faudit/dev.c b/src/faudit/dev.c
new file mode 100644
index 000000000..52506a258
--- /dev/null
+++ b/src/faudit/dev.c
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2014-2016 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#include "faudit.h"
21#include <dirent.h>
22
23void dev_test(void) {
24 DIR *dir;
25 if (!(dir = opendir("/dev"))) {
26 fprintf(stderr, "Error: cannot open /dev directory\n");
27 return;
28 }
29
30 struct dirent *entry;
31 char *end;
32 printf("INFO: files visible in /dev directory: ");
33 int cnt = 0;
34 while ((entry = readdir(dir)) != NULL) {
35 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
36 continue;
37
38 printf("%s, ", entry->d_name);
39 cnt++;
40 }
41 printf("\n");
42
43 if (cnt > 20)
44 printf("MAYBE: /dev directory seems to be fully populated. Use --private-dev or --whitelist to restrict the access.\n");
45 else
46 printf("GOOD: Access to /dev directory is restricted.\n");
47 closedir(dir);
48}