* Jim Meyering <[EMAIL PROTECTED]> [080425 08:55]:
> Patches welcome.

Apologies if I'm over-simplifying, I'm not familiar with the coreutils
code.  This does seem to cause --no-preserve=mode to work as expected
for both directories and files (although it keeps the source's x bit),
and does pass all tests from make check.

Patch against git trunk:

--- a/src/copy.c        2008-04-25 12:21:57.597167502 -0500
+++ b/src/copy.c        2008-04-25 12:35:28.799419214 -0500
@@ -1624,7 +1624,11 @@
      special mode bits may change after the directory is created),
      omit some permissions at first, so unauthorized users cannot nip
      in before the file is ready.  */
-  dst_mode_bits = (x->set_mode ? x->mode : src_mode) & CHMOD_MODE_BITS;
+  dst_mode_bits = (x->set_mode ? x->mode :
+       (x->preserve_mode ? src_mode :
+        src_mode | (S_IRUSR | S_IRGRP | S_IROTH)
+        | (S_IWUSR | S_IWGRP | S_IWOTH)
+       )) & CHMOD_MODE_BITS;
   omitted_permissions =
     (dst_mode_bits
      & (x->preserve_ownership ? S_IRWXG | S_IRWXO
@@ -1827,7 +1831,7 @@
         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,
+      if (! copy_reg (src_name, dst_name, x, dst_mode_bits & S_IRWXUGO,
                      omitted_permissions, &new_dst, &src_sb))
        goto un_backup;
     }



_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to