From e244a8ca45b033c2bc45aa382c20277fbd952a57 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 3 Jun 2020 18:05:11 +0100
Subject: [PATCH] pv_cheap_tree_copy: Preserve permissions

It isn't particularly important either way, but there's no real reason
not to.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 src/utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/utils.c b/src/utils.c
index 0ee4ced1d..94a126fa7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -303,8 +303,8 @@ copy_tree_helper (const char *fpath,
           return 1;
         }
 
-      if (!glnx_shutil_mkdir_p_at (-1, nftw_data.dest_root, 0700, NULL,
-                                   error))
+      if (!glnx_shutil_mkdir_p_at (-1, nftw_data.dest_root,
+                                   sb->st_mode & 07777, NULL, error))
         return 1;
 
       return 0;
@@ -318,8 +318,8 @@ copy_tree_helper (const char *fpath,
   switch (typeflag)
     {
       case FTW_D:
-        /* For now we assume the permissions are not significant */
-        if (!glnx_shutil_mkdir_p_at (-1, dest, 0755, NULL, error))
+        if (!glnx_shutil_mkdir_p_at (-1, dest, sb->st_mode & 07777,
+                                     NULL, error))
           return 1;
         break;
 
-- 
GitLab