From 974ab3dd887985e3aa347f3c6521f819296396a0 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 16 Feb 2013 14:42:43 +0000 Subject: Imported Upstream version 8.21 --- src/copy.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/copy.c') diff --git a/src/copy.c b/src/copy.c index 2558fea1..3f2cc2b0 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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) -- cgit v1.2.3