diff options
Diffstat (limited to 'src/firejail/profile.c')
-rw-r--r-- | src/firejail/profile.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index fc390c83a..e61f59f46 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -1193,6 +1193,29 @@ void profile_read(const char *fname) { | |||
1193 | exit(1); | 1193 | exit(1); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | // save the name of the file for --profile.print option | ||
1197 | if (include_level == 0) { | ||
1198 | char *runfile; | ||
1199 | if (asprintf(&runfile, "%s/%d", RUN_FIREJAIL_PROFILE_DIR, getpid()) == -1) | ||
1200 | errExit("asprintf"); | ||
1201 | |||
1202 | EUID_ROOT(); | ||
1203 | // the file is deleted first | ||
1204 | FILE *fp = fopen(runfile, "w"); | ||
1205 | if (!fp) { | ||
1206 | fprintf(stderr, "Error: cannot create %s\n", runfile); | ||
1207 | exit(1); | ||
1208 | } | ||
1209 | fprintf(fp, "%s\n", fname); | ||
1210 | |||
1211 | // mode and ownership | ||
1212 | SET_PERMS_STREAM(fp, 0, 0, 0644); | ||
1213 | fclose(fp); | ||
1214 | EUID_USER(); | ||
1215 | free(runfile); | ||
1216 | } | ||
1217 | |||
1218 | |||
1196 | int msg_printed = 0; | 1219 | int msg_printed = 0; |
1197 | 1220 | ||
1198 | // read the file line by line | 1221 | // read the file line by line |