aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/fs_home.c
diff options
context:
space:
mode:
authorLibravatar nextime <franco@unixmedia.it>2016-08-04 02:15:43 +0200
committerLibravatar nextime <franco@unixmedia.it>2016-08-04 02:15:43 +0200
commit8f512407ddb2abc3e2b7ae71f848916e7e3fc64d (patch)
tree50ebfd6aed46a44b9d80f9ee05576fc65c5f3bc9 /src/firejail/fs_home.c
parentFix minor bugs (diff)
downloadfirejail-8f512407ddb2abc3e2b7ae71f848916e7e3fc64d.tar.gz
firejail-8f512407ddb2abc3e2b7ae71f848916e7e3fc64d.tar.zst
firejail-8f512407ddb2abc3e2b7ae71f848916e7e3fc64d.zip
Make copydir work as expected
Diffstat (limited to 'src/firejail/fs_home.c')
-rw-r--r--src/firejail/fs_home.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c
index 3cb410569..604bba0e4 100644
--- a/src/firejail/fs_home.c
+++ b/src/firejail/fs_home.c
@@ -355,11 +355,22 @@ int fs_copydir(const char *path, const struct stat *st, int ftype, struct FTW *s
355 struct stat s; 355 struct stat s;
356 // don't copy it if we already have the file 356 // don't copy it if we already have the file
357 if (stat(dest, &s) == 0) 357 if (stat(dest, &s) == 0)
358 return 0; 358 return(0);
359 if (stat(path, &s) == 0) { 359 if (stat(path, &s) == 0) {
360 if (copy_file(path, dest) == 0) { 360 if(ftype == FTW_F) {
361 if (chown(dest, u, g) == -1) 361 if (copy_file(path, dest) == 0) {
362 errExit("chown"); 362 if (arg_debug)
363 printf("copy from %s to %s\n", path, dest);
364 if (chown(dest, u, g) == -1)
365 errExit("chown");
366 fs_logger2("clone", path);
367 }
368 }
369 else if(ftype == FTW_D) {
370 if (mkdir(dest, s.st_mode) == -1)
371 errExit("mkdir");
372 if (arg_debug)
373 printf("copy from %s to %s\n", path, dest);
363 fs_logger2("clone", path); 374 fs_logger2("clone", path);
364 } 375 }
365 } 376 }
@@ -369,11 +380,13 @@ int fs_copydir(const char *path, const struct stat *st, int ftype, struct FTW *s
369} 380}
370 381
371void fs_private_template(void) { 382void fs_private_template(void) {
383
372 fs_private(); 384 fs_private();
373 if(!nftw(cfg.private_template, fs_copydir, 1, FTW_PHYS)) { 385 if(nftw(cfg.private_template, fs_copydir, 1, FTW_PHYS) != 0) {
374 fprintf(stderr, "Error: unable to copy template dir\n"); 386 fprintf(stderr, "Error: unable to copy template dir\n");
375 exit(1); 387 exit(1);
376 } 388 }
389
377} 390}
378 391
379// check new private home directory (--private= option) - exit if it fails 392// check new private home directory (--private= option) - exit if it fails