diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-02-16 14:42:43 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-02-16 14:42:43 +0000 |
commit | 7548e75065063dae256d94e6c7f4f9f43bd7f210 (patch) | |
tree | f23b000f8822f6eb70249c1106a3275deaa03bac /src/copy.c | |
parent | ddefcddae2e97579f82320f4fd70d0ba14a52392 (diff) | |
parent | 974ab3dd887985e3aa347f3c6521f819296396a0 (diff) | |
download | coreutils-7548e75065063dae256d94e6c7f4f9f43bd7f210.tar.gz |
Merge tag 'upstream/8.21'
Upstream version 8.21
Diffstat (limited to 'src/copy.c')
-rw-r--r-- | src/copy.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -1,5 +1,5 @@ /* copy.c -- core functions for copying files and directories - Copyright (C) 1989-2012 Free Software Foundation, Inc. + Copyright (C) 1989-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -165,7 +165,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, { if (errno == EINTR) continue; - error (0, errno, _("reading %s"), quote (src_name)); + error (0, errno, _("error reading %s"), quote (src_name)); return false; } if (n_read == 0) @@ -203,7 +203,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t n = n_read; if (full_write (dest_fd, buf, n) != n) { - error (0, errno, _("writing %s"), quote (dst_name)); + error (0, errno, _("error writing %s"), quote (dst_name)); return false; } @@ -1151,6 +1151,11 @@ preserve_metadata: if (set_acl (dst_name, dest_desc, x->mode) != 0) return_val = false; } + else if (x->explicit_no_preserve_mode) + { + if (set_acl (dst_name, dest_desc, 0666 & ~cached_umask ()) != 0) + return_val = false; + } else if (omitted_permissions) { omitted_permissions &= ~ cached_umask (); @@ -1167,13 +1172,13 @@ preserve_metadata: close_src_and_dst_desc: if (close (dest_desc) < 0) { - error (0, errno, _("closing %s"), quote (dst_name)); + error (0, errno, _("failed to close %s"), quote (dst_name)); return_val = false; } close_src_desc: if (close (source_desc) < 0) { - error (0, errno, _("closing %s"), quote (src_name)); + error (0, errno, _("failed to close %s"), quote (src_name)); return_val = false; } @@ -2389,8 +2394,13 @@ copy_internal (char const *src_name, char const *dst_name, /* POSIX says the permission bits of the source file must be used as the 3rd argument in the open call. Historical practice passed all the source mode bits to 'open', but the extra - bits were ignored, so it should be the same either way. */ - if (! copy_reg (src_name, dst_name, x, src_mode & S_IRWXUGO, + bits were ignored, so it should be the same either way. + + This call uses DST_MODE_BITS, not SRC_MODE. These are + normally the same, and the exception (where x->set_mode) is + used only by 'install', which POSIX does not specify and + where DST_MODE_BITS is what's wanted. */ + if (! copy_reg (src_name, dst_name, x, dst_mode_bits & S_IRWXUGO, omitted_permissions, &new_dst, &src_sb)) goto un_backup; } @@ -2570,6 +2580,11 @@ copy_internal (char const *src_name, char const *dst_name, if (set_acl (dst_name, -1, x->mode) != 0) return false; } + else if (x->explicit_no_preserve_mode) + { + if (set_acl (dst_name, -1, 0777 & ~cached_umask ()) != 0) + return false; + } else { if (omitted_permissions) |