diff options
-rw-r--r-- | src/firejail/appimage.c | 8 | ||||
-rw-r--r-- | src/firejail/chroot.c | 8 | ||||
-rw-r--r-- | src/firejail/fs.c | 8 | ||||
-rw-r--r-- | src/firejail/fs_mkdir.c | 9 | ||||
-rw-r--r-- | src/firejail/ls.c | 16 | ||||
-rw-r--r-- | src/firejail/main.c | 9 | ||||
-rw-r--r-- | src/firejail/profile.c | 8 | ||||
-rw-r--r-- | src/firejail/rlimit.c | 30 | ||||
-rw-r--r-- | src/firejail/sandbox.c | 11 | ||||
-rw-r--r-- | src/firejail/util.c | 25 | ||||
-rw-r--r-- | src/firemon/interface.c | 9 | ||||
-rw-r--r-- | src/firemon/netstats.c | 8 | ||||
-rw-r--r-- | src/firemon/procevent.c | 7 | ||||
-rw-r--r-- | src/firemon/top.c | 8 | ||||
-rw-r--r-- | src/include/gcov_wrapper.h | 6 |
15 files changed, 62 insertions, 108 deletions
diff --git a/src/firejail/appimage.c b/src/firejail/appimage.c index e019de36f..8d0d726db 100644 --- a/src/firejail/appimage.c +++ b/src/firejail/appimage.c | |||
@@ -21,6 +21,7 @@ | |||
21 | // sudo mount -o loop krita-3.0-x86_64.appimage mnt | 21 | // sudo mount -o loop krita-3.0-x86_64.appimage mnt |
22 | 22 | ||
23 | #include "firejail.h" | 23 | #include "firejail.h" |
24 | #include "../include/gcov_wrapper.h" | ||
24 | #include <sys/types.h> | 25 | #include <sys/types.h> |
25 | #include <sys/stat.h> | 26 | #include <sys/stat.h> |
26 | #include <sys/mount.h> | 27 | #include <sys/mount.h> |
@@ -28,10 +29,6 @@ | |||
28 | #include <linux/loop.h> | 29 | #include <linux/loop.h> |
29 | #include <errno.h> | 30 | #include <errno.h> |
30 | 31 | ||
31 | #ifdef HAVE_GCOV | ||
32 | #include "../include/gcov_wrapper.h" | ||
33 | #endif | ||
34 | |||
35 | static char *devloop = NULL; // device file | 32 | static char *devloop = NULL; // device file |
36 | static long unsigned size = 0; // offset into appimage file | 33 | static long unsigned size = 0; // offset into appimage file |
37 | #define MAXBUF 4096 | 34 | #define MAXBUF 4096 |
@@ -140,9 +137,8 @@ void appimage_set(const char *appimage) { | |||
140 | 137 | ||
141 | if (cfg.cwd) | 138 | if (cfg.cwd) |
142 | env_store_name_val("OWD", cfg.cwd, SETENV); | 139 | env_store_name_val("OWD", cfg.cwd, SETENV); |
143 | #ifdef HAVE_GCOV | 140 | |
144 | __gcov_flush(); | 141 | __gcov_flush(); |
145 | #endif | ||
146 | #else | 142 | #else |
147 | fprintf(stderr, "Error: /dev/loop-control interface is not supported by your kernel\n"); | 143 | fprintf(stderr, "Error: /dev/loop-control interface is not supported by your kernel\n"); |
148 | exit(1); | 144 | exit(1); |
diff --git a/src/firejail/chroot.c b/src/firejail/chroot.c index 0d4baa618..37ec22117 100644 --- a/src/firejail/chroot.c +++ b/src/firejail/chroot.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #ifdef HAVE_CHROOT | 21 | #ifdef HAVE_CHROOT |
22 | #include "firejail.h" | 22 | #include "firejail.h" |
23 | #include "../include/gcov_wrapper.h" | ||
23 | #include <sys/mount.h> | 24 | #include <sys/mount.h> |
24 | #include <sys/sendfile.h> | 25 | #include <sys/sendfile.h> |
25 | #include <errno.h> | 26 | #include <errno.h> |
@@ -29,10 +30,6 @@ | |||
29 | #define O_PATH 010000000 | 30 | #define O_PATH 010000000 |
30 | #endif | 31 | #endif |
31 | 32 | ||
32 | #ifdef HAVE_GCOV | ||
33 | #include "../include/gcov_wrapper.h" | ||
34 | #endif | ||
35 | |||
36 | // exit if error | 33 | // exit if error |
37 | void fs_check_chroot_dir(void) { | 34 | void fs_check_chroot_dir(void) { |
38 | EUID_ASSERT(); | 35 | EUID_ASSERT(); |
@@ -263,9 +260,8 @@ void fs_chroot(const char *rootdir) { | |||
263 | // update chroot resolv.conf | 260 | // update chroot resolv.conf |
264 | update_file(parentfd, "etc/resolv.conf"); | 261 | update_file(parentfd, "etc/resolv.conf"); |
265 | 262 | ||
266 | #ifdef HAVE_GCOV | ||
267 | __gcov_flush(); | 263 | __gcov_flush(); |
268 | #endif | 264 | |
269 | // create /run/firejail/mnt/oroot | 265 | // create /run/firejail/mnt/oroot |
270 | char *oroot = RUN_OVERLAY_ROOT; | 266 | char *oroot = RUN_OVERLAY_ROOT; |
271 | if (mkdir(oroot, 0755) == -1) | 267 | if (mkdir(oroot, 0755) == -1) |
diff --git a/src/firejail/fs.c b/src/firejail/fs.c index 803b081c9..7a4ef5f8d 100644 --- a/src/firejail/fs.c +++ b/src/firejail/fs.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <sys/mount.h> | 22 | #include <sys/mount.h> |
22 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
23 | #include <sys/statvfs.h> | 24 | #include <sys/statvfs.h> |
@@ -33,10 +34,6 @@ | |||
33 | #define O_PATH 010000000 | 34 | #define O_PATH 010000000 |
34 | #endif | 35 | #endif |
35 | 36 | ||
36 | #ifdef HAVE_GCOV | ||
37 | #include "../include/gcov_wrapper.h" | ||
38 | #endif | ||
39 | |||
40 | #define MAX_BUF 4096 | 37 | #define MAX_BUF 4096 |
41 | #define EMPTY_STRING ("") | 38 | #define EMPTY_STRING ("") |
42 | // check noblacklist statements not matched by a proper blacklist in disable-*.inc files | 39 | // check noblacklist statements not matched by a proper blacklist in disable-*.inc files |
@@ -1206,9 +1203,8 @@ void fs_overlayfs(void) { | |||
1206 | fs_logger("whitelist /tmp"); | 1203 | fs_logger("whitelist /tmp"); |
1207 | 1204 | ||
1208 | // chroot in the new filesystem | 1205 | // chroot in the new filesystem |
1209 | #ifdef HAVE_GCOV | ||
1210 | __gcov_flush(); | 1206 | __gcov_flush(); |
1211 | #endif | 1207 | |
1212 | if (chroot(oroot) == -1) | 1208 | if (chroot(oroot) == -1) |
1213 | errExit("chroot"); | 1209 | errExit("chroot"); |
1214 | 1210 | ||
diff --git a/src/firejail/fs_mkdir.c b/src/firejail/fs_mkdir.c index 0195435f9..4983db0a0 100644 --- a/src/firejail/fs_mkdir.c +++ b/src/firejail/fs_mkdir.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <sys/types.h> | 22 | #include <sys/types.h> |
22 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
23 | #include <unistd.h> | 24 | #include <unistd.h> |
@@ -25,10 +26,6 @@ | |||
25 | #include <sys/wait.h> | 26 | #include <sys/wait.h> |
26 | #include <string.h> | 27 | #include <string.h> |
27 | 28 | ||
28 | #ifdef HAVE_GCOV | ||
29 | #include "../include/gcov_wrapper.h" | ||
30 | #endif | ||
31 | |||
32 | static void check(const char *fname) { | 29 | static void check(const char *fname) { |
33 | // manufacture /run/user directory | 30 | // manufacture /run/user directory |
34 | char *runuser; | 31 | char *runuser; |
@@ -98,9 +95,9 @@ void fs_mkdir(const char *name) { | |||
98 | 95 | ||
99 | // create directory | 96 | // create directory |
100 | mkdir_recursive(expanded); | 97 | mkdir_recursive(expanded); |
101 | #ifdef HAVE_GCOV | 98 | |
102 | __gcov_flush(); | 99 | __gcov_flush(); |
103 | #endif | 100 | |
104 | _exit(0); | 101 | _exit(0); |
105 | } | 102 | } |
106 | // wait for the child to finish | 103 | // wait for the child to finish |
diff --git a/src/firejail/ls.c b/src/firejail/ls.c index ae7e89741..70985ba9e 100644 --- a/src/firejail/ls.c +++ b/src/firejail/ls.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "firejail.h" | 21 | #include "firejail.h" |
22 | #include "../include/gcov_wrapper.h" | ||
22 | #include <sys/types.h> | 23 | #include <sys/types.h> |
23 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
24 | #include <sys/wait.h> | 25 | #include <sys/wait.h> |
@@ -31,10 +32,6 @@ | |||
31 | //#include <stdio.h> | 32 | //#include <stdio.h> |
32 | //#include <stdlib.h> | 33 | //#include <stdlib.h> |
33 | 34 | ||
34 | #ifdef HAVE_GCOV | ||
35 | #include "../include/gcov_wrapper.h" | ||
36 | #endif | ||
37 | |||
38 | // uid/gid cache | 35 | // uid/gid cache |
39 | static uid_t c_uid = 0; | 36 | static uid_t c_uid = 0; |
40 | static char *c_uid_name = NULL; | 37 | static char *c_uid_name = NULL; |
@@ -353,9 +350,8 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { | |||
353 | ls(fname1); | 350 | ls(fname1); |
354 | else | 351 | else |
355 | cat(fname1); | 352 | cat(fname1); |
356 | #ifdef HAVE_GCOV | 353 | |
357 | __gcov_flush(); | 354 | __gcov_flush(); |
358 | #endif | ||
359 | } | 355 | } |
360 | // get file from host and store it in the sandbox | 356 | // get file from host and store it in the sandbox |
361 | else if (op == SANDBOX_FS_PUT && path2) { | 357 | else if (op == SANDBOX_FS_PUT && path2) { |
@@ -387,9 +383,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { | |||
387 | // copy the file | 383 | // copy the file |
388 | if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) // already a regular user | 384 | if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) // already a regular user |
389 | _exit(1); | 385 | _exit(1); |
390 | #ifdef HAVE_GCOV | 386 | |
391 | __gcov_flush(); | 387 | __gcov_flush(); |
392 | #endif | 388 | |
393 | _exit(0); | 389 | _exit(0); |
394 | } | 390 | } |
395 | 391 | ||
@@ -419,9 +415,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { | |||
419 | // copy the file | 415 | // copy the file |
420 | if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) // already a regular user | 416 | if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) // already a regular user |
421 | _exit(1); | 417 | _exit(1); |
422 | #ifdef HAVE_GCOV | 418 | |
423 | __gcov_flush(); | 419 | __gcov_flush(); |
424 | #endif | 420 | |
425 | _exit(0); | 421 | _exit(0); |
426 | } | 422 | } |
427 | 423 | ||
diff --git a/src/firejail/main.c b/src/firejail/main.c index 86c6575e2..9624c35bc 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include "../include/pid.h" | 21 | #include "../include/pid.h" |
22 | #include "../include/firejail_user.h" | 22 | #include "../include/firejail_user.h" |
23 | #include "../include/gcov_wrapper.h" | ||
23 | #include "../include/syscall.h" | 24 | #include "../include/syscall.h" |
24 | #include "../include/seccomp.h" | 25 | #include "../include/seccomp.h" |
25 | #define _GNU_SOURCE | 26 | #define _GNU_SOURCE |
@@ -44,10 +45,6 @@ | |||
44 | #define O_PATH 010000000 | 45 | #define O_PATH 010000000 |
45 | #endif | 46 | #endif |
46 | 47 | ||
47 | #ifdef HAVE_GCOV | ||
48 | #include "../include/gcov_wrapper.h" | ||
49 | #endif | ||
50 | |||
51 | #ifdef __ia64__ | 48 | #ifdef __ia64__ |
52 | /* clone(2) has a different interface on ia64, as it needs to know | 49 | /* clone(2) has a different interface on ia64, as it needs to know |
53 | the size of the stack */ | 50 | the size of the stack */ |
@@ -3024,9 +3021,9 @@ int main(int argc, char **argv, char **envp) { | |||
3024 | network_main(child); | 3021 | network_main(child); |
3025 | if (arg_debug) | 3022 | if (arg_debug) |
3026 | printf("Host network configured\n"); | 3023 | printf("Host network configured\n"); |
3027 | #ifdef HAVE_GCOV | 3024 | |
3028 | __gcov_flush(); | 3025 | __gcov_flush(); |
3029 | #endif | 3026 | |
3030 | _exit(0); | 3027 | _exit(0); |
3031 | } | 3028 | } |
3032 | 3029 | ||
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 8675a1712..a06d0b69d 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -18,15 +18,12 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include "../include/seccomp.h" | 22 | #include "../include/seccomp.h" |
22 | #include "../include/syscall.h" | 23 | #include "../include/syscall.h" |
23 | #include <dirent.h> | 24 | #include <dirent.h> |
24 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
25 | 26 | ||
26 | #ifdef HAVE_GCOV | ||
27 | #include "../include/gcov_wrapper.h" | ||
28 | #endif | ||
29 | |||
30 | extern char *xephyr_screen; | 27 | extern char *xephyr_screen; |
31 | 28 | ||
32 | #define MAX_READ 8192 // line buffer for profile files | 29 | #define MAX_READ 8192 // line buffer for profile files |
@@ -1799,9 +1796,8 @@ void profile_read(const char *fname) { | |||
1799 | // else { | 1796 | // else { |
1800 | // free(ptr); | 1797 | // free(ptr); |
1801 | // } | 1798 | // } |
1802 | #ifdef HAVE_GCOV | 1799 | |
1803 | __gcov_flush(); | 1800 | __gcov_flush(); |
1804 | #endif | ||
1805 | } | 1801 | } |
1806 | fclose(fp); | 1802 | fclose(fp); |
1807 | } | 1803 | } |
diff --git a/src/firejail/rlimit.c b/src/firejail/rlimit.c index 2666486fa..f177f4b89 100644 --- a/src/firejail/rlimit.c +++ b/src/firejail/rlimit.c | |||
@@ -18,13 +18,10 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <sys/time.h> | 22 | #include <sys/time.h> |
22 | #include <sys/resource.h> | 23 | #include <sys/resource.h> |
23 | 24 | ||
24 | #ifdef HAVE_GCOV | ||
25 | #include "../include/gcov_wrapper.h" | ||
26 | #endif | ||
27 | |||
28 | void set_rlimits(void) { | 25 | void set_rlimits(void) { |
29 | EUID_ASSERT(); | 26 | EUID_ASSERT(); |
30 | // resource limits | 27 | // resource limits |
@@ -37,9 +34,9 @@ void set_rlimits(void) { | |||
37 | // set the new limit | 34 | // set the new limit |
38 | rl.rlim_cur = (rlim_t) cfg.rlimit_cpu; | 35 | rl.rlim_cur = (rlim_t) cfg.rlimit_cpu; |
39 | rl.rlim_max = (rlim_t) cfg.rlimit_cpu; | 36 | rl.rlim_max = (rlim_t) cfg.rlimit_cpu; |
40 | #ifdef HAVE_GCOV | 37 | |
41 | __gcov_dump(); | 38 | __gcov_dump(); |
42 | #endif | 39 | |
43 | if (setrlimit(RLIMIT_CPU, &rl) == -1) | 40 | if (setrlimit(RLIMIT_CPU, &rl) == -1) |
44 | errExit("setrlimit"); | 41 | errExit("setrlimit"); |
45 | if (arg_debug) | 42 | if (arg_debug) |
@@ -54,9 +51,10 @@ void set_rlimits(void) { | |||
54 | // set the new limit | 51 | // set the new limit |
55 | rl.rlim_cur = (rlim_t) cfg.rlimit_nofile; | 52 | rl.rlim_cur = (rlim_t) cfg.rlimit_nofile; |
56 | rl.rlim_max = (rlim_t) cfg.rlimit_nofile; | 53 | rl.rlim_max = (rlim_t) cfg.rlimit_nofile; |
57 | #ifdef HAVE_GCOV // gcov-instrumented programs might crash at this point | 54 | |
55 | // gcov-instrumented programs might crash at this point | ||
58 | __gcov_dump(); | 56 | __gcov_dump(); |
59 | #endif | 57 | |
60 | if (setrlimit(RLIMIT_NOFILE, &rl) == -1) | 58 | if (setrlimit(RLIMIT_NOFILE, &rl) == -1) |
61 | errExit("setrlimit"); | 59 | errExit("setrlimit"); |
62 | if (arg_debug) | 60 | if (arg_debug) |
@@ -71,9 +69,9 @@ void set_rlimits(void) { | |||
71 | // set the new limit | 69 | // set the new limit |
72 | rl.rlim_cur = (rlim_t) cfg.rlimit_nproc; | 70 | rl.rlim_cur = (rlim_t) cfg.rlimit_nproc; |
73 | rl.rlim_max = (rlim_t) cfg.rlimit_nproc; | 71 | rl.rlim_max = (rlim_t) cfg.rlimit_nproc; |
74 | #ifdef HAVE_GCOV | 72 | |
75 | __gcov_dump(); | 73 | __gcov_dump(); |
76 | #endif | 74 | |
77 | if (setrlimit(RLIMIT_NPROC, &rl) == -1) | 75 | if (setrlimit(RLIMIT_NPROC, &rl) == -1) |
78 | errExit("setrlimit"); | 76 | errExit("setrlimit"); |
79 | if (arg_debug) | 77 | if (arg_debug) |
@@ -88,9 +86,9 @@ void set_rlimits(void) { | |||
88 | // set the new limit | 86 | // set the new limit |
89 | rl.rlim_cur = (rlim_t) cfg.rlimit_fsize; | 87 | rl.rlim_cur = (rlim_t) cfg.rlimit_fsize; |
90 | rl.rlim_max = (rlim_t) cfg.rlimit_fsize; | 88 | rl.rlim_max = (rlim_t) cfg.rlimit_fsize; |
91 | #ifdef HAVE_GCOV | 89 | |
92 | __gcov_dump(); | 90 | __gcov_dump(); |
93 | #endif | 91 | |
94 | if (setrlimit(RLIMIT_FSIZE, &rl) == -1) | 92 | if (setrlimit(RLIMIT_FSIZE, &rl) == -1) |
95 | errExit("setrlimit"); | 93 | errExit("setrlimit"); |
96 | if (arg_debug) | 94 | if (arg_debug) |
@@ -105,9 +103,9 @@ void set_rlimits(void) { | |||
105 | // set the new limit | 103 | // set the new limit |
106 | rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending; | 104 | rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending; |
107 | rl.rlim_max = (rlim_t) cfg.rlimit_sigpending; | 105 | rl.rlim_max = (rlim_t) cfg.rlimit_sigpending; |
108 | #ifdef HAVE_GCOV | 106 | |
109 | __gcov_dump(); | 107 | __gcov_dump(); |
110 | #endif | 108 | |
111 | if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1) | 109 | if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1) |
112 | errExit("setrlimit"); | 110 | errExit("setrlimit"); |
113 | if (arg_debug) | 111 | if (arg_debug) |
@@ -122,9 +120,9 @@ void set_rlimits(void) { | |||
122 | // set the new limit | 120 | // set the new limit |
123 | rl.rlim_cur = (rlim_t) cfg.rlimit_as; | 121 | rl.rlim_cur = (rlim_t) cfg.rlimit_as; |
124 | rl.rlim_max = (rlim_t) cfg.rlimit_as; | 122 | rl.rlim_max = (rlim_t) cfg.rlimit_as; |
125 | #ifdef HAVE_GCOV | 123 | |
126 | __gcov_dump(); | 124 | __gcov_dump(); |
127 | #endif | 125 | |
128 | if (setrlimit(RLIMIT_AS, &rl) == -1) | 126 | if (setrlimit(RLIMIT_AS, &rl) == -1) |
129 | errExit("setrlimit"); | 127 | errExit("setrlimit"); |
130 | if (arg_debug) | 128 | if (arg_debug) |
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c index 7bf372a14..cfcb6d714 100644 --- a/src/firejail/sandbox.c +++ b/src/firejail/sandbox.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "firejail.h" | 21 | #include "firejail.h" |
22 | #include "../include/gcov_wrapper.h" | ||
22 | #include "../include/seccomp.h" | 23 | #include "../include/seccomp.h" |
23 | #include <sys/mman.h> | 24 | #include <sys/mman.h> |
24 | #include <sys/mount.h> | 25 | #include <sys/mount.h> |
@@ -49,10 +50,6 @@ | |||
49 | #include <sys/apparmor.h> | 50 | #include <sys/apparmor.h> |
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | #ifdef HAVE_GCOV | ||
53 | #include "../include/gcov_wrapper.h" | ||
54 | #endif | ||
55 | |||
56 | static int force_nonewprivs = 0; | 53 | static int force_nonewprivs = 0; |
57 | 54 | ||
58 | static int monitored_pid = 0; | 55 | static int monitored_pid = 0; |
@@ -507,9 +504,8 @@ void start_application(int no_sandbox, int fd, char *set_sandbox_status) { | |||
507 | exit(1); | 504 | exit(1); |
508 | } | 505 | } |
509 | 506 | ||
510 | #ifdef HAVE_GCOV | ||
511 | __gcov_dump(); | 507 | __gcov_dump(); |
512 | #endif | 508 | |
513 | seccomp_install_filters(); | 509 | seccomp_install_filters(); |
514 | 510 | ||
515 | if (set_sandbox_status) | 511 | if (set_sandbox_status) |
@@ -563,9 +559,8 @@ void start_application(int no_sandbox, int fd, char *set_sandbox_status) { | |||
563 | if (!arg_command && !arg_quiet) | 559 | if (!arg_command && !arg_quiet) |
564 | print_time(); | 560 | print_time(); |
565 | 561 | ||
566 | #ifdef HAVE_GCOV | ||
567 | __gcov_dump(); | 562 | __gcov_dump(); |
568 | #endif | 563 | |
569 | seccomp_install_filters(); | 564 | seccomp_install_filters(); |
570 | 565 | ||
571 | if (set_sandbox_status) | 566 | if (set_sandbox_status) |
diff --git a/src/firejail/util.c b/src/firejail/util.c index 71dd84e8f..3e6c56f73 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | #define _XOPEN_SOURCE 500 | 20 | #define _XOPEN_SOURCE 500 |
21 | #include "firejail.h" | 21 | #include "firejail.h" |
22 | #include "../include/gcov_wrapper.h" | ||
22 | #include <ftw.h> | 23 | #include <ftw.h> |
23 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
24 | #include <sys/mount.h> | 25 | #include <sys/mount.h> |
@@ -41,10 +42,6 @@ | |||
41 | #include <linux/openat2.h> | 42 | #include <linux/openat2.h> |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | #ifdef HAVE_GCOV | ||
45 | #include "../include/gcov_wrapper.h" | ||
46 | #endif | ||
47 | |||
48 | #define MAX_GROUPS 1024 | 45 | #define MAX_GROUPS 1024 |
49 | #define MAXBUF 4098 | 46 | #define MAXBUF 4098 |
50 | #define EMPTY_STRING ("") | 47 | #define EMPTY_STRING ("") |
@@ -341,9 +338,9 @@ void copy_file_as_user(const char *srcname, const char *destname, uid_t uid, gid | |||
341 | int rv = copy_file(srcname, destname, uid, gid, mode); // already a regular user | 338 | int rv = copy_file(srcname, destname, uid, gid, mode); // already a regular user |
342 | if (rv) | 339 | if (rv) |
343 | fwarning("cannot copy %s\n", srcname); | 340 | fwarning("cannot copy %s\n", srcname); |
344 | #ifdef HAVE_GCOV | 341 | |
345 | __gcov_flush(); | 342 | __gcov_flush(); |
346 | #endif | 343 | |
347 | _exit(0); | 344 | _exit(0); |
348 | } | 345 | } |
349 | // wait for the child to finish | 346 | // wait for the child to finish |
@@ -375,9 +372,9 @@ void copy_file_from_user_to_root(const char *srcname, const char *destname, uid_ | |||
375 | close(src); | 372 | close(src); |
376 | } | 373 | } |
377 | close(dst); | 374 | close(dst); |
378 | #ifdef HAVE_GCOV | 375 | |
379 | __gcov_flush(); | 376 | __gcov_flush(); |
380 | #endif | 377 | |
381 | _exit(0); | 378 | _exit(0); |
382 | } | 379 | } |
383 | // wait for the child to finish | 380 | // wait for the child to finish |
@@ -406,9 +403,9 @@ void touch_file_as_user(const char *fname, mode_t mode) { | |||
406 | } | 403 | } |
407 | else | 404 | else |
408 | fwarning("cannot create %s\n", fname); | 405 | fwarning("cannot create %s\n", fname); |
409 | #ifdef HAVE_GCOV | 406 | |
410 | __gcov_flush(); | 407 | __gcov_flush(); |
411 | #endif | 408 | |
412 | _exit(0); | 409 | _exit(0); |
413 | } | 410 | } |
414 | // wait for the child to finish | 411 | // wait for the child to finish |
@@ -1015,9 +1012,9 @@ int remove_overlay_directory(void) { | |||
1015 | // remove ~/.firejail | 1012 | // remove ~/.firejail |
1016 | if (rmdir(path) == -1) | 1013 | if (rmdir(path) == -1) |
1017 | errExit("rmdir"); | 1014 | errExit("rmdir"); |
1018 | #ifdef HAVE_GCOV | 1015 | |
1019 | __gcov_flush(); | 1016 | __gcov_flush(); |
1020 | #endif | 1017 | |
1021 | _exit(0); | 1018 | _exit(0); |
1022 | } | 1019 | } |
1023 | // wait for the child to finish | 1020 | // wait for the child to finish |
@@ -1073,9 +1070,9 @@ int create_empty_dir_as_user(const char *dir, mode_t mode) { | |||
1073 | } | 1070 | } |
1074 | else if (arg_debug) | 1071 | else if (arg_debug) |
1075 | printf("Directory %s not created: %s\n", dir, strerror(errno)); | 1072 | printf("Directory %s not created: %s\n", dir, strerror(errno)); |
1076 | #ifdef HAVE_GCOV | 1073 | |
1077 | __gcov_flush(); | 1074 | __gcov_flush(); |
1078 | #endif | 1075 | |
1079 | _exit(0); | 1076 | _exit(0); |
1080 | } | 1077 | } |
1081 | waitpid(child, NULL, 0); | 1078 | waitpid(child, NULL, 0); |
diff --git a/src/firemon/interface.c b/src/firemon/interface.c index 372cdee41..780e3d706 100644 --- a/src/firemon/interface.c +++ b/src/firemon/interface.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firemon.h" | 20 | #include "firemon.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <sys/types.h> | 22 | #include <sys/types.h> |
22 | #include <sys/wait.h> | 23 | #include <sys/wait.h> |
23 | #include <netdb.h> | 24 | #include <netdb.h> |
@@ -33,10 +34,6 @@ | |||
33 | //#include <net/route.h> | 34 | //#include <net/route.h> |
34 | //#include <linux/if_bridge.h> | 35 | //#include <linux/if_bridge.h> |
35 | 36 | ||
36 | #ifdef HAVE_GCOV | ||
37 | #include "../include/gcov_wrapper.h" | ||
38 | #endif | ||
39 | |||
40 | // print IP addresses for all interfaces | 37 | // print IP addresses for all interfaces |
41 | static void net_ifprint(void) { | 38 | static void net_ifprint(void) { |
42 | uint32_t ip; | 39 | uint32_t ip; |
@@ -149,9 +146,9 @@ static void print_sandbox(pid_t pid) { | |||
149 | if (rv) | 146 | if (rv) |
150 | return; | 147 | return; |
151 | net_ifprint(); | 148 | net_ifprint(); |
152 | #ifdef HAVE_GCOV | 149 | |
153 | __gcov_flush(); | 150 | __gcov_flush(); |
154 | #endif | 151 | |
155 | _exit(0); | 152 | _exit(0); |
156 | } | 153 | } |
157 | 154 | ||
diff --git a/src/firemon/netstats.c b/src/firemon/netstats.c index 205ad7601..9d8e5d7f5 100644 --- a/src/firemon/netstats.c +++ b/src/firemon/netstats.c | |||
@@ -18,16 +18,13 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firemon.h" | 20 | #include "firemon.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <termios.h> | 22 | #include <termios.h> |
22 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
25 | #include <unistd.h> | 26 | #include <unistd.h> |
26 | 27 | ||
27 | #ifdef HAVE_GCOV | ||
28 | #include "../include/gcov_wrapper.h" | ||
29 | #endif | ||
30 | |||
31 | #define MAXBUF 4096 | 28 | #define MAXBUF 4096 |
32 | 29 | ||
33 | // ip -s link: device stats | 30 | // ip -s link: device stats |
@@ -246,8 +243,7 @@ void netstats(void) { | |||
246 | print_proc(i, itv, col); | 243 | print_proc(i, itv, col); |
247 | } | 244 | } |
248 | } | 245 | } |
249 | #ifdef HAVE_GCOV | 246 | |
250 | __gcov_flush(); | 247 | __gcov_flush(); |
251 | #endif | ||
252 | } | 248 | } |
253 | } | 249 | } |
diff --git a/src/firemon/procevent.c b/src/firemon/procevent.c index 79f487582..716a9cba4 100644 --- a/src/firemon/procevent.c +++ b/src/firemon/procevent.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firemon.h" | 20 | #include "firemon.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <sys/socket.h> | 22 | #include <sys/socket.h> |
22 | #include <linux/connector.h> | 23 | #include <linux/connector.h> |
23 | #include <linux/netlink.h> | 24 | #include <linux/netlink.h> |
@@ -30,10 +31,6 @@ | |||
30 | #include <fcntl.h> | 31 | #include <fcntl.h> |
31 | #include <sys/uio.h> | 32 | #include <sys/uio.h> |
32 | 33 | ||
33 | #ifdef HAVE_GCOV | ||
34 | #include "../include/gcov_wrapper.h" | ||
35 | #endif | ||
36 | |||
37 | #define PIDS_BUFLEN 4096 | 34 | #define PIDS_BUFLEN 4096 |
38 | #define SERVER_PORT 889 // 889-899 is left unassigned by IANA | 35 | #define SERVER_PORT 889 // 889-899 is left unassigned by IANA |
39 | 36 | ||
@@ -234,9 +231,7 @@ static void __attribute__((noreturn)) procevent_monitor(const int sock, pid_t my | |||
234 | tv.tv_usec = 0; | 231 | tv.tv_usec = 0; |
235 | 232 | ||
236 | while (1) { | 233 | while (1) { |
237 | #ifdef HAVE_GCOV | ||
238 | __gcov_flush(); | 234 | __gcov_flush(); |
239 | #endif | ||
240 | 235 | ||
241 | #define BUFFSIZE 4096 | 236 | #define BUFFSIZE 4096 |
242 | char __attribute__ ((aligned(NLMSG_ALIGNTO)))buf[BUFFSIZE]; | 237 | char __attribute__ ((aligned(NLMSG_ALIGNTO)))buf[BUFFSIZE]; |
diff --git a/src/firemon/top.c b/src/firemon/top.c index 585fdcdab..2217cc7de 100644 --- a/src/firemon/top.c +++ b/src/firemon/top.c | |||
@@ -18,16 +18,13 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firemon.h" | 20 | #include "firemon.h" |
21 | #include "../include/gcov_wrapper.h" | ||
21 | #include <termios.h> | 22 | #include <termios.h> |
22 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
25 | #include <unistd.h> | 26 | #include <unistd.h> |
26 | 27 | ||
27 | #ifdef HAVE_GCOV | ||
28 | #include "../include/gcov_wrapper.h" | ||
29 | #endif | ||
30 | |||
31 | static unsigned pgs_rss = 0; | 28 | static unsigned pgs_rss = 0; |
32 | static unsigned pgs_shared = 0; | 29 | static unsigned pgs_shared = 0; |
33 | static unsigned clocktick = 0; | 30 | static unsigned clocktick = 0; |
@@ -330,8 +327,7 @@ void top(void) { | |||
330 | } | 327 | } |
331 | } | 328 | } |
332 | head_print(col, row); | 329 | head_print(col, row); |
333 | #ifdef HAVE_GCOV | 330 | |
334 | __gcov_flush(); | 331 | __gcov_flush(); |
335 | #endif | ||
336 | } | 332 | } |
337 | } | 333 | } |
diff --git a/src/include/gcov_wrapper.h b/src/include/gcov_wrapper.h index 2f409309d..4aafb8e18 100644 --- a/src/include/gcov_wrapper.h +++ b/src/include/gcov_wrapper.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifndef GCOV_WRAPPER_H | 21 | #ifndef GCOV_WRAPPER_H |
22 | #define GCOV_WRAPPER_H | 22 | #define GCOV_WRAPPER_H |
23 | 23 | ||
24 | #ifdef HAS_GCOV | ||
24 | #include <gcov.h> | 25 | #include <gcov.h> |
25 | 26 | ||
26 | /* | 27 | /* |
@@ -36,5 +37,10 @@ static void __gcov_flush(void) { | |||
36 | __gcov_reset(); | 37 | __gcov_reset(); |
37 | } | 38 | } |
38 | #endif | 39 | #endif |
40 | #else | ||
41 | #define __gcov_dump() ((void)0) | ||
42 | #define __gcov_reset() ((void)0) | ||
43 | #define __gcov_flush() ((void)0) | ||
44 | #endif /* HAS_GCOV */ | ||
39 | 45 | ||
40 | #endif /* GCOV_WRAPPER_H */ | 46 | #endif /* GCOV_WRAPPER_H */ |