Paul Eggert wrote:
> Thanks for the bug report.  I committed this patch:
>
> Subject: [PATCH] cp: don't mishandle existing dir dest permissions (Bug#9170)
>
> * src/copy.c (copy_internal): If we don't create the directory,
> then we cannot have omitted permissions.  Problem and trivial
> fix reported by Eric Lammerts.
> * tests/Makefile.am (TESTS): Add cp/existing-perm-dir.
> * tests/cp/existing-perm-dir: New file.

Thanks, Paul.

That is a bug fix, so it deserves a NEWS entry.
Do you feel like tracking down the point at which
the bug was introduced to mention it in NEWS?

I'll apply the change below to address the style issues.

>From 5f35396395a61a9dd60367066bd4495091bd6f88 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Tue, 26 Jul 2011 09:01:44 +0200
Subject: [PATCH] maint: use consistent style in C and test scripts

* src/copy.c (copy_internal): Adjust formatting style to conform with
guidelines in HACKING: put braces around two one-line "else" blocks.
* tests/cp/existing-perm-dir: Use $(...), not `...`, and
stat rather than ls+cut to get the mode string.
mode=$(stat --p=%A dst/dir)
---
 src/copy.c                 |    8 ++++++--
 tests/cp/existing-perm-dir |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/copy.c b/src/copy.c
index b2aeb6e..aaf7e79 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -951,7 +951,9 @@ copy_reg (char const *src_name, char const *dst_name,
         dest_errno = ENOTDIR;
     }
   else
-    omitted_permissions = 0;
+    {
+      omitted_permissions = 0;
+    }

   if (dest_desc < 0)
     {
@@ -2212,7 +2214,9 @@ copy_internal (char const *src_name, char const *dst_name,
             emit_verbose (src_name, dst_name, NULL);
         }
       else
-        omitted_permissions = 0;
+        {
+          omitted_permissions = 0;
+        }

       /* Decide whether to copy the contents of the directory.  */
       if (x->one_file_system && device != 0 && device != src_sb.st_dev)
diff --git a/tests/cp/existing-perm-dir b/tests/cp/existing-perm-dir
index 6ef73f0..a8c2816 100755
--- a/tests/cp/existing-perm-dir
+++ b/tests/cp/existing-perm-dir
@@ -25,7 +25,7 @@ mkdir -p -m ug-s,u=rwx,g=,o= dst/dir || fail=1

 cp -r src/. dst/ || fail=1

-mode=`ls -ld dst/dir | cut -b-10`
+mode=$(stat --p=%A dst/dir)
 test "$mode" = drwx------ || fail=1

 Exit $fail
--
1.7.6.609.gbf6a9



Reply via email to