RCS file: /cvsroot/mc/mc/src/file.c,v
retrieving revision 1.149
diff -u -p -r1.149 file.c
|
|
copy_file_file (FileOpContext *ctx, cons |
474 | 474 | int return_status, temp_status; |
475 | 475 | struct timeval tv_transfer_start; |
476 | 476 | int dst_status = DEST_NONE; /* 1 if the file is not fully copied */ |
| 477 | int open_flags; |
477 | 478 | |
478 | 479 | /* FIXME: We should not be using global variables! */ |
479 | 480 | ctx->do_reget = 0; |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
606 | 607 | utb.modtime = sb.st_mtime; |
607 | 608 | file_size = sb.st_size; |
608 | 609 | |
609 | | /* Create the new regular file with small permissions initially, |
610 | | do not create a security hole. FIXME: You have security hole |
611 | | here, btw. Imagine copying to /tmp and symlink attack :-( */ |
612 | | |
613 | | while ((dest_desc = mc_open (dst_path, O_WRONLY | (ctx->do_append ? |
614 | | O_APPEND : (O_CREAT | O_TRUNC)), 0600)) < 0) { |
| 610 | open_flags = O_WRONLY; |
| 611 | if (dst_exists != 0) { |
| 612 | if (ctx->do_append != 0) |
| 613 | open_flags |= O_APPEND; |
| 614 | else |
| 615 | open_flags |= O_CREAT | O_TRUNC; |
| 616 | } else { |
| 617 | open_flags |= O_CREAT | O_EXCL; |
| 618 | } |
| 619 | while ((dest_desc = mc_open (dst_path, open_flags, src_mode)) < 0) { |
| 620 | if (errno == EEXIST) { |
| 621 | goto ret; |
| 622 | } |
615 | 623 | return_status = file_error ( |
616 | 624 | _(" Cannot create target file \"%s\" \n %s "), dst_path); |
617 | 625 | if (return_status == FILE_RETRY) |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
790 | 798 | } |
791 | 799 | } |
792 | 800 | |
793 | | if (!appending) { |
| 801 | if (!appending && ctx->preserve) { |
794 | 802 | while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) { |
795 | 803 | temp_status = file_error ( |
796 | 804 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |