diff options
Diffstat (limited to 'src/firemon/x11.c')
-rw-r--r-- | src/firemon/x11.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/firemon/x11.c b/src/firemon/x11.c new file mode 100644 index 000000000..e30c2d78b --- /dev/null +++ b/src/firemon/x11.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2016 netblue30 (netblue30@yahoo.com) | ||
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 "firemon.h" | ||
21 | #include <sys/types.h> | ||
22 | #include <sys/stat.h> | ||
23 | #include <unistd.h> | ||
24 | |||
25 | void x11(pid_t pid) { | ||
26 | if (getuid() == 0) | ||
27 | firemon_drop_privs(); | ||
28 | |||
29 | pid_read(pid); | ||
30 | |||
31 | // print processes | ||
32 | int i; | ||
33 | for (i = 0; i < max_pids; i++) { | ||
34 | if (pids[i].level == 1) { | ||
35 | pid_print_list(i, 0); | ||
36 | |||
37 | char *x11file; | ||
38 | // todo: use macro from src/firejail/firejail.h for /run/firejail/x11 directory | ||
39 | if (asprintf(&x11file, "/run/firejail/x11/%d", i) == -1) | ||
40 | errExit("asprintf"); | ||
41 | |||
42 | struct stat s; | ||
43 | if (stat(x11file, &s) == 0) { | ||
44 | FILE *fp = fopen(x11file, "r"); | ||
45 | if (!fp) { | ||
46 | free(x11file); | ||
47 | continue; | ||
48 | } | ||
49 | int display; | ||
50 | int rv = fscanf(fp, "%d", &display); | ||
51 | if (rv == 1) | ||
52 | printf(" DISPLAY :%d\n", display); | ||
53 | fclose(fp); | ||
54 | } | ||
55 | |||
56 | free(x11file); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||