aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/fs_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/fs_trace.c')
-rw-r--r--src/firejail/fs_trace.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/firejail/fs_trace.c b/src/firejail/fs_trace.c
index 6058bf3c4..2b0f52a98 100644
--- a/src/firejail/fs_trace.c
+++ b/src/firejail/fs_trace.c
@@ -52,23 +52,21 @@ void fs_trace(void) {
52 // create the new ld.so.preload file and mount-bind it 52 // create the new ld.so.preload file and mount-bind it
53 if (arg_debug) 53 if (arg_debug)
54 printf("Create the new ld.so.preload file\n"); 54 printf("Create the new ld.so.preload file\n");
55 char *preload; 55
56 if (asprintf(&preload, "%s/ld.so.preload", MNT_DIR) == -1) 56 FILE *fp = fopen(LDPRELOAD_FILE, "w");
57 errExit("asprintf");
58 FILE *fp = fopen(preload, "w");
59 if (!fp) 57 if (!fp)
60 errExit("fopen"); 58 errExit("fopen");
61 fprintf(fp, "%s/firejail/libtrace.so\n", LIBDIR); 59 fprintf(fp, "%s/firejail/libtrace.so\n", LIBDIR);
62 fclose(fp); 60 fclose(fp);
63 if (chown(preload, 0, 0) < 0) 61 if (chown(LDPRELOAD_FILE, 0, 0) < 0)
64 errExit("chown"); 62 errExit("chown");
65 if (chmod(preload, S_IRUSR | S_IWRITE | S_IRGRP | S_IROTH ) < 0) 63 if (chmod(LDPRELOAD_FILE, S_IRUSR | S_IWRITE | S_IRGRP | S_IROTH ) < 0)
66 errExit("chmod"); 64 errExit("chmod");
67 65
68 // mount the new preload file 66 // mount the new preload file
69 if (arg_debug) 67 if (arg_debug)
70 printf("Mount the new ld.so.preload file\n"); 68 printf("Mount the new ld.so.preload file\n");
71 if (mount(preload, "/etc/ld.so.preload", NULL, MS_BIND|MS_REC, NULL) < 0) 69 if (mount(LDPRELOAD_FILE, "/etc/ld.so.preload", NULL, MS_BIND|MS_REC, NULL) < 0)
72 errExit("mount bind ls.so.preload"); 70 errExit("mount bind ls.so.preload");
73} 71}
74 72