On 17/11/2026 02:55, Collin Funk wrote:
* src/cp.c (re_protect): Clear special mode bits when lchownat fails.
* tests/cp/special-bits.sh: Add a test case.
* NEWS: Mention the bug fix.

I think this may also be needed to handle the `cp --preserve=owner --parents` 
case?

cheers,
Padraig

diff --git a/src/cp.c b/src/cp.cindex 1af5f78cf..60c24a176 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -434,7 +434,7 @@ re_protect (char const *const_dst_name, char const 
*dst_src_name,
         }
       else if (p->restore_mode)
         {
-          if (lchmodat (dst_dirfd, relname, p->st.st_mode) != 0)
+          if (lchmodat (dst_dirfd, relname, src_mode) != 0)
             {
               error (0, errno, _("failed to preserve permissions for %s"),
                      quoteaf (dst_name));

Reply via email to