diff options
Diffstat (limited to 'src/fcopy/main.c')
-rw-r--r-- | src/fcopy/main.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c index 9fca2a39b..3f507a361 100644 --- a/src/fcopy/main.c +++ b/src/fcopy/main.c | |||
@@ -25,9 +25,11 @@ | |||
25 | #include <pwd.h> | 25 | #include <pwd.h> |
26 | 26 | ||
27 | int arg_quiet = 0; | 27 | int arg_quiet = 0; |
28 | int arg_debug = 0; | ||
28 | static int arg_follow_link = 0; | 29 | static int arg_follow_link = 0; |
29 | 30 | ||
30 | #define COPY_LIMIT (500 * 1024 *1024) | 31 | static int copy_limit = 500 * 1024 *1024; // 500 MB |
32 | #define COPY_LIMIT ( | ||
31 | static int size_limit_reached = 0; | 33 | static int size_limit_reached = 0; |
32 | static unsigned file_cnt = 0; | 34 | static unsigned file_cnt = 0; |
33 | static unsigned size_cnt = 0; | 35 | static unsigned size_cnt = 0; |
@@ -184,8 +186,8 @@ static int fs_copydir(const char *infname, const struct stat *st, int ftype, str | |||
184 | mode_t mode = s.st_mode; | 186 | mode_t mode = s.st_mode; |
185 | 187 | ||
186 | // recalculate size | 188 | // recalculate size |
187 | if ((s.st_size + size_cnt) > COPY_LIMIT) { | 189 | if ((s.st_size + size_cnt) > copy_limit) { |
188 | fprintf(stderr, "Error fcopy: size limit of %dMB reached\n", (COPY_LIMIT / 1024) / 1024); | 190 | fprintf(stderr, "Error fcopy: size limit of %dMB reached\n", (copy_limit / 1024) / 1024); |
189 | size_limit_reached = 1; | 191 | size_limit_reached = 1; |
190 | free(outfname); | 192 | free(outfname); |
191 | return 0; | 193 | return 0; |
@@ -330,6 +332,9 @@ int main(int argc, char **argv) { | |||
330 | char *quiet = getenv("FIREJAIL_QUIET"); | 332 | char *quiet = getenv("FIREJAIL_QUIET"); |
331 | if (quiet && strcmp(quiet, "yes") == 0) | 333 | if (quiet && strcmp(quiet, "yes") == 0) |
332 | arg_quiet = 1; | 334 | arg_quiet = 1; |
335 | char *debug = getenv("FIREJAIL_DEBUG"); | ||
336 | if (debug && strcmp(debug, "yes") == 0) | ||
337 | arg_debug = 1; | ||
333 | 338 | ||
334 | char *src; | 339 | char *src; |
335 | char *dest; | 340 | char *dest; |
@@ -384,6 +389,14 @@ int main(int argc, char **argv) { | |||
384 | exit(1); | 389 | exit(1); |
385 | } | 390 | } |
386 | 391 | ||
392 | // extract copy limit size from env variable, if any | ||
393 | char *cl = getenv("FIREJAIL_FILE_COPY_LIMIT"); | ||
394 | if (cl) { | ||
395 | copy_limit = atoi(cl) * 1024 * 1024; | ||
396 | if (arg_debug) | ||
397 | printf("file copy limit %d bytes\n", copy_limit); | ||
398 | } | ||
399 | |||
387 | // copy files | 400 | // copy files |
388 | if ((arg_follow_link ? stat : lstat)(src, &s) == -1) { | 401 | if ((arg_follow_link ? stat : lstat)(src, &s) == -1) { |
389 | fprintf(stderr, "Error fcopy: src %s: %s\n", src, strerror(errno)); | 402 | fprintf(stderr, "Error fcopy: src %s: %s\n", src, strerror(errno)); |